VTK
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 
62 #include "vtkImagingCoreModule.h" // For export macro
64 
65 // interpolation mode constants
66 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
67 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
68 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
69 
70 class vtkImageData;
72 class vtkMatrix4x4;
74 class vtkScalarsToColors;
76 
77 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
78 {
79 public:
80  static vtkImageReslice *New();
82 
83  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
86 
101  virtual void SetResliceAxes(vtkMatrix4x4*);
102  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
104 
106 
112  void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
113  double y0, double y1, double y2,
114  double z0, double z1, double z2);
115  void SetResliceAxesDirectionCosines(const double x[3],
116  const double y[3],
117  const double z[3]) {
118  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
119  y[0], y[1], y[2],
120  z[0], z[1], z[2]); };
121  void SetResliceAxesDirectionCosines(const double xyz[9]) {
122  this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
123  xyz[3], xyz[4], xyz[5],
124  xyz[6], xyz[7], xyz[8]); };
125  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
126  void GetResliceAxesDirectionCosines(double xyz[9]) {
127  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
129  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
130  return this->ResliceAxesDirectionCosines; };
132 
134 
140  void SetResliceAxesOrigin(double x, double y, double z);
141  void SetResliceAxesOrigin(const double xyz[3]) {
142  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
143  void GetResliceAxesOrigin(double xyz[3]);
145  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
146  return this->ResliceAxesOrigin; };
148 
150 
159  virtual void SetResliceTransform(vtkAbstractTransform*);
160  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
162 
164 
173  virtual void SetInformationInput(vtkImageData*);
174  vtkGetObjectMacro(InformationInput, vtkImageData);
176 
178 
185  vtkSetMacro(TransformInputSampling, vtkTypeBool);
186  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
187  vtkGetMacro(TransformInputSampling, vtkTypeBool);
189 
191 
196  vtkSetMacro(AutoCropOutput, vtkTypeBool);
197  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
198  vtkGetMacro(AutoCropOutput, vtkTypeBool);
200 
202 
205  vtkSetMacro(Wrap, vtkTypeBool);
206  vtkGetMacro(Wrap, vtkTypeBool);
207  vtkBooleanMacro(Wrap, vtkTypeBool);
209 
211 
215  vtkSetMacro(Mirror, vtkTypeBool);
216  vtkGetMacro(Mirror, vtkTypeBool);
217  vtkBooleanMacro(Mirror, vtkTypeBool);
219 
221 
231  vtkSetMacro(Border, vtkTypeBool);
232  vtkGetMacro(Border, vtkTypeBool);
233  vtkBooleanMacro(Border, vtkTypeBool);
235 
237 
242  vtkSetMacro(BorderThickness, double);
243  vtkGetMacro(BorderThickness, double);
245 
249  vtkSetClampMacro(InterpolationMode, int,
251  vtkGetMacro(InterpolationMode, int);
253  this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
255  this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
257  this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
258  virtual const char *GetInterpolationModeAsString();
260 
262 
266  virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
267  virtual vtkAbstractImageInterpolator *GetInterpolator();
269 
271 
277  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
278  vtkGetMacro(SlabMode, int);
280  this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
282  this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
284  this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
286  this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
287  virtual const char *GetSlabModeAsString();
289 
291 
294  vtkSetMacro(SlabNumberOfSlices, int);
295  vtkGetMacro(SlabNumberOfSlices, int);
297 
299 
304  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
305  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
306  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
308 
310 
319  vtkSetMacro(SlabSliceSpacingFraction, double);
320  vtkGetMacro(SlabSliceSpacingFraction, double);
322 
324 
328  vtkSetMacro(Optimization, vtkTypeBool);
329  vtkGetMacro(Optimization, vtkTypeBool);
330  vtkBooleanMacro(Optimization, vtkTypeBool);
332 
334 
341  vtkSetMacro(ScalarShift, double);
342  vtkGetMacro(ScalarShift, double);
344 
346 
353  vtkSetMacro(ScalarScale, double);
354  vtkGetMacro(ScalarScale, double)
356 
358 
368  vtkSetMacro(OutputScalarType, int);
369  vtkGetMacro(OutputScalarType, int);
371 
373 
376  vtkSetVector4Macro(BackgroundColor, double);
377  vtkGetVector4Macro(BackgroundColor, double);
379 
381 
384  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
385  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
387 
389 
393  virtual void SetOutputSpacing(double x, double y, double z);
394  virtual void SetOutputSpacing(const double a[3]) {
395  this->SetOutputSpacing(a[0], a[1], a[2]); };
396  vtkGetVector3Macro(OutputSpacing, double);
397  void SetOutputSpacingToDefault();
399 
401 
405  virtual void SetOutputOrigin(double x, double y, double z);
406  virtual void SetOutputOrigin(const double a[3]) {
407  this->SetOutputOrigin(a[0], a[1], a[2]); };
408  vtkGetVector3Macro(OutputOrigin, double);
409  void SetOutputOriginToDefault();
411 
413 
417  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
418  virtual void SetOutputExtent(const int a[6]) {
419  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
420  vtkGetVector6Macro(OutputExtent, int);
421  void SetOutputExtentToDefault();
423 
425 
435  vtkSetMacro(OutputDimensionality, int);
436  vtkGetMacro(OutputDimensionality, int);
438 
443  vtkMTimeType GetMTime() override;
444 
448  void ReportReferences(vtkGarbageCollector*) override;
449 
451 
459  void SetInterpolate(int t) {
460  if (t && !this->GetInterpolate()) {
461  this->SetInterpolationModeToLinear(); }
462  else if (!t && this->GetInterpolate()) {
463  this->SetInterpolationModeToNearestNeighbor(); } };
464  void InterpolateOn() {
465  this->SetInterpolate(1); };
466  void InterpolateOff() {
467  this->SetInterpolate(0); };
469  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  return this->GetOutputPort(1); }
498  vtkImageStencilData *GetStencilOutput();
499  void SetStencilOutput(vtkImageStencilData *stencil);
501 
502 protected:
503  vtkImageReslice();
504  ~vtkImageReslice() override;
505 
507  double ResliceAxesDirectionCosines[9];
508  double ResliceAxesOrigin[3];
517  int SlabMode;
521  double ScalarShift;
522  double ScalarScale;
524  double BackgroundColor[4];
525  double OutputOrigin[3];
526  double OutputSpacing[3];
527  int OutputExtent[6];
538 
541 
547 
552  virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
553 
562  virtual void ConvertScalars(void *inPtr, void *outPtr,
563  int inputType, int inputNumComponents,
564  int count, int idX, int idY, int idZ,
565  int threadId);
566 
567  void ConvertScalarsBase(void *inPtr, void *outPtr,
568  int inputType, int inputNumComponents,
569  int count, int idX, int idY, int idZ, int threadId) {
570  this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
571  count, idX, idY, idZ, threadId); }
572 
573  void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
574  void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) override;
577  vtkInformationVector *) override;
579  vtkInformationVector *) override;
581  vtkInformationVector *) override;
582  void ThreadedRequestData(vtkInformation *request,
583  vtkInformationVector **inputVector,
584  vtkInformationVector *outputVector,
585  vtkImageData ***inData,
586  vtkImageData **outData, int ext[6], int id) override;
587  int FillInputPortInformation(int port, vtkInformation *info) override;
589 
590  vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
591  vtkInformation *outInfo);
593  return this->OptimizedTransform; };
594 
595 private:
596  vtkImageReslice(const vtkImageReslice&) = delete;
597  void operator=(const vtkImageReslice&) = delete;
598 };
599 
600 #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:513
vtkImageReslice::InformationInput
vtkImageData * InformationInput
Definition: vtkImageReslice.h:511
vtkImageReslice::GetStencilOutputPort
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
Definition: vtkImageReslice.h:496
vtkImageReslice::ResliceAxes
vtkMatrix4x4 * ResliceAxes
Definition: vtkImageReslice.h:506
vtkImageReslice::SetSlabModeToMax
void SetSlabModeToMax()
Definition: vtkImageReslice.h:281
vtkImageReslice::IndexMatrix
vtkMatrix4x4 * IndexMatrix
Definition: vtkImageReslice.h:539
vtkImageReslice::SetInterpolationModeToLinear
void SetInterpolationModeToLinear()
Definition: vtkImageReslice.h:254
vtkImageReslice::Wrap
vtkTypeBool Wrap
Definition: vtkImageReslice.h:512
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:50
vtkImageReslice::InterpolateOff
void InterpolateOff()
Definition: vtkImageReslice.h:466
vtkImageReslice::SetResliceAxesOrigin
void SetResliceAxesOrigin(const double xyz[3])
Definition: vtkImageReslice.h:141
VTK_IMAGE_SLAB_MAX
#define VTK_IMAGE_SLAB_MAX
Definition: vtkSystemIncludes.h:113
vtkImageReslice::SlabMode
int SlabMode
Definition: vtkImageReslice.h:517
vtkImageReslice::ComputeOutputSpacing
int ComputeOutputSpacing
Definition: vtkImageReslice.h:534
vtkAlgorithm::GetOutputPort
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:460
vtkImageReslice::SetInterpolate
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
Definition: vtkImageReslice.h:459
vtkImageReslice::OutputScalarType
int OutputScalarType
Definition: vtkImageReslice.h:528
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkImageReslice::InterpolationMode
int InterpolationMode
Definition: vtkImageReslice.h:515
vtkImageReslice::SetResliceAxesDirectionCosines
void SetResliceAxesDirectionCosines(const double xyz[9])
Definition: vtkImageReslice.h:121
vtkImageReslice::GetResliceAxesDirectionCosines
double * GetResliceAxesDirectionCosines()
Definition: vtkImageReslice.h:128
vtkImageReslice::ComputeOutputExtent
int ComputeOutputExtent
Definition: vtkImageReslice.h:536
vtkImageReslice::SlabTrapezoidIntegration
vtkTypeBool SlabTrapezoidIntegration
Definition: vtkImageReslice.h:519
vtkThreadedImageAlgorithm
Generic filter that has one input.
Definition: vtkThreadedImageAlgorithm.h:43
vtkImageReslice::UsePermuteExecute
int UsePermuteExecute
Definition: vtkImageReslice.h:533
vtkImageReslice::SetResliceAxesDirectionCosines
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Definition: vtkImageReslice.h:115
vtkImageReslice::InterpolateOn
void InterpolateOn()
Definition: vtkImageReslice.h:464
vtkImageReslice::OutputDimensionality
int OutputDimensionality
Definition: vtkImageReslice.h:529
vtkThreadedImageAlgorithm.h
VTK_IMAGE_SLAB_MEAN
#define VTK_IMAGE_SLAB_MEAN
Definition: vtkSystemIncludes.h:114
vtkX3D::port
Definition: vtkX3D.h:447
vtkImageReslice::SetInterpolationModeToCubic
void SetInterpolationModeToCubic()
Definition: vtkImageReslice.h:256
vtkImageReslice::SetOutputExtent
virtual void SetOutputExtent(const int a[6])
Definition: vtkImageReslice.h:418
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:42
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:68
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
VTK_IMAGE_SLAB_MIN
#define VTK_IMAGE_SLAB_MIN
Definition: vtkSystemIncludes.h:112
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:537
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:126
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkImageReslice::Interpolator
vtkAbstractImageInterpolator * Interpolator
Definition: vtkImageReslice.h:510
vtkImageReslice::SlabSliceSpacingFraction
double SlabSliceSpacingFraction
Definition: vtkImageReslice.h:520
vtkImageReslice::Optimization
vtkTypeBool Optimization
Definition: vtkImageReslice.h:516
vtkImageReslice
Reslices a volume along a new set of axes.
Definition: vtkImageReslice.h:77
vtkImageReslice::GetBackgroundLevel
double GetBackgroundLevel()
Definition: vtkImageReslice.h:385
vtkImageReslice::AutoCropOutput
vtkTypeBool AutoCropOutput
Definition: vtkImageReslice.h:531
vtkImageReslice::BorderThickness
double BorderThickness
Definition: vtkImageReslice.h:523
VTK_RESLICE_NEAREST
#define VTK_RESLICE_NEAREST
Definition: vtkImageReslice.h:66
vtkImageReslice::SetOutputSpacing
virtual void SetOutputSpacing(const double a[3])
Definition: vtkImageReslice.h:394
vtkImageReslice::GetInterpolate
int GetInterpolate()
Definition: vtkImageReslice.h:468
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:66
vtkImageReslice::OptimizedTransform
vtkAbstractTransform * OptimizedTransform
Definition: vtkImageReslice.h:540
vtkImageReslice::ScalarScale
double ScalarScale
Definition: vtkImageReslice.h:522
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:99
vtkImageReslice::SetInterpolationModeToNearestNeighbor
void SetInterpolationModeToNearestNeighbor()
Definition: vtkImageReslice.h:252
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkImageReslice::SetSlabModeToSum
void SetSlabModeToSum()
Definition: vtkImageReslice.h:285
vtkX3D::info
Definition: vtkX3D.h:376
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:546
vtkImageReslice::ComputeOutputOrigin
int ComputeOutputOrigin
Definition: vtkImageReslice.h:535
vtkAlgorithm::ReportReferences
void ReportReferences(vtkGarbageCollector *) override
vtkImageReslice::ScalarShift
double ScalarShift
Definition: vtkImageReslice.h:521
vtkImageReslice::SetSlabModeToMean
void SetSlabModeToMean()
Definition: vtkImageReslice.h:283
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:115
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:567
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:39
vtkImageReslice::SlabNumberOfSlices
int SlabNumberOfSlices
Definition: vtkImageReslice.h:518
VTK_RESLICE_LINEAR
#define VTK_RESLICE_LINEAR
Definition: vtkImageReslice.h:67
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:37
vtkImageReslice::SetBackgroundLevel
void SetBackgroundLevel(double v)
Set background grey level (for single-component images).
Definition: vtkImageReslice.h:384
vtkImageReslice::SetOutputOrigin
virtual void SetOutputOrigin(const double a[3])
Definition: vtkImageReslice.h:406
vtkImageReslice::HitInputExtent
int HitInputExtent
Definition: vtkImageReslice.h:532
vtkImageReslice::Border
vtkTypeBool Border
Definition: vtkImageReslice.h:514
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:49
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:64
vtkThreadedImageAlgorithm::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkImageReslice::GetResliceAxesOrigin
double * GetResliceAxesOrigin()
Definition: vtkImageReslice.h:144
vtkImageReslice::SetSlabModeToMin
void SetSlabModeToMin()
Definition: vtkImageReslice.h:279
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageReslice::ResliceTransform
vtkAbstractTransform * ResliceTransform
Definition: vtkImageReslice.h:509
vtkImageReslice::GetOptimizedTransform
vtkAbstractTransform * GetOptimizedTransform()
Definition: vtkImageReslice.h:592
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkImageReslice::TransformInputSampling
vtkTypeBool TransformInputSampling
Definition: vtkImageReslice.h:530