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 =========================================================================*/
52 #ifndef vtkImageReslice_h
53 #define vtkImageReslice_h
54 
55 
56 #include "vtkImagingCoreModule.h" // For export macro
58 
59 // interpolation mode constants
60 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
61 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
62 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
63 
64 class vtkImageData;
66 class vtkMatrix4x4;
68 class vtkScalarsToColors;
70 
71 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
72 {
73 public:
74  static vtkImageReslice *New();
76 
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
80 
95  virtual void SetResliceAxes(vtkMatrix4x4*);
96  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
98 
100 
106  void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
107  double y0, double y1, double y2,
108  double z0, double z1, double z2);
109  void SetResliceAxesDirectionCosines(const double x[3],
110  const double y[3],
111  const double z[3]) {
112  this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
113  y[0], y[1], y[2],
114  z[0], z[1], z[2]); };
115  void SetResliceAxesDirectionCosines(const double xyz[9]) {
116  this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
117  xyz[3], xyz[4], xyz[5],
118  xyz[6], xyz[7], xyz[8]); };
119  void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
120  void GetResliceAxesDirectionCosines(double xyz[9]) {
121  this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
123  this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
124  return this->ResliceAxesDirectionCosines; };
126 
128 
134  void SetResliceAxesOrigin(double x, double y, double z);
135  void SetResliceAxesOrigin(const double xyz[3]) {
136  this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
137  void GetResliceAxesOrigin(double xyz[3]);
139  this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
140  return this->ResliceAxesOrigin; };
142 
144 
153  virtual void SetResliceTransform(vtkAbstractTransform*);
154  vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
156 
158 
167  virtual void SetInformationInput(vtkImageData*);
168  vtkGetObjectMacro(InformationInput, vtkImageData);
170 
172 
179  vtkSetMacro(TransformInputSampling, vtkTypeBool);
180  vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
181  vtkGetMacro(TransformInputSampling, vtkTypeBool);
183 
185 
190  vtkSetMacro(AutoCropOutput, vtkTypeBool);
191  vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
192  vtkGetMacro(AutoCropOutput, vtkTypeBool);
194 
196 
199  vtkSetMacro(Wrap, vtkTypeBool);
200  vtkGetMacro(Wrap, vtkTypeBool);
201  vtkBooleanMacro(Wrap, vtkTypeBool);
203 
205 
209  vtkSetMacro(Mirror, vtkTypeBool);
210  vtkGetMacro(Mirror, vtkTypeBool);
211  vtkBooleanMacro(Mirror, vtkTypeBool);
213 
215 
225  vtkSetMacro(Border, vtkTypeBool);
226  vtkGetMacro(Border, vtkTypeBool);
227  vtkBooleanMacro(Border, vtkTypeBool);
229 
231 
236  vtkSetMacro(BorderThickness, double);
237  vtkGetMacro(BorderThickness, double);
239 
243  vtkSetClampMacro(InterpolationMode, int,
245  vtkGetMacro(InterpolationMode, int);
247  this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
249  this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
251  this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
252  virtual const char *GetInterpolationModeAsString();
254 
256 
260  virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
261  virtual vtkAbstractImageInterpolator *GetInterpolator();
263 
265 
271  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
272  vtkGetMacro(SlabMode, int);
274  this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
276  this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
278  this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
280  this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
281  virtual const char *GetSlabModeAsString();
283 
285 
288  vtkSetMacro(SlabNumberOfSlices, int);
289  vtkGetMacro(SlabNumberOfSlices, int);
291 
293 
298  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
299  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
300  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
302 
304 
313  vtkSetMacro(SlabSliceSpacingFraction, double);
314  vtkGetMacro(SlabSliceSpacingFraction, double);
316 
318 
322  vtkSetMacro(Optimization, vtkTypeBool);
323  vtkGetMacro(Optimization, vtkTypeBool);
324  vtkBooleanMacro(Optimization, vtkTypeBool);
326 
328 
335  vtkSetMacro(ScalarShift, double);
336  vtkGetMacro(ScalarShift, double);
338 
340 
347  vtkSetMacro(ScalarScale, double);
348  vtkGetMacro(ScalarScale, double)
350 
352 
362  vtkSetMacro(OutputScalarType, int);
363  vtkGetMacro(OutputScalarType, int);
365 
367 
370  vtkSetVector4Macro(BackgroundColor, double);
371  vtkGetVector4Macro(BackgroundColor, double);
373 
375 
378  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
379  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
381 
383 
387  virtual void SetOutputSpacing(double x, double y, double z);
388  virtual void SetOutputSpacing(const double a[3]) {
389  this->SetOutputSpacing(a[0], a[1], a[2]); };
390  vtkGetVector3Macro(OutputSpacing, double);
391  void SetOutputSpacingToDefault();
393 
395 
399  virtual void SetOutputOrigin(double x, double y, double z);
400  virtual void SetOutputOrigin(const double a[3]) {
401  this->SetOutputOrigin(a[0], a[1], a[2]); };
402  vtkGetVector3Macro(OutputOrigin, double);
403  void SetOutputOriginToDefault();
405 
407 
411  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
412  virtual void SetOutputExtent(const int a[6]) {
413  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
414  vtkGetVector6Macro(OutputExtent, int);
415  void SetOutputExtentToDefault();
417 
419 
429  vtkSetMacro(OutputDimensionality, int);
430  vtkGetMacro(OutputDimensionality, int);
432 
437  vtkMTimeType GetMTime() override;
438 
442  void ReportReferences(vtkGarbageCollector*) override;
443 
445 
453  void SetInterpolate(int t) {
454  if (t && !this->GetInterpolate()) {
455  this->SetInterpolationModeToLinear(); }
456  else if (!t && this->GetInterpolate()) {
457  this->SetInterpolationModeToNearestNeighbor(); } };
458  void InterpolateOn() {
459  this->SetInterpolate(1); };
460  void InterpolateOff() {
461  this->SetInterpolate(0); };
463  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  return this->GetOutputPort(1); }
492  vtkImageStencilData *GetStencilOutput();
493  void SetStencilOutput(vtkImageStencilData *stencil);
495 
496 protected:
497  vtkImageReslice();
498  ~vtkImageReslice() override;
499 
501  double ResliceAxesDirectionCosines[9];
502  double ResliceAxesOrigin[3];
511  int SlabMode;
515  double ScalarShift;
516  double ScalarScale;
518  double BackgroundColor[4];
519  double OutputOrigin[3];
520  double OutputSpacing[3];
521  int OutputExtent[6];
532 
535 
541 
546  virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
547 
556  virtual void ConvertScalars(void *inPtr, void *outPtr,
557  int inputType, int inputNumComponents,
558  int count, int idX, int idY, int idZ,
559  int threadId);
560 
561  void ConvertScalarsBase(void *inPtr, void *outPtr,
562  int inputType, int inputNumComponents,
563  int count, int idX, int idY, int idZ, int threadId) {
564  this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
565  count, idX, idY, idZ, threadId); }
566 
567  void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
568  void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) override;
571  vtkInformationVector *) override;
573  vtkInformationVector *) override;
575  vtkInformationVector *) override;
576  void ThreadedRequestData(vtkInformation *request,
577  vtkInformationVector **inputVector,
578  vtkInformationVector *outputVector,
579  vtkImageData ***inData,
580  vtkImageData **outData, int ext[6], int id) override;
581  int FillInputPortInformation(int port, vtkInformation *info) override;
583 
584  vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
585  vtkInformation *outInfo);
587  return this->OptimizedTransform; };
588 
589 private:
590  vtkImageReslice(const vtkImageReslice&) = delete;
591  void operator=(const vtkImageReslice&) = delete;
592 };
593 
594 #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:507
vtkImageReslice::InformationInput
vtkImageData * InformationInput
Definition: vtkImageReslice.h:505
vtkImageReslice::GetStencilOutputPort
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
Definition: vtkImageReslice.h:490
vtkImageReslice::ResliceAxes
vtkMatrix4x4 * ResliceAxes
Definition: vtkImageReslice.h:500
vtkImageReslice::SetSlabModeToMax
void SetSlabModeToMax()
Definition: vtkImageReslice.h:275
vtkImageReslice::IndexMatrix
vtkMatrix4x4 * IndexMatrix
Definition: vtkImageReslice.h:533
vtkImageReslice::SetInterpolationModeToLinear
void SetInterpolationModeToLinear()
Definition: vtkImageReslice.h:248
vtkImageReslice::Wrap
vtkTypeBool Wrap
Definition: vtkImageReslice.h:506
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:50
vtkImageReslice::InterpolateOff
void InterpolateOff()
Definition: vtkImageReslice.h:460
vtkImageReslice::SetResliceAxesOrigin
void SetResliceAxesOrigin(const double xyz[3])
Definition: vtkImageReslice.h:135
VTK_IMAGE_SLAB_MAX
#define VTK_IMAGE_SLAB_MAX
Definition: vtkSystemIncludes.h:113
vtkImageReslice::SlabMode
int SlabMode
Definition: vtkImageReslice.h:511
vtkImageReslice::ComputeOutputSpacing
int ComputeOutputSpacing
Definition: vtkImageReslice.h:528
vtkAlgorithm::GetOutputPort
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:454
vtkImageReslice::SetInterpolate
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
Definition: vtkImageReslice.h:453
vtkImageReslice::OutputScalarType
int OutputScalarType
Definition: vtkImageReslice.h:522
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkImageReslice::InterpolationMode
int InterpolationMode
Definition: vtkImageReslice.h:509
vtkImageReslice::SetResliceAxesDirectionCosines
void SetResliceAxesDirectionCosines(const double xyz[9])
Definition: vtkImageReslice.h:115
vtkImageReslice::GetResliceAxesDirectionCosines
double * GetResliceAxesDirectionCosines()
Definition: vtkImageReslice.h:122
vtkImageReslice::ComputeOutputExtent
int ComputeOutputExtent
Definition: vtkImageReslice.h:530
vtkImageReslice::SlabTrapezoidIntegration
vtkTypeBool SlabTrapezoidIntegration
Definition: vtkImageReslice.h:513
vtkThreadedImageAlgorithm
Generic filter that has one input.
Definition: vtkThreadedImageAlgorithm.h:37
vtkImageReslice::UsePermuteExecute
int UsePermuteExecute
Definition: vtkImageReslice.h:527
vtkImageReslice::SetResliceAxesDirectionCosines
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Definition: vtkImageReslice.h:109
vtkImageReslice::InterpolateOn
void InterpolateOn()
Definition: vtkImageReslice.h:458
vtkImageReslice::OutputDimensionality
int OutputDimensionality
Definition: vtkImageReslice.h:523
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:250
vtkImageReslice::SetOutputExtent
virtual void SetOutputExtent(const int a[6])
Definition: vtkImageReslice.h:412
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:62
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:531
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:120
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
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:504
vtkImageReslice::SlabSliceSpacingFraction
double SlabSliceSpacingFraction
Definition: vtkImageReslice.h:514
vtkImageReslice::Optimization
vtkTypeBool Optimization
Definition: vtkImageReslice.h:510
vtkImageReslice
Reslices a volume along a new set of axes.
Definition: vtkImageReslice.h:71
vtkImageReslice::GetBackgroundLevel
double GetBackgroundLevel()
Definition: vtkImageReslice.h:379
vtkImageReslice::AutoCropOutput
vtkTypeBool AutoCropOutput
Definition: vtkImageReslice.h:525
vtkImageReslice::BorderThickness
double BorderThickness
Definition: vtkImageReslice.h:517
VTK_RESLICE_NEAREST
#define VTK_RESLICE_NEAREST
Definition: vtkImageReslice.h:60
vtkImageReslice::SetOutputSpacing
virtual void SetOutputSpacing(const double a[3])
Definition: vtkImageReslice.h:388
vtkImageReslice::GetInterpolate
int GetInterpolate()
Definition: vtkImageReslice.h:462
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:60
vtkImageReslice::OptimizedTransform
vtkAbstractTransform * OptimizedTransform
Definition: vtkImageReslice.h:534
vtkImageReslice::ScalarScale
double ScalarScale
Definition: vtkImageReslice.h:516
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:96
vtkImageReslice::SetInterpolationModeToNearestNeighbor
void SetInterpolationModeToNearestNeighbor()
Definition: vtkImageReslice.h:246
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkImageReslice::SetSlabModeToSum
void SetSlabModeToSum()
Definition: vtkImageReslice.h:279
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:540
vtkImageReslice::ComputeOutputOrigin
int ComputeOutputOrigin
Definition: vtkImageReslice.h:529
vtkAlgorithm::ReportReferences
void ReportReferences(vtkGarbageCollector *) override
vtkImageReslice::ScalarShift
double ScalarShift
Definition: vtkImageReslice.h:515
vtkImageReslice::SetSlabModeToMean
void SetSlabModeToMean()
Definition: vtkImageReslice.h:277
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:561
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkImageReslice::SlabNumberOfSlices
int SlabNumberOfSlices
Definition: vtkImageReslice.h:512
VTK_RESLICE_LINEAR
#define VTK_RESLICE_LINEAR
Definition: vtkImageReslice.h:61
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:34
vtkImageReslice::SetBackgroundLevel
void SetBackgroundLevel(double v)
Set background grey level (for single-component images).
Definition: vtkImageReslice.h:378
vtkImageReslice::SetOutputOrigin
virtual void SetOutputOrigin(const double a[3])
Definition: vtkImageReslice.h:400
vtkImageReslice::HitInputExtent
int HitInputExtent
Definition: vtkImageReslice.h:526
vtkImageReslice::Border
vtkTypeBool Border
Definition: vtkImageReslice.h:508
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:58
vtkThreadedImageAlgorithm::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkImageReslice::GetResliceAxesOrigin
double * GetResliceAxesOrigin()
Definition: vtkImageReslice.h:138
vtkImageReslice::SetSlabModeToMin
void SetSlabModeToMin()
Definition: vtkImageReslice.h:273
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImageReslice::ResliceTransform
vtkAbstractTransform * ResliceTransform
Definition: vtkImageReslice.h:503
vtkImageReslice::GetOptimizedTransform
vtkAbstractTransform * GetOptimizedTransform()
Definition: vtkImageReslice.h:586
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkImageReslice::TransformInputSampling
vtkTypeBool TransformInputSampling
Definition: vtkImageReslice.h:524