VTK  9.0.1
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 =========================================================================*/
52 #ifndef vtkImageReslice_h
53 #define vtkImageReslice_h
54 
55 #include "vtkImagingCoreModule.h" // For export macro
57 
58 // interpolation mode constants
59 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
60 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
61 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
62 
63 class vtkImageData;
65 class vtkMatrix4x4;
67 class vtkScalarsToColors;
69 
70 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
71 {
72 public:
73  static vtkImageReslice* New();
75 
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
79 
94  virtual void SetResliceAxes(vtkMatrix4x4*);
95  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
97 
99 
105  void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
106  double y2, double z0, double z1, double z2);
107  void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
108  {
109  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
110  }
111  void SetResliceAxesDirectionCosines(const double xyz[9])
112  {
113  this->SetResliceAxesDirectionCosines(
114  xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
115  }
116  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
117  void GetResliceAxesDirectionCosines(double xyz[9])
118  {
119  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
120  }
122  {
123  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
124  return this->ResliceAxesDirectionCosines;
125  }
127 
129 
135  void SetResliceAxesOrigin(double x, double y, double z);
136  void SetResliceAxesOrigin(const double xyz[3])
137  {
138  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
139  }
140  void GetResliceAxesOrigin(double xyz[3]);
142  {
143  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
144  return this->ResliceAxesOrigin;
145  }
147 
149 
158  virtual void SetResliceTransform(vtkAbstractTransform*);
159  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
161 
163 
172  virtual void SetInformationInput(vtkImageData*);
173  vtkGetObjectMacro(InformationInput, vtkImageData);
175 
177 
184  vtkSetMacro(TransformInputSampling, vtkTypeBool);
185  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
186  vtkGetMacro(TransformInputSampling, vtkTypeBool);
188 
190 
195  vtkSetMacro(AutoCropOutput, vtkTypeBool);
196  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
197  vtkGetMacro(AutoCropOutput, vtkTypeBool);
199 
201 
204  vtkSetMacro(Wrap, vtkTypeBool);
205  vtkGetMacro(Wrap, vtkTypeBool);
206  vtkBooleanMacro(Wrap, vtkTypeBool);
208 
210 
214  vtkSetMacro(Mirror, vtkTypeBool);
215  vtkGetMacro(Mirror, vtkTypeBool);
216  vtkBooleanMacro(Mirror, vtkTypeBool);
218 
220 
230  vtkSetMacro(Border, vtkTypeBool);
231  vtkGetMacro(Border, vtkTypeBool);
232  vtkBooleanMacro(Border, vtkTypeBool);
234 
236 
241  vtkSetMacro(BorderThickness, double);
242  vtkGetMacro(BorderThickness, double);
244 
248  vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
249  vtkGetMacro(InterpolationMode, int);
250  void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
251  void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
252  void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
253  virtual const char* GetInterpolationModeAsString();
255 
257 
261  virtual void SetInterpolator(vtkAbstractImageInterpolator* sampler);
262  virtual vtkAbstractImageInterpolator* GetInterpolator();
264 
266 
272  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
273  vtkGetMacro(SlabMode, int);
274  void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
275  void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
276  void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
277  void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
278  virtual const char* GetSlabModeAsString();
280 
282 
285  vtkSetMacro(SlabNumberOfSlices, int);
286  vtkGetMacro(SlabNumberOfSlices, int);
288 
290 
295  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
296  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
297  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
299 
301 
310  vtkSetMacro(SlabSliceSpacingFraction, double);
311  vtkGetMacro(SlabSliceSpacingFraction, double);
313 
315 
319  vtkSetMacro(Optimization, vtkTypeBool);
320  vtkGetMacro(Optimization, vtkTypeBool);
321  vtkBooleanMacro(Optimization, vtkTypeBool);
323 
325 
332  vtkSetMacro(ScalarShift, double);
333  vtkGetMacro(ScalarShift, double);
335 
337 
344  vtkSetMacro(ScalarScale, double);
345  vtkGetMacro(ScalarScale, double);
347 
349 
359  vtkSetMacro(OutputScalarType, int);
360  vtkGetMacro(OutputScalarType, int);
362 
364 
367  vtkSetVector4Macro(BackgroundColor, double);
368  vtkGetVector4Macro(BackgroundColor, double);
370 
372 
375  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
376  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
378 
380 
384  virtual void SetOutputSpacing(double x, double y, double z);
385  virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
386  vtkGetVector3Macro(OutputSpacing, double);
387  void SetOutputSpacingToDefault();
389 
391 
395  virtual void SetOutputOrigin(double x, double y, double z);
396  virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
397  vtkGetVector3Macro(OutputOrigin, double);
398  void SetOutputOriginToDefault();
400 
402 
406  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
407  virtual void SetOutputExtent(const int a[6])
408  {
409  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
410  }
411  vtkGetVector6Macro(OutputExtent, int);
412  void SetOutputExtentToDefault();
414 
416 
426  vtkSetMacro(OutputDimensionality, int);
427  vtkGetMacro(OutputDimensionality, int);
429 
434  vtkMTimeType GetMTime() override;
435 
439  void ReportReferences(vtkGarbageCollector*) override;
440 
442 
450  void SetInterpolate(int t)
451  {
452  if (t && !this->GetInterpolate())
453  {
454  this->SetInterpolationModeToLinear();
455  }
456  else if (!t && this->GetInterpolate())
457  {
458  this->SetInterpolationModeToNearestNeighbor();
459  }
460  }
461  void InterpolateOn() { this->SetInterpolate(1); }
462  void InterpolateOff() { this->SetInterpolate(0); }
463  int GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
465 
467 
472  void SetStencilData(vtkImageStencilData* stencil);
473  vtkImageStencilData* GetStencil();
475 
477 
481  vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
482  vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
483  vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
485 
487 
491  vtkImageStencilData* GetStencilOutput();
492  void SetStencilOutput(vtkImageStencilData* stencil);
494 
495 protected:
496  vtkImageReslice();
497  ~vtkImageReslice() override;
498 
500  double ResliceAxesDirectionCosines[9];
501  double ResliceAxesOrigin[3];
510  int SlabMode;
514  double ScalarShift;
515  double ScalarScale;
517  double BackgroundColor[4];
518  double OutputOrigin[3];
519  double OutputSpacing[3];
520  int OutputExtent[6];
531 
534 
540 
545  virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
546 
555  virtual void ConvertScalars(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
556  int count, int idX, int idY, int idZ, int threadId);
557 
558  void ConvertScalarsBase(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
559  int count, int idX, int idY, int idZ, int threadId)
560  {
561  this->ConvertScalars(
562  inPtr, outPtr, inputType, inputNumComponents, count, idX, idY, idZ, threadId);
563  }
564 
565  void GetAutoCroppedOutputBounds(vtkInformation* inInfo, double bounds[6]);
566  void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
571  void ThreadedRequestData(vtkInformation* request, vtkInformationVector** inputVector,
572  vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData, int ext[6],
573  int id) override;
574  int FillInputPortInformation(int port, vtkInformation* info) override;
576 
577  vtkMatrix4x4* GetIndexMatrix(vtkInformation* inInfo, vtkInformation* outInfo);
578  vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
579 
580 private:
581  vtkImageReslice(const vtkImageReslice&) = delete;
582  void operator=(const vtkImageReslice&) = delete;
583 };
584 
585 #endif
vtkThreadedImageAlgorithm::ThreadedRequestData
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,...
vtkImageReslice::Mirror
vtkTypeBool Mirror
Definition: vtkImageReslice.h:506
vtkImageReslice::InformationInput
vtkImageData * InformationInput
Definition: vtkImageReslice.h:504
vtkImageReslice::GetStencilOutputPort
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
Definition: vtkImageReslice.h:490
vtkImageReslice::ResliceAxes
vtkMatrix4x4 * ResliceAxes
Definition: vtkImageReslice.h:499
vtkImageReslice::SetSlabModeToMax
void SetSlabModeToMax()
Definition: vtkImageReslice.h:275
vtkImageReslice::IndexMatrix
vtkMatrix4x4 * IndexMatrix
Definition: vtkImageReslice.h:532
vtkImageReslice::SetInterpolationModeToLinear
void SetInterpolationModeToLinear()
Definition: vtkImageReslice.h:251
vtkImageReslice::Wrap
vtkTypeBool Wrap
Definition: vtkImageReslice.h:505
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:50
vtkImageReslice::InterpolateOff
void InterpolateOff()
Definition: vtkImageReslice.h:462
vtkImageReslice::SetResliceAxesOrigin
void SetResliceAxesOrigin(const double xyz[3])
Definition: vtkImageReslice.h:136
VTK_IMAGE_SLAB_MAX
#define VTK_IMAGE_SLAB_MAX
Definition: vtkSystemIncludes.h:100
vtkImageReslice::SlabMode
int SlabMode
Definition: vtkImageReslice.h:510
vtkImageReslice::ComputeOutputSpacing
int ComputeOutputSpacing
Definition: vtkImageReslice.h:527
vtkAlgorithm::GetOutputPort
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:477
vtkImageReslice::SetInterpolate
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
Definition: vtkImageReslice.h:450
vtkImageReslice::OutputScalarType
int OutputScalarType
Definition: vtkImageReslice.h:521
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkImageReslice::InterpolationMode
int InterpolationMode
Definition: vtkImageReslice.h:508
vtkImageReslice::SetResliceAxesDirectionCosines
void SetResliceAxesDirectionCosines(const double xyz[9])
Definition: vtkImageReslice.h:111
vtkImageReslice::GetResliceAxesDirectionCosines
double * GetResliceAxesDirectionCosines()
Definition: vtkImageReslice.h:121
vtkImageReslice::ComputeOutputExtent
int ComputeOutputExtent
Definition: vtkImageReslice.h:529
vtkImageReslice::SlabTrapezoidIntegration
vtkTypeBool SlabTrapezoidIntegration
Definition: vtkImageReslice.h:512
vtkThreadedImageAlgorithm
Generic filter that has one input.
Definition: vtkThreadedImageAlgorithm.h:37
vtkImageReslice::UsePermuteExecute
int UsePermuteExecute
Definition: vtkImageReslice.h:526
vtkImageReslice::SetResliceAxesDirectionCosines
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Definition: vtkImageReslice.h:107
vtkImageReslice::InterpolateOn
void InterpolateOn()
Definition: vtkImageReslice.h:461
vtkImageReslice::OutputDimensionality
int OutputDimensionality
Definition: vtkImageReslice.h:522
vtkThreadedImageAlgorithm.h
VTK_IMAGE_SLAB_MEAN
#define VTK_IMAGE_SLAB_MEAN
Definition: vtkSystemIncludes.h:101
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkImageReslice::SetInterpolationModeToCubic
void SetInterpolationModeToCubic()
Definition: vtkImageReslice.h:252
vtkImageReslice::SetOutputExtent
virtual void SetOutputExtent(const int a[6])
Definition: vtkImageReslice.h:407
vtkImageAlgorithm::RequestUpdateExtent
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Subclasses can reimplement this method to translate the update extent requests from each output port ...
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkImageAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
VTK_RESLICE_CUBIC
#define VTK_RESLICE_CUBIC
Definition: vtkImageReslice.h:61
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
VTK_IMAGE_SLAB_MIN
#define VTK_IMAGE_SLAB_MIN
Definition: vtkSystemIncludes.h:99
vtkThreadedImageAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImageReslice::GenerateStencilOutput
vtkTypeBool GenerateStencilOutput
Definition: vtkImageReslice.h:530
vtkImageAlgorithm::AllocateOutputData
virtual void AllocateOutputData(vtkImageData *out, vtkInformation *outInfo, int *uExtent)
Allocate the output data.
vtkImageReslice::GetResliceAxesDirectionCosines
void GetResliceAxesDirectionCosines(double xyz[9])
Definition: vtkImageReslice.h:117
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkImageReslice::Interpolator
vtkAbstractImageInterpolator * Interpolator
Definition: vtkImageReslice.h:503
vtkImageReslice::SlabSliceSpacingFraction
double SlabSliceSpacingFraction
Definition: vtkImageReslice.h:513
vtkImageReslice::Optimization
vtkTypeBool Optimization
Definition: vtkImageReslice.h:509
vtkImageReslice
Reslices a volume along a new set of axes.
Definition: vtkImageReslice.h:70
vtkImageReslice::GetBackgroundLevel
double GetBackgroundLevel()
Definition: vtkImageReslice.h:376
vtkImageReslice::AutoCropOutput
vtkTypeBool AutoCropOutput
Definition: vtkImageReslice.h:524
vtkImageReslice::BorderThickness
double BorderThickness
Definition: vtkImageReslice.h:516
VTK_RESLICE_NEAREST
#define VTK_RESLICE_NEAREST
Definition: vtkImageReslice.h:59
vtkImageReslice::SetOutputSpacing
virtual void SetOutputSpacing(const double a[3])
Definition: vtkImageReslice.h:385
vtkImageReslice::GetInterpolate
int GetInterpolate()
Definition: vtkImageReslice.h:463
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:59
vtkImageReslice::OptimizedTransform
vtkAbstractTransform * OptimizedTransform
Definition: vtkImageReslice.h:533
vtkImageReslice::ScalarScale
double ScalarScale
Definition: vtkImageReslice.h:515
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:94
vtkImageReslice::SetInterpolationModeToNearestNeighbor
void SetInterpolationModeToNearestNeighbor()
Definition: vtkImageReslice.h:250
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkImageReslice::SetSlabModeToSum
void SetSlabModeToSum()
Definition: vtkImageReslice.h:277
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkImageReslice::HasConvertScalars
int HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
Definition: vtkImageReslice.h:539
vtkImageReslice::ComputeOutputOrigin
int ComputeOutputOrigin
Definition: vtkImageReslice.h:528
vtkAlgorithm::ReportReferences
void ReportReferences(vtkGarbageCollector *) override
vtkImageReslice::ScalarShift
double ScalarShift
Definition: vtkImageReslice.h:514
vtkImageReslice::SetSlabModeToMean
void SetSlabModeToMean()
Definition: vtkImageReslice.h:276
vtkImageAlgorithm::FillOutputPortInformation
int FillOutputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
VTK_IMAGE_SLAB_SUM
#define VTK_IMAGE_SLAB_SUM
Definition: vtkSystemIncludes.h:102
vtkImageReslice::ConvertScalarsBase
void ConvertScalarsBase(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
Definition: vtkImageReslice.h:558
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkImageReslice::SlabNumberOfSlices
int SlabNumberOfSlices
Definition: vtkImageReslice.h:511
VTK_RESLICE_LINEAR
#define VTK_RESLICE_LINEAR
Definition: vtkImageReslice.h:60
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:33
vtkImageReslice::SetBackgroundLevel
void SetBackgroundLevel(double v)
Set background grey level (for single-component images).
Definition: vtkImageReslice.h:375
vtkImageReslice::SetOutputOrigin
virtual void SetOutputOrigin(const double a[3])
Definition: vtkImageReslice.h:396
vtkImageReslice::HitInputExtent
int HitInputExtent
Definition: vtkImageReslice.h:525
vtkImageReslice::Border
vtkTypeBool Border
Definition: vtkImageReslice.h:507
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:46
vtkImageAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkThreadedImageAlgorithm::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkImageReslice::GetResliceAxesOrigin
double * GetResliceAxesOrigin()
Definition: vtkImageReslice.h:141
vtkImageReslice::SetSlabModeToMin
void SetSlabModeToMin()
Definition: vtkImageReslice.h:274
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageReslice::ResliceTransform
vtkAbstractTransform * ResliceTransform
Definition: vtkImageReslice.h:502
vtkImageReslice::GetOptimizedTransform
vtkAbstractTransform * GetOptimizedTransform()
Definition: vtkImageReslice.h:578
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
vtkImageReslice::TransformInputSampling
vtkTypeBool TransformInputSampling
Definition: vtkImageReslice.h:523