VTK  9.1.0
vtkImageReslice.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkImageReslice.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
61#ifndef vtkImageReslice_h
62#define vtkImageReslice_h
63
64#include "vtkImagingCoreModule.h" // For export macro
66
67// interpolation mode constants
68#define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
69#define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
70#define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
71
72class vtkImageData;
74class vtkMatrix4x4;
78
79class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
80{
81public:
84
85 void PrintSelf(ostream& os, vtkIndent indent) override;
86
88
104 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
106
108
114 void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
115 double y2, double z0, double z1, double z2);
116 void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
117 {
118 this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
119 }
120 void SetResliceAxesDirectionCosines(const double xyz[9])
121 {
122 this->SetResliceAxesDirectionCosines(
123 xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
124 }
125 void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
127 {
128 this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
129 }
131 {
132 this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
133 return this->ResliceAxesDirectionCosines;
134 }
136
138
144 void SetResliceAxesOrigin(double x, double y, double z);
145 void SetResliceAxesOrigin(const double xyz[3])
146 {
147 this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
148 }
149 void GetResliceAxesOrigin(double xyz[3]);
151 {
152 this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
153 return this->ResliceAxesOrigin;
154 }
156
158
168 vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
170
172
182 vtkGetObjectMacro(InformationInput, vtkImageData);
184
186
193 vtkSetMacro(TransformInputSampling, vtkTypeBool);
194 vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
195 vtkGetMacro(TransformInputSampling, vtkTypeBool);
197
199
204 vtkSetMacro(AutoCropOutput, vtkTypeBool);
205 vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
206 vtkGetMacro(AutoCropOutput, vtkTypeBool);
208
210
213 vtkSetMacro(Wrap, vtkTypeBool);
214 vtkGetMacro(Wrap, vtkTypeBool);
215 vtkBooleanMacro(Wrap, vtkTypeBool);
217
219
223 vtkSetMacro(Mirror, vtkTypeBool);
224 vtkGetMacro(Mirror, vtkTypeBool);
225 vtkBooleanMacro(Mirror, vtkTypeBool);
227
229
239 vtkSetMacro(Border, vtkTypeBool);
240 vtkGetMacro(Border, vtkTypeBool);
241 vtkBooleanMacro(Border, vtkTypeBool);
243
245
250 vtkSetMacro(BorderThickness, double);
251 vtkGetMacro(BorderThickness, double);
253
257 vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
258 vtkGetMacro(InterpolationMode, int);
259 void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
260 void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
261 void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
262 virtual const char* GetInterpolationModeAsString();
264
266
273
275
281 vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
282 vtkGetMacro(SlabMode, int);
283 void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
284 void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
285 void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
286 void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
287 virtual const char* GetSlabModeAsString();
289
291
294 vtkSetMacro(SlabNumberOfSlices, int);
295 vtkGetMacro(SlabNumberOfSlices, int);
297
299
304 vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
305 vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
306 vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
308
310
319 vtkSetMacro(SlabSliceSpacingFraction, double);
320 vtkGetMacro(SlabSliceSpacingFraction, double);
322
324
328 vtkSetMacro(Optimization, vtkTypeBool);
329 vtkGetMacro(Optimization, vtkTypeBool);
330 vtkBooleanMacro(Optimization, vtkTypeBool);
332
334
341 vtkSetMacro(ScalarShift, double);
342 vtkGetMacro(ScalarShift, double);
344
346
353 vtkSetMacro(ScalarScale, double);
354 vtkGetMacro(ScalarScale, double);
356
358
368 vtkSetMacro(OutputScalarType, int);
369 vtkGetMacro(OutputScalarType, int);
371
373
376 vtkSetVector4Macro(BackgroundColor, double);
377 vtkGetVector4Macro(BackgroundColor, double);
379
381
384 void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
385 double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
387
389
393 virtual void SetOutputSpacing(double x, double y, double z);
394 virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
395 vtkGetVector3Macro(OutputSpacing, double);
398
400
404 virtual void SetOutputOrigin(double x, double y, double z);
405 virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
406 vtkGetVector3Macro(OutputOrigin, double);
409
411
415 virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
416 virtual void SetOutputExtent(const int a[6])
417 {
418 this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
419 }
420 vtkGetVector6Macro(OutputExtent, int);
423
425
435 vtkSetMacro(OutputDimensionality, int);
436 vtkGetMacro(OutputDimensionality, int);
438
444
449
451
459 void SetInterpolate(int t)
460 {
461 if (t && !this->GetInterpolate())
462 {
463 this->SetInterpolationModeToLinear();
464 }
465 else if (!t && this->GetInterpolate())
466 {
467 this->SetInterpolationModeToNearestNeighbor();
468 }
469 }
470 void InterpolateOn() { this->SetInterpolate(1); }
471 void InterpolateOff() { this->SetInterpolate(0); }
472 int GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
474
476
484
486
490 vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
491 vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
492 vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
494
496
503
504protected:
507
509 double ResliceAxesDirectionCosines[9];
510 double ResliceAxesOrigin[3];
526 double BackgroundColor[4];
527 double OutputOrigin[3];
528 double OutputSpacing[3];
529 int OutputExtent[6];
540
543
549
554 virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
555
564 virtual void ConvertScalars(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
565 int count, int idX, int idY, int idZ, int threadId);
566
567 void ConvertScalarsBase(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
568 int count, int idX, int idY, int idZ, int threadId)
569 {
570 this->ConvertScalars(
571 inPtr, outPtr, inputType, inputNumComponents, count, idX, idY, idZ, threadId);
572 }
573
580
581 void GetAutoCroppedOutputBounds(vtkInformation* inInfo, double bounds[6]);
582 void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
588 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData, int ext[6],
589 int id) override;
592
594 vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
595
596private:
597 vtkImageReslice(const vtkImageReslice&) = delete;
598 void operator=(const vtkImageReslice&) = delete;
599};
600
601#endif
interpolate data values from images
superclass for all geometric transformations
Proxy object to connect input/output ports.
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:479
general representation of visualization data
Definition: vtkDataObject.h:69
Detect and break reference loops.
topologically and geometrically regular array of data
Definition: vtkImageData.h:57
Reslices a volume along a new set of axes.
void InterpolateOff()
Convenient methods for switching between nearest-neighbor and linear interpolation.
int HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
vtkImageStencilData * GetStencil()
Use a stencil to limit the calculations to a specific region of the output.
virtual void SetOutputOrigin(const double a[3])
Set the origin for the output data.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ReportReferences(vtkGarbageCollector *) override
Report object referenced by instances of this class.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f)
Set the extent for the output data.
void SetResliceAxesDirectionCosines(const double xyz[9])
Specify the direction cosines for the ResliceAxes (i.e.
vtkTypeBool Wrap
vtkTypeBool TransformInputSampling
double * GetResliceAxesOrigin()
Specify the origin for the ResliceAxes (i.e.
void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6])
virtual void SetResliceTransform(vtkAbstractTransform *)
Set a transform to be applied to the resampling grid that has been defined via the ResliceAxes and th...
vtkTypeBool Border
int RequestInformationBase(vtkInformationVector **, vtkInformationVector *)
For derived classes, this should be called at the very end of RequestInformation() to ensure that var...
virtual const char * GetInterpolationModeAsString()
void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)
Specify the direction cosines for the ResliceAxes (i.e.
void SetSlabModeToMean()
Set the slab mode, for generating thick slices.
void InterpolateOn()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void SetResliceAxesOrigin(double x, double y, double z)
Specify the origin for the ResliceAxes (i.e.
void SetResliceAxesOrigin(const double xyz[3])
Specify the origin for the ResliceAxes (i.e.
virtual void ConvertScalars(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
This should be overridden by derived classes that operate on the interpolated data before it is place...
void GetResliceAxesDirectionCosines(double xyz[9])
Specify the direction cosines for the ResliceAxes (i.e.
virtual void SetOutputExtent(const int a[6])
Set the extent for the output data.
virtual void SetOutputOrigin(double x, double y, double z)
Set the origin for the output data.
vtkTypeBool Optimization
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetOutputSpacingToDefault()
Set the voxel spacing for the output data.
void SetStencilOutput(vtkImageStencilData *stencil)
Get the output stencil.
void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, int ext[6], int id) override
If the subclass does not define an Execute method, then the task will be broken up,...
vtkImageStencilData * GetStencilOutput()
Get the output stencil.
virtual vtkAbstractImageInterpolator * GetInterpolator()
Set the interpolator to use.
void SetInterpolationModeToCubic()
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
double SlabSliceSpacingFraction
vtkImageData * AllocateOutputData(vtkDataObject *, vtkInformation *) override
Allocate the output data.
vtkTypeBool Mirror
int GetInterpolate()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void GetResliceAxesOrigin(double xyz[3])
Specify the origin for the ResliceAxes (i.e.
void SetSlabModeToMin()
Set the slab mode, for generating thick slices.
virtual void SetOutputSpacing(const double a[3])
Set the voxel spacing for the output data.
double GetBackgroundLevel()
Set background grey level (for single-component images).
virtual int ConvertScalarInfo(int &scalarType, int &numComponents)
This should be overridden by derived classes that operate on the interpolated data before it is place...
~vtkImageReslice() override
void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) override
Allocate the output data.
void SetSlabModeToMax()
Set the slab mode, for generating thick slices.
vtkAbstractTransform * OptimizedTransform
vtkTypeBool SlabTrapezoidIntegration
vtkMatrix4x4 * IndexMatrix
vtkMTimeType GetMTime() override
When determining the modified time of the filter, this check the modified time of the transform and m...
vtkTypeBool AutoCropOutput
vtkTypeBool GenerateStencilOutput
vtkMatrix4x4 * ResliceAxes
virtual void SetOutputSpacing(double x, double y, double z)
Set the voxel spacing for the output data.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
static vtkImageReslice * New()
void ConvertScalarsBase(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
double * GetResliceAxesDirectionCosines()
Specify the direction cosines for the ResliceAxes (i.e.
vtkAbstractTransform * ResliceTransform
virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler)
Set the interpolator to use.
virtual void SetResliceAxes(vtkMatrix4x4 *)
This method is used to set up the axes for the output voxels.
vtkAbstractImageInterpolator * Interpolator
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
void SetInterpolationModeToNearestNeighbor()
void SetOutputExtentToDefault()
Set the extent for the output data.
virtual const char * GetSlabModeAsString()
Set the slab mode, for generating thick slices.
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
vtkAbstractTransform * GetOptimizedTransform()
void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
vtkMatrix4x4 * GetIndexMatrix(vtkInformation *inInfo, vtkInformation *outInfo)
vtkImageData * InformationInput
void SetBackgroundLevel(double v)
Set background grey level (for single-component images).
void SetOutputOriginToDefault()
Set the origin for the output data.
virtual void SetInformationInput(vtkImageData *)
Set a vtkImageData from which the default Spacing, Origin, and WholeExtent of the output will be copi...
void SetInterpolationModeToLinear()
int FillOutputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
void SetStencilData(vtkImageStencilData *stencil)
Use a stencil to limit the calculations to a specific region of the output.
void SetSlabModeToSum()
Set the slab mode, for generating thick slices.
efficient description of an image stencil
a simple class to control print indentation
Definition: vtkIndent.h:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:45
Superclass for mapping scalar values to colors.
Generic filter that has one input.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_RESLICE_CUBIC
#define VTK_RESLICE_NEAREST
#define VTK_RESLICE_LINEAR
#define VTK_IMAGE_SLAB_MAX
#define VTK_IMAGE_SLAB_MIN
#define VTK_IMAGE_SLAB_SUM
#define VTK_IMAGE_SLAB_MEAN
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)