VTK  9.2.6
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 =========================================================================*/
58 #ifndef vtkImageReslice_h
59 #define vtkImageReslice_h
60 
61 #include "vtkImagingCoreModule.h" // For export macro
63 
64 // interpolation mode constants
65 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
66 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
67 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
68 
69 class vtkImageData;
71 class vtkMatrix4x4;
73 class vtkScalarsToColors;
75 
76 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
77 {
78 public:
79  static vtkImageReslice* New();
81 
82  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
85 
100  virtual void SetResliceAxes(vtkMatrix4x4*);
101  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
103 
105 
111  void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
112  double y2, double z0, double z1, double z2);
113  void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
114  {
115  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
116  }
117  void SetResliceAxesDirectionCosines(const double xyz[9])
118  {
119  this->SetResliceAxesDirectionCosines(
120  xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
121  }
122  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
123  void GetResliceAxesDirectionCosines(double xyz[9])
124  {
125  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
126  }
128  {
129  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
130  return this->ResliceAxesDirectionCosines;
131  }
133 
135 
141  void SetResliceAxesOrigin(double x, double y, double z);
142  void SetResliceAxesOrigin(const double xyz[3])
143  {
144  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
145  }
146  void GetResliceAxesOrigin(double xyz[3]);
148  {
149  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
150  return this->ResliceAxesOrigin;
151  }
153 
155 
164  virtual void SetResliceTransform(vtkAbstractTransform*);
165  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
167 
169 
178  virtual void SetInformationInput(vtkImageData*);
179  vtkGetObjectMacro(InformationInput, vtkImageData);
181 
183 
190  vtkSetMacro(TransformInputSampling, vtkTypeBool);
191  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
192  vtkGetMacro(TransformInputSampling, vtkTypeBool);
194 
196 
201  vtkSetMacro(AutoCropOutput, vtkTypeBool);
202  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
203  vtkGetMacro(AutoCropOutput, vtkTypeBool);
205 
207 
210  vtkSetMacro(Wrap, vtkTypeBool);
211  vtkGetMacro(Wrap, vtkTypeBool);
212  vtkBooleanMacro(Wrap, vtkTypeBool);
214 
216 
220  vtkSetMacro(Mirror, vtkTypeBool);
221  vtkGetMacro(Mirror, vtkTypeBool);
222  vtkBooleanMacro(Mirror, vtkTypeBool);
224 
226 
236  vtkSetMacro(Border, vtkTypeBool);
237  vtkGetMacro(Border, vtkTypeBool);
238  vtkBooleanMacro(Border, vtkTypeBool);
240 
242 
246  vtkSetMacro(BorderThickness, double);
248  vtkGetMacro(BorderThickness, double);
250 
254  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
255  vtkGetMacro(InterpolationMode, int);
256  void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
257  void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
258  void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
259  virtual const char* GetInterpolationModeAsString();
261 
263 
267  virtual void SetInterpolator(vtkAbstractImageInterpolator* sampler);
268  virtual vtkAbstractImageInterpolator* GetInterpolator();
270 
272 
278  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
279  vtkGetMacro(SlabMode, int);
280  void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
281  void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
282  void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
283  void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
284  virtual const char* GetSlabModeAsString();
286 
288 
291  vtkSetMacro(SlabNumberOfSlices, int);
292  vtkGetMacro(SlabNumberOfSlices, int);
294 
296 
301  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
302  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
303  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
305 
307 
316  vtkSetMacro(SlabSliceSpacingFraction, double);
317  vtkGetMacro(SlabSliceSpacingFraction, double);
319 
321 
325  vtkSetMacro(Optimization, vtkTypeBool);
326  vtkGetMacro(Optimization, vtkTypeBool);
327  vtkBooleanMacro(Optimization, vtkTypeBool);
329 
331 
338  vtkSetMacro(ScalarShift, double);
339  vtkGetMacro(ScalarShift, double);
341 
343 
350  vtkSetMacro(ScalarScale, double);
351  vtkGetMacro(ScalarScale, double);
353 
355 
365  vtkSetMacro(OutputScalarType, int);
366  vtkGetMacro(OutputScalarType, int);
368 
370 
373  vtkSetVector4Macro(BackgroundColor, double);
374  vtkGetVector4Macro(BackgroundColor, double);
376 
378 
381  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
382  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
384 
386 
390  virtual void SetOutputSpacing(double x, double y, double z);
391  virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
392  vtkGetVector3Macro(OutputSpacing, double);
393  void SetOutputSpacingToDefault();
395 
397 
401  virtual void SetOutputOrigin(double x, double y, double z);
402  virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
403  vtkGetVector3Macro(OutputOrigin, double);
404  void SetOutputOriginToDefault();
406 
408 
412  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
413  virtual void SetOutputExtent(const int a[6])
414  {
415  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
416  }
417  vtkGetVector6Macro(OutputExtent, int);
418  void SetOutputExtentToDefault();
420 
422 
432  vtkSetMacro(OutputDimensionality, int);
433  vtkGetMacro(OutputDimensionality, int);
435 
440  vtkMTimeType GetMTime() override;
441 
445  void ReportReferences(vtkGarbageCollector*) override;
446 
448 
456  void SetInterpolate(int t)
457  {
458  if (t && !this->GetInterpolate())
459  {
460  this->SetInterpolationModeToLinear();
461  }
462  else if (!t && this->GetInterpolate())
463  {
464  this->SetInterpolationModeToNearestNeighbor();
465  }
466  }
467  void InterpolateOn() { this->SetInterpolate(1); }
468  void InterpolateOff() { this->SetInterpolate(0); }
469  int GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
471 
473 
478  void SetStencilData(vtkImageStencilData* stencil);
479  vtkImageStencilData* GetStencil();
481 
483 
487  vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
488  vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
489  vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
491 
493 
497  vtkImageStencilData* GetStencilOutput();
498  void SetStencilOutput(vtkImageStencilData* stencil);
500 
501 protected:
502  vtkImageReslice();
503  ~vtkImageReslice() override;
504 
506  double ResliceAxesDirectionCosines[9];
507  double ResliceAxesOrigin[3];
516  int SlabMode;
520  double ScalarShift;
521  double ScalarScale;
523  double BackgroundColor[4];
524  double OutputOrigin[3];
525  double OutputSpacing[3];
526  int OutputExtent[6];
537 
540 
546 
551  virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
552 
561  virtual void ConvertScalars(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
562  int count, int idX, int idY, int idZ, int threadId);
563 
564  void ConvertScalarsBase(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
565  int count, int idX, int idY, int idZ, int threadId)
566  {
567  this->ConvertScalars(
568  inPtr, outPtr, inputType, inputNumComponents, count, idX, idY, idZ, threadId);
569  }
570 
576  int RequestInformationBase(vtkInformationVector**, vtkInformationVector*);
577 
578  void GetAutoCroppedOutputBounds(vtkInformation* inInfo, double bounds[6]);
579  void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
584  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
585  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData, int ext[6],
586  int id) override;
587  int FillInputPortInformation(int port, vtkInformation* info) override;
589 
590  vtkMatrix4x4* GetIndexMatrix(vtkInformation* inInfo, vtkInformation* outInfo);
591  vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
592 
593 private:
594  vtkImageReslice(const vtkImageReslice&) = delete;
595  void operator=(const vtkImageReslice&) = delete;
596 };
597 
598 #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:470
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
#define VTK_IMAGE_SLAB_MIN
vtkAbstractTransform * GetOptimizedTransform()
#define VTK_RESLICE_CUBIC
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
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
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:69
Superclass for mapping scalar values to colors.
Generic filter that has one input.
a simple class to control print indentation
Definition: vtkIndent.h:39
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:53
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 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
int HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
general representation of visualization data
Definition: vtkDataObject.h:65
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.