VTK  9.7.1
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
44 #ifndef vtkImageReslice_h
45 #define vtkImageReslice_h
46 
47 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
48 #include "vtkImagingCoreModule.h" // For export macro
50 #include "vtkWrappingHints.h"
51 
52 // interpolation mode constants
53 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
54 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
55 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
56 
57 VTK_ABI_NAMESPACE_BEGIN
58 class vtkImageData;
60 class vtkMatrix4x4;
62 class vtkScalarsToColors;
64 class vtkDataArray;
65 
66 class VTKIMAGINGCORE_EXPORT VTK_MARSHALAUTO vtkImageReslice : public vtkThreadedImageAlgorithm
67 {
68 public:
69  static vtkImageReslice* New();
71 
72  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
75 
90  virtual void SetResliceAxes(vtkMatrix4x4*);
91  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
93 
95 
101  void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
102  double y2, double z0, double z1, double z2);
103  void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
104  {
105  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
106  }
107  void SetResliceAxesDirectionCosines(const double xyz[9])
108  {
109  this->SetResliceAxesDirectionCosines(
110  xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
111  }
112  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
113  void GetResliceAxesDirectionCosines(double xyz[9])
114  {
115  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
116  }
118  {
119  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
120  return this->ResliceAxesDirectionCosines;
121  }
123 
125 
131  void SetResliceAxesOrigin(double x, double y, double z);
132  void SetResliceAxesOrigin(const double xyz[3])
133  {
134  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
135  }
136  void GetResliceAxesOrigin(double xyz[3]);
138  {
139  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
140  return this->ResliceAxesOrigin;
141  }
143 
145 
154  virtual void SetResliceTransform(vtkAbstractTransform*);
155  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
157 
159 
168  virtual void SetInformationInput(vtkImageData*);
169  vtkGetObjectMacro(InformationInput, vtkImageData);
171 
173 
180  vtkSetMacro(TransformInputSampling, vtkTypeBool);
181  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
182  vtkGetMacro(TransformInputSampling, vtkTypeBool);
184 
186 
191  vtkSetMacro(AutoCropOutput, vtkTypeBool);
192  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
193  vtkGetMacro(AutoCropOutput, vtkTypeBool);
195 
197 
200  vtkSetMacro(Wrap, vtkTypeBool);
201  vtkGetMacro(Wrap, vtkTypeBool);
202  vtkBooleanMacro(Wrap, vtkTypeBool);
204 
206 
210  vtkSetMacro(Mirror, vtkTypeBool);
211  vtkGetMacro(Mirror, vtkTypeBool);
212  vtkBooleanMacro(Mirror, vtkTypeBool);
214 
216 
226  vtkSetMacro(Border, vtkTypeBool);
227  vtkGetMacro(Border, vtkTypeBool);
228  vtkBooleanMacro(Border, vtkTypeBool);
230 
232 
236  vtkSetMacro(BorderThickness, double);
238  vtkGetMacro(BorderThickness, double);
240 
244  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
245  vtkGetMacro(InterpolationMode, int);
246  void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
247  void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
248  void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
249  virtual const char* GetInterpolationModeAsString();
251 
253 
257  virtual void SetInterpolator(vtkAbstractImageInterpolator* sampler);
258  virtual vtkAbstractImageInterpolator* GetInterpolator();
260 
262 
268  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
269  vtkGetMacro(SlabMode, int);
270  void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
271  void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
272  void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
273  void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
274  virtual const char* GetSlabModeAsString();
276 
278 
281  vtkSetMacro(SlabNumberOfSlices, int);
282  vtkGetMacro(SlabNumberOfSlices, int);
284 
286 
291  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
292  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
293  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
295 
297 
306  vtkSetMacro(SlabSliceSpacingFraction, double);
307  vtkGetMacro(SlabSliceSpacingFraction, double);
309 
311 
315  vtkSetMacro(Optimization, vtkTypeBool);
316  vtkGetMacro(Optimization, vtkTypeBool);
317  vtkBooleanMacro(Optimization, vtkTypeBool);
319 
321 
328  vtkSetMacro(ScalarShift, double);
329  vtkGetMacro(ScalarShift, double);
331 
333 
340  vtkSetMacro(ScalarScale, double);
341  vtkGetMacro(ScalarScale, double);
343 
345 
355  vtkSetMacro(OutputScalarType, int);
356  vtkGetMacro(OutputScalarType, int);
358 
360 
366  vtkSetVector4Macro(BackgroundColor, double);
367  vtkGetVector4Macro(BackgroundColor, double);
369 
371 
374  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
375  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
377 
379 
383  virtual void SetOutputSpacing(double x, double y, double z);
384  virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
385  vtkGetVector3Macro(OutputSpacing, double);
386  void SetOutputSpacingToDefault();
388 
390 
399  virtual void SetOutputDirection(double xx, double xy, double xz, double yx, double yy, double yz,
400  double zx, double zy, double zz);
401  virtual void SetOutputDirection(const double a[9])
402  {
403  this->SetOutputDirection(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
404  }
405  vtkGetVector3Macro(OutputDirection, double);
406  void SetOutputDirectionToDefault();
408 
410 
414  virtual void SetOutputOrigin(double x, double y, double z);
415  virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
416  vtkGetVector3Macro(OutputOrigin, double);
417  void SetOutputOriginToDefault();
419 
421 
425  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
426  virtual void SetOutputExtent(const int a[6])
427  {
428  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
429  }
430  vtkGetVector6Macro(OutputExtent, int);
431  void SetOutputExtentToDefault();
433 
435 
445  vtkSetMacro(OutputDimensionality, int);
446  vtkGetMacro(OutputDimensionality, int);
448 
453  vtkMTimeType GetMTime() override;
454 
458  void ReportReferences(vtkGarbageCollector*) override;
459 
461 
470  {
471  if (t && !this->GetInterpolate())
472  {
473  this->SetInterpolationModeToLinear();
474  }
475  else if (!t && this->GetInterpolate())
476  {
477  this->SetInterpolationModeToNearestNeighbor();
478  }
479  }
480  void InterpolateOn() { this->SetInterpolate(1); }
481  void InterpolateOff() { this->SetInterpolate(0); }
482  vtkTypeBool GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
484 
486 
491  void SetStencilData(vtkImageStencilData* stencil);
492  vtkImageStencilData* GetStencil();
494 
496 
500  vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
501  vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
502  vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
504 
506 
510  vtkImageStencilData* GetStencilOutput();
511  void SetStencilOutput(vtkImageStencilData* stencil);
513 
514 protected:
515  vtkImageReslice();
516  ~vtkImageReslice() override;
517 
519  double ResliceAxesDirectionCosines[9];
520  double ResliceAxesOrigin[3];
529  int SlabMode;
533  double ScalarShift;
534  double ScalarScale;
536  double BackgroundColor[4];
537  double OutputDirection[9];
538  double OutputOrigin[3];
539  double OutputSpacing[3];
540  int OutputExtent[6];
552 
555 
561 
566  virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
567 
576  virtual void ConvertScalars(
577  vtkDataArray* input, void* outPtr, int count, int idX, int idY, int idZ, int threadId);
578 
580  vtkDataArray* input, void* outPtr, int count, int idX, int idY, int idZ, int threadId)
581  {
582  this->ConvertScalars(input, outPtr, count, idX, idY, idZ, threadId);
583  }
584 
592  VTK_DEPRECATED_IN_9_7_0("Use the ConvertScalars overload taking vtkDataArray* instead")
593  virtual void ConvertScalars(VTK_FUTURE_CONST void* inPtr, void* outPtr, int inputType,
594  int inputNumComponents, int count, int idX, int idY, int idZ, int threadId);
595 
596  void ConvertScalarsBase(VTK_FUTURE_CONST void* inPtr, void* outPtr, int inputType,
597  int inputNumComponents, int count, int idX, int idY, int idZ, int threadId);
598 
604  int RequestInformationBase(vtkInformationVector**, vtkInformationVector*);
605 
606  void GetAutoCroppedOutputBounds(
607  vtkInformation* inInfo, const double outDirection[9], double bounds[6]);
608  void AllocateOutputData(
609  vtkImageData* output, vtkInformation* outInfo, VTK_FUTURE_CONST int uExtent[6]) override;
610  vtkImageData* AllocateOutputData(vtkDataObject*, vtkInformation*) override;
611  int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
612  int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
613  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
614  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
615  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData,
616  VTK_FUTURE_CONST int ext[6], int id) override;
617  int FillInputPortInformation(int port, vtkInformation* info) override;
618  int FillOutputPortInformation(int port, vtkInformation* info) override;
619 
620  vtkMatrix4x4* GetIndexMatrix(vtkInformation* inInfo, vtkInformation* outInfo);
621  vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
622 
623 private:
624  vtkImageReslice(const vtkImageReslice&) = delete;
625  void operator=(const vtkImageReslice&) = delete;
626 };
627 
628 VTK_ABI_NAMESPACE_END
629 #endif
vtkTypeBool AutoCropOutput
double * GetResliceAxesDirectionCosines()
Specify the direction cosines for the ResliceAxes (i.e.
interpolate data values from images
#define VTK_IMAGE_SLAB_MAX
#define VTK_RESLICE_NEAREST
vtkTypeBool Wrap
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:621
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
#define VTK_IMAGE_SLAB_MIN
vtkTypeBool GetInterpolate()
Convenient methods for switching between nearest-neighbor and linear interpolation.
#define VTK_RESLICE_CUBIC
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
void SetSlabModeToMax()
Set the slab mode, for generating thick slices.
vtkMatrix4x4 * IndexMatrix
vtkTypeBool Optimization
#define VTK_IMAGE_SLAB_SUM
#define VTK_IMAGE_SLAB_MEAN
vtkTypeBool GenerateStencilOutput
void ReportReferences(vtkGarbageCollector *) override
void SetInterpolationModeToLinear()
void SetInterpolationModeToCubic()
void InterpolateOn()
Convenient methods for switching between nearest-neighbor and linear interpolation.
vtkTypeBool Border
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
double * GetResliceAxesOrigin()
Specify the origin for the ResliceAxes (i.e.
void SetSlabModeToMean()
Set the slab mode, for generating thick slices.
vtkTypeBool ComputeOutputExtent
#define VTK_RESLICE_LINEAR
virtual void SetOutputDirection(const double a[9])
Set the direction for the output data.
vtkTypeBool UsePermuteExecute
Detect and break reference loops.
vtkTypeBool ComputeOutputOrigin
Proxy object to connect input/output ports.
void SetSlabModeToSum()
Set the slab mode, for generating thick slices.
int vtkTypeBool
Definition: vtkABI.h:64
Superclass for mapping scalar values to colors.
Generic filter that has one input.
a simple class to control print indentation
Definition: vtkIndent.h:28
efficient description of an image stencil
vtkAbstractTransform * OptimizedTransform
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
superclass for all geometric transformations
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkTypeBool HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
vtkTypeBool ComputeOutputSpacing
vtkTypeBool SlabTrapezoidIntegration
void ConvertScalarsBase(vtkDataArray *input, void *outPtr, int count, int idX, int idY, int idZ, int threadId)
double GetBackgroundLevel()
Set background grey level (for single-component images).
vtkTypeBool HitInputExtent
virtual void SetOutputExtent(const int a[6])
Set the extent for the output data.
vtkImageData * InformationInput
#define VTK_SIZEHINT(...)
void SetInterpolate(vtkTypeBool t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
Reslices a volume along a new set of axes.
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
vtkTypeBool TransformInputSampling
void SetBackgroundLevel(double v)
Set background grey level (for single-component images).
vtkMatrix4x4 * ResliceAxes
void InterpolateOff()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void GetResliceAxesDirectionCosines(double xyz[9])
Specify the direction cosines for the ResliceAxes (i.e.
void SetResliceAxesDirectionCosines(const double xyz[9])
Specify the direction cosines for the ResliceAxes (i.e.
virtual void SetOutputSpacing(const double a[3])
Set the voxel spacing for the output data.
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_MARSHALAUTO
vtkTypeBool Mirror
general representation of visualization data
Definition: vtkDataObject.h:55
#define VTK_DEPRECATED_IN_9_7_0(reason)
void SetInterpolationModeToNearestNeighbor()
vtkAbstractImageInterpolator * Interpolator
virtual void SetOutputOrigin(const double a[3])
Set the origin for the output data.
vtkAbstractTransform * ResliceTransform
void SetSlabModeToMin()
Set the slab mode, for generating thick slices.
double SlabSliceSpacingFraction
void SetResliceAxesOrigin(const double xyz[3])
Specify the origin for the ResliceAxes (i.e.