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 
234  vtkSetClampMacro(InterpolationMode, int,
236  vtkGetMacro(InterpolationMode, int);
238  this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
240  this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
242  this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
243  virtual const char *GetInterpolationModeAsString();
245 
247 
251  virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
252  virtual vtkAbstractImageInterpolator *GetInterpolator();
254 
256 
262  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
263  vtkGetMacro(SlabMode, int);
265  this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
267  this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
269  this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
271  this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
272  virtual const char *GetSlabModeAsString();
274 
276 
279  vtkSetMacro(SlabNumberOfSlices, int);
280  vtkGetMacro(SlabNumberOfSlices, int);
282 
284 
289  vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
290  vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
291  vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
293 
295 
304  vtkSetMacro(SlabSliceSpacingFraction, double);
305  vtkGetMacro(SlabSliceSpacingFraction, double);
307 
309 
313  vtkSetMacro(Optimization, vtkTypeBool);
314  vtkGetMacro(Optimization, vtkTypeBool);
315  vtkBooleanMacro(Optimization, vtkTypeBool);
317 
319 
326  vtkSetMacro(ScalarShift, double);
327  vtkGetMacro(ScalarShift, double);
329 
331 
338  vtkSetMacro(ScalarScale, double);
339  vtkGetMacro(ScalarScale, double)
341 
343 
353  vtkSetMacro(OutputScalarType, int);
354  vtkGetMacro(OutputScalarType, int);
356 
358 
361  vtkSetVector4Macro(BackgroundColor, double);
362  vtkGetVector4Macro(BackgroundColor, double);
364 
366 
369  void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
370  double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
372 
374 
378  virtual void SetOutputSpacing(double x, double y, double z);
379  virtual void SetOutputSpacing(const double a[3]) {
380  this->SetOutputSpacing(a[0], a[1], a[2]); };
381  vtkGetVector3Macro(OutputSpacing, double);
382  void SetOutputSpacingToDefault();
384 
386 
390  virtual void SetOutputOrigin(double x, double y, double z);
391  virtual void SetOutputOrigin(const double a[3]) {
392  this->SetOutputOrigin(a[0], a[1], a[2]); };
393  vtkGetVector3Macro(OutputOrigin, double);
394  void SetOutputOriginToDefault();
396 
398 
402  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
403  virtual void SetOutputExtent(const int a[6]) {
404  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
405  vtkGetVector6Macro(OutputExtent, int);
406  void SetOutputExtentToDefault();
408 
410 
420  vtkSetMacro(OutputDimensionality, int);
421  vtkGetMacro(OutputDimensionality, int);
423 
428  vtkMTimeType GetMTime() override;
429 
433  void ReportReferences(vtkGarbageCollector*) override;
434 
436 
444  void SetInterpolate(int t) {
445  if (t && !this->GetInterpolate()) {
446  this->SetInterpolationModeToLinear(); }
447  else if (!t && this->GetInterpolate()) {
448  this->SetInterpolationModeToNearestNeighbor(); } };
449  void InterpolateOn() {
450  this->SetInterpolate(1); };
451  void InterpolateOff() {
452  this->SetInterpolate(0); };
454  return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
456 
458 
463  void SetStencilData(vtkImageStencilData *stencil);
464  vtkImageStencilData *GetStencil();
466 
468 
472  vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
473  vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
474  vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
476 
478 
482  return this->GetOutputPort(1); }
483  vtkImageStencilData *GetStencilOutput();
484  void SetStencilOutput(vtkImageStencilData *stencil);
486 
487 protected:
488  vtkImageReslice();
489  ~vtkImageReslice() override;
490 
492  double ResliceAxesDirectionCosines[9];
493  double ResliceAxesOrigin[3];
502  int SlabMode;
506  double ScalarShift;
507  double ScalarScale;
508  double BackgroundColor[4];
509  double OutputOrigin[3];
510  double OutputSpacing[3];
511  int OutputExtent[6];
522 
525 
531 
536  virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
537 
546  virtual void ConvertScalars(void *inPtr, void *outPtr,
547  int inputType, int inputNumComponents,
548  int count, int idX, int idY, int idZ,
549  int threadId);
550 
551  void ConvertScalarsBase(void *inPtr, void *outPtr,
552  int inputType, int inputNumComponents,
553  int count, int idX, int idY, int idZ, int threadId) {
554  this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
555  count, idX, idY, idZ, threadId); }
556 
557  void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
558  void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) override;
561  vtkInformationVector *) override;
563  vtkInformationVector *) override;
565  vtkInformationVector *) override;
566  void ThreadedRequestData(vtkInformation *request,
567  vtkInformationVector **inputVector,
568  vtkInformationVector *outputVector,
569  vtkImageData ***inData,
570  vtkImageData **outData, int ext[6], int id) override;
571  int FillInputPortInformation(int port, vtkInformation *info) override;
573 
574  vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
575  vtkInformation *outInfo);
577  return this->OptimizedTransform; };
578 
579 private:
580  vtkImageReslice(const vtkImageReslice&) = delete;
581  void operator=(const vtkImageReslice&) = delete;
582 };
583 
584 #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:454
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
#define VTK_IMAGE_SLAB_MIN
vtkAbstractTransform * GetOptimizedTransform()
#define VTK_RESLICE_CUBIC
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
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()
Set interpolation mode (default: nearest neighbor).
void SetInterpolationModeToCubic()
Set interpolation mode (default: nearest neighbor).
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:33
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:39
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:58
void SetInterpolationModeToNearestNeighbor()
Set interpolation mode (default: nearest neighbor).
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.