VTK  9.3.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 "vtkImagingCoreModule.h" // For export macro
49 
50 // interpolation mode constants
51 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
52 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
53 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
54 
55 VTK_ABI_NAMESPACE_BEGIN
56 class vtkImageData;
58 class vtkMatrix4x4;
60 class vtkScalarsToColors;
62 
63 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
64 {
65 public:
66  static vtkImageReslice* New();
68 
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
72 
87  virtual void SetResliceAxes(vtkMatrix4x4*);
88  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
90 
92 
98  void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
99  double y2, double z0, double z1, double z2);
100  void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
101  {
102  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
103  }
104  void SetResliceAxesDirectionCosines(const double xyz[9])
105  {
106  this->SetResliceAxesDirectionCosines(
107  xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
108  }
109  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
110  void GetResliceAxesDirectionCosines(double xyz[9])
111  {
112  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
113  }
115  {
116  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
117  return this->ResliceAxesDirectionCosines;
118  }
120 
122 
128  void SetResliceAxesOrigin(double x, double y, double z);
129  void SetResliceAxesOrigin(const double xyz[3])
130  {
131  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
132  }
133  void GetResliceAxesOrigin(double xyz[3]);
135  {
136  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
137  return this->ResliceAxesOrigin;
138  }
140 
142 
151  virtual void SetResliceTransform(vtkAbstractTransform*);
152  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
154 
156 
165  virtual void SetInformationInput(vtkImageData*);
166  vtkGetObjectMacro(InformationInput, vtkImageData);
168 
170 
177  vtkSetMacro(TransformInputSampling, vtkTypeBool);
178  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
179  vtkGetMacro(TransformInputSampling, vtkTypeBool);
181 
183 
188  vtkSetMacro(AutoCropOutput, vtkTypeBool);
189  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
190  vtkGetMacro(AutoCropOutput, vtkTypeBool);
192 
194 
197  vtkSetMacro(Wrap, vtkTypeBool);
198  vtkGetMacro(Wrap, vtkTypeBool);
199  vtkBooleanMacro(Wrap, vtkTypeBool);
201 
203 
207  vtkSetMacro(Mirror, vtkTypeBool);
208  vtkGetMacro(Mirror, vtkTypeBool);
209  vtkBooleanMacro(Mirror, vtkTypeBool);
211 
213 
223  vtkSetMacro(Border, vtkTypeBool);
224  vtkGetMacro(Border, vtkTypeBool);
225  vtkBooleanMacro(Border, vtkTypeBool);
227 
229 
233  vtkSetMacro(BorderThickness, double);
235  vtkGetMacro(BorderThickness, double);
237 
241  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
242  vtkGetMacro(InterpolationMode, int);
243  void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
244  void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
245  void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
246  virtual const char* GetInterpolationModeAsString();
248 
250 
254  virtual void SetInterpolator(vtkAbstractImageInterpolator* sampler);
255  virtual vtkAbstractImageInterpolator* GetInterpolator();
257 
259 
265  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
266  vtkGetMacro(SlabMode, int);
267  void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
268  void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
269  void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
270  void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
271  virtual const char* GetSlabModeAsString();
273 
275 
278  vtkSetMacro(SlabNumberOfSlices, int);
279  vtkGetMacro(SlabNumberOfSlices, int);
281 
283 
288  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
289  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
290  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
292 
294 
303  vtkSetMacro(SlabSliceSpacingFraction, double);
304  vtkGetMacro(SlabSliceSpacingFraction, double);
306 
308 
312  vtkSetMacro(Optimization, vtkTypeBool);
313  vtkGetMacro(Optimization, vtkTypeBool);
314  vtkBooleanMacro(Optimization, vtkTypeBool);
316 
318 
325  vtkSetMacro(ScalarShift, double);
326  vtkGetMacro(ScalarShift, double);
328 
330 
337  vtkSetMacro(ScalarScale, double);
338  vtkGetMacro(ScalarScale, double);
340 
342 
352  vtkSetMacro(OutputScalarType, int);
353  vtkGetMacro(OutputScalarType, int);
355 
357 
360  vtkSetVector4Macro(BackgroundColor, double);
361  vtkGetVector4Macro(BackgroundColor, double);
363 
365 
368  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
369  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
371 
373 
377  virtual void SetOutputSpacing(double x, double y, double z);
378  virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
379  vtkGetVector3Macro(OutputSpacing, double);
380  void SetOutputSpacingToDefault();
382 
384 
393  virtual void SetOutputDirection(double xx, double xy, double xz, double yx, double yy, double yz,
394  double zx, double zy, double zz);
395  virtual void SetOutputDirection(const double a[9])
396  {
397  this->SetOutputDirection(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
398  }
399  vtkGetVector3Macro(OutputDirection, double);
400  void SetOutputDirectionToDefault();
402 
404 
408  virtual void SetOutputOrigin(double x, double y, double z);
409  virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
410  vtkGetVector3Macro(OutputOrigin, double);
411  void SetOutputOriginToDefault();
413 
415 
419  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
420  virtual void SetOutputExtent(const int a[6])
421  {
422  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
423  }
424  vtkGetVector6Macro(OutputExtent, int);
425  void SetOutputExtentToDefault();
427 
429 
439  vtkSetMacro(OutputDimensionality, int);
440  vtkGetMacro(OutputDimensionality, int);
442 
447  vtkMTimeType GetMTime() override;
448 
452  void ReportReferences(vtkGarbageCollector*) override;
453 
455 
463  void SetInterpolate(int t)
464  {
465  if (t && !this->GetInterpolate())
466  {
467  this->SetInterpolationModeToLinear();
468  }
469  else if (!t && this->GetInterpolate())
470  {
471  this->SetInterpolationModeToNearestNeighbor();
472  }
473  }
474  void InterpolateOn() { this->SetInterpolate(1); }
475  void InterpolateOff() { this->SetInterpolate(0); }
476  int GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
478 
480 
485  void SetStencilData(vtkImageStencilData* stencil);
486  vtkImageStencilData* GetStencil();
488 
490 
494  vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
495  vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
496  vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
498 
500 
504  vtkImageStencilData* GetStencilOutput();
505  void SetStencilOutput(vtkImageStencilData* stencil);
507 
508 protected:
509  vtkImageReslice();
510  ~vtkImageReslice() override;
511 
513  double ResliceAxesDirectionCosines[9];
514  double ResliceAxesOrigin[3];
523  int SlabMode;
527  double ScalarShift;
528  double ScalarScale;
530  double BackgroundColor[4];
531  double OutputDirection[9];
532  double OutputOrigin[3];
533  double OutputSpacing[3];
534  int OutputExtent[6];
546 
549 
555 
560  virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
561 
570  virtual void ConvertScalars(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
571  int count, int idX, int idY, int idZ, int threadId);
572 
573  void ConvertScalarsBase(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
574  int count, int idX, int idY, int idZ, int threadId)
575  {
576  this->ConvertScalars(
577  inPtr, outPtr, inputType, inputNumComponents, count, idX, idY, idZ, threadId);
578  }
579 
585  int RequestInformationBase(vtkInformationVector**, vtkInformationVector*);
586 
587  void GetAutoCroppedOutputBounds(
588  vtkInformation* inInfo, const double outDirection[9], double bounds[6]);
589  void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
594  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
595  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData, int ext[6],
596  int id) override;
597  int FillInputPortInformation(int port, vtkInformation* info) override;
599 
600  vtkMatrix4x4* GetIndexMatrix(vtkInformation* inInfo, vtkInformation* outInfo);
601  vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
602 
603 private:
604  vtkImageReslice(const vtkImageReslice&) = delete;
605  void operator=(const vtkImageReslice&) = delete;
606 };
607 
608 VTK_ABI_NAMESPACE_END
609 #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:500
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
#define VTK_IMAGE_SLAB_MIN
vtkAbstractTransform * GetOptimizedTransform()
#define VTK_RESLICE_CUBIC
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
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.
#define VTK_RESLICE_LINEAR
virtual void SetOutputDirection(const double a[9])
Set the direction for the output data.
Detect and break reference loops.
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
Proxy object to connect input/output ports.
void SetSlabModeToSum()
Set the slab mode, for generating thick slices.
virtual void AllocateOutputData(vtkImageData *out, vtkInformation *outInfo, int *uExtent)
Allocate the output data.
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
void ConvertScalarsBase(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
vtkAbstractTransform * OptimizedTransform
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
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 SlabTrapezoidIntegration
virtual void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, int extent[6], int threadId)
If the subclass does not define an Execute method, then the task will be broken up, multiple threads will be spawned, and each thread will call this method.
double GetBackgroundLevel()
Set background grey level (for single-component images).
virtual void SetOutputExtent(const int a[6])
Set the extent for the output data.
vtkImageData * InformationInput
#define VTK_SIZEHINT(...)
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).
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
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.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
int FillOutputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
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.
int GetInterpolate()
Convenient methods for switching between nearest-neighbor and linear interpolation.
vtkTypeBool Mirror
general representation of visualization data
Definition: vtkDataObject.h:54
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.