VTK  9.3.20240418
vtkImageReslice.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
83 #ifndef vtkImageReslice_h
84 #define vtkImageReslice_h
85 
86 #include "vtkImagingCoreModule.h" // For export macro
88 
89 // interpolation mode constants
90 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
91 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
92 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
93 
94 VTK_ABI_NAMESPACE_BEGIN
95 class vtkImageData;
97 class vtkMatrix4x4;
99 class vtkScalarsToColors;
101 
102 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
103 {
104 public:
105  static vtkImageReslice* New();
107 
108  void PrintSelf(ostream& os, vtkIndent indent) override;
109 
111 
126  virtual void SetResliceAxes(vtkMatrix4x4*);
127  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
129 
131 
137  void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
138  double y2, double z0, double z1, double z2);
139  void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
140  {
141  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
142  }
143  void SetResliceAxesDirectionCosines(const double xyz[9])
144  {
145  this->SetResliceAxesDirectionCosines(
146  xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
147  }
148  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
149  void GetResliceAxesDirectionCosines(double xyz[9])
150  {
151  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
152  }
154  {
155  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
156  return this->ResliceAxesDirectionCosines;
157  }
159 
161 
167  void SetResliceAxesOrigin(double x, double y, double z);
168  void SetResliceAxesOrigin(const double xyz[3])
169  {
170  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
171  }
172  void GetResliceAxesOrigin(double xyz[3]);
174  {
175  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
176  return this->ResliceAxesOrigin;
177  }
179 
181 
191  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
193 
195 
205  vtkGetObjectMacro(InformationInput, vtkImageData);
207 
209 
216  vtkSetMacro(TransformInputSampling, vtkTypeBool);
217  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
218  vtkGetMacro(TransformInputSampling, vtkTypeBool);
220 
222 
227  vtkSetMacro(AutoCropOutput, vtkTypeBool);
228  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
229  vtkGetMacro(AutoCropOutput, vtkTypeBool);
231 
233 
236  vtkSetMacro(Wrap, vtkTypeBool);
237  vtkGetMacro(Wrap, vtkTypeBool);
238  vtkBooleanMacro(Wrap, vtkTypeBool);
240 
242 
246  vtkSetMacro(Mirror, vtkTypeBool);
247  vtkGetMacro(Mirror, vtkTypeBool);
248  vtkBooleanMacro(Mirror, vtkTypeBool);
250 
252 
262  vtkSetMacro(Border, vtkTypeBool);
263  vtkGetMacro(Border, vtkTypeBool);
264  vtkBooleanMacro(Border, vtkTypeBool);
266 
268 
273  vtkSetMacro(BorderThickness, double);
274  vtkGetMacro(BorderThickness, double);
276 
280  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
281  vtkGetMacro(InterpolationMode, int);
282  void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
283  void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
284  void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
285  virtual const char* GetInterpolationModeAsString();
287 
289 
296 
298 
304  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
305  vtkGetMacro(SlabMode, int);
306  void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
307  void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
308  void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
309  void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
310  virtual const char* GetSlabModeAsString();
312 
314 
317  vtkSetMacro(SlabNumberOfSlices, int);
318  vtkGetMacro(SlabNumberOfSlices, int);
320 
322 
327  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
328  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
329  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
331 
333 
342  vtkSetMacro(SlabSliceSpacingFraction, double);
343  vtkGetMacro(SlabSliceSpacingFraction, double);
345 
347 
351  vtkSetMacro(Optimization, vtkTypeBool);
352  vtkGetMacro(Optimization, vtkTypeBool);
353  vtkBooleanMacro(Optimization, vtkTypeBool);
355 
357 
364  vtkSetMacro(ScalarShift, double);
365  vtkGetMacro(ScalarShift, double);
367 
369 
376  vtkSetMacro(ScalarScale, double);
377  vtkGetMacro(ScalarScale, double);
379 
381 
391  vtkSetMacro(OutputScalarType, int);
392  vtkGetMacro(OutputScalarType, int);
394 
396 
399  vtkSetVector4Macro(BackgroundColor, double);
400  vtkGetVector4Macro(BackgroundColor, double);
402 
404 
407  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
408  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
410 
412 
416  virtual void SetOutputSpacing(double x, double y, double z);
417  virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
418  vtkGetVector3Macro(OutputSpacing, double);
421 
423 
432  virtual void SetOutputDirection(double xx, double xy, double xz, double yx, double yy, double yz,
433  double zx, double zy, double zz);
434  virtual void SetOutputDirection(const double a[9])
435  {
436  this->SetOutputDirection(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
437  }
438  vtkGetVector3Macro(OutputDirection, double);
441 
443 
447  virtual void SetOutputOrigin(double x, double y, double z);
448  virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
449  vtkGetVector3Macro(OutputOrigin, double);
452 
454 
458  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
459  virtual void SetOutputExtent(const int a[6])
460  {
461  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
462  }
463  vtkGetVector6Macro(OutputExtent, int);
466 
468 
478  vtkSetMacro(OutputDimensionality, int);
479  vtkGetMacro(OutputDimensionality, int);
481 
486  vtkMTimeType GetMTime() override;
487 
492 
494 
502  void SetInterpolate(int t)
503  {
504  if (t && !this->GetInterpolate())
505  {
506  this->SetInterpolationModeToLinear();
507  }
508  else if (!t && this->GetInterpolate())
509  {
510  this->SetInterpolationModeToNearestNeighbor();
511  }
512  }
513  void InterpolateOn() { this->SetInterpolate(1); }
514  void InterpolateOff() { this->SetInterpolate(0); }
515  int GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
517 
519 
527 
529 
533  vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
534  vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
535  vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
537 
539 
546 
547 protected:
549  ~vtkImageReslice() override;
550 
552  double ResliceAxesDirectionCosines[9];
553  double ResliceAxesOrigin[3];
562  int SlabMode;
566  double ScalarShift;
567  double ScalarScale;
569  double BackgroundColor[4];
570  double OutputDirection[9];
571  double OutputOrigin[3];
572  double OutputSpacing[3];
573  int OutputExtent[6];
585 
588 
594 
599  virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
600 
609  virtual void ConvertScalars(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
610  int count, int idX, int idY, int idZ, int threadId);
611 
612  void ConvertScalarsBase(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
613  int count, int idX, int idY, int idZ, int threadId)
614  {
615  this->ConvertScalars(
616  inPtr, outPtr, inputType, inputNumComponents, count, idX, idY, idZ, threadId);
617  }
618 
625 
627  vtkInformation* inInfo, const double outDirection[9], double bounds[6]);
628  void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
634  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData, int ext[6],
635  int id) override;
638 
640  vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
641 
642 private:
643  vtkImageReslice(const vtkImageReslice&) = delete;
644  void operator=(const vtkImageReslice&) = delete;
645 };
646 
647 VTK_ABI_NAMESPACE_END
648 #endif
interpolate data values from images
superclass for all geometric transformations
Proxy object to connect input/output ports.
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:610
general representation of visualization data
Detect and break reference loops.
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
Reslices a volume along a new set of axes.
void InterpolateOff()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
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...
double * GetResliceAxesOrigin()
Specify the origin for the ResliceAxes (i.e.
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.
virtual const char * GetInterpolationModeAsString()
vtkTypeBool Wrap
vtkTypeBool TransformInputSampling
void GetAutoCroppedOutputBounds(vtkInformation *inInfo, const double outDirection[9], 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...
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.
vtkTypeBool HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
static vtkImageReslice * New()
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.
virtual void SetOutputDirection(const double a[9])
Set the direction 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,...
double * GetResliceAxesDirectionCosines()
Specify the direction cosines for the ResliceAxes (i.e.
void SetInterpolationModeToCubic()
virtual void SetOutputDirection(double xx, double xy, double xz, double yx, double yy, double yz, double zx, double zy, double zz)
Set the direction for the output data.
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
double SlabSliceSpacingFraction
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.
vtkImageStencilData * GetStencilOutput()
Get the output stencil.
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).
vtkImageStencilData * GetStencil()
Use a stencil to limit the calculations to a specific region of the output.
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 SetOutputDirectionToDefault()
Set the direction for the output data.
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
virtual const char * GetSlabModeAsString()
Set the slab mode, for generating thick slices.
vtkMatrix4x4 * ResliceAxes
vtkAbstractTransform * GetOptimizedTransform()
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.
void ConvertScalarsBase(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
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
virtual vtkAbstractImageInterpolator * GetInterpolator()
Set the interpolator to use.
void SetInterpolationModeToNearestNeighbor()
vtkMatrix4x4 * GetIndexMatrix(vtkInformation *inInfo, vtkInformation *outInfo)
void SetOutputExtentToDefault()
Set the extent for the output data.
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
vtkImageData * InformationInput
vtkImageData * AllocateOutputData(vtkDataObject *, vtkInformation *) override
Allocate the output data.
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:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:141
Superclass for mapping scalar values to colors.
Generic filter that has one input.
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
int vtkTypeBool
Definition: vtkABI.h:64
#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:270
#define VTK_SIZEHINT(...)