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) VTK_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, int);
186  vtkBooleanMacro(TransformInputSampling, int);
187  vtkGetMacro(TransformInputSampling, int);
189 
191 
196  vtkSetMacro(AutoCropOutput, int);
197  vtkBooleanMacro(AutoCropOutput, int);
198  vtkGetMacro(AutoCropOutput, int);
200 
202 
205  vtkSetMacro(Wrap, int);
206  vtkGetMacro(Wrap, int);
207  vtkBooleanMacro(Wrap, int);
209 
211 
215  vtkSetMacro(Mirror, int);
216  vtkGetMacro(Mirror, int);
217  vtkBooleanMacro(Mirror, int);
219 
221 
231  vtkSetMacro(Border, int);
232  vtkGetMacro(Border, int);
233  vtkBooleanMacro(Border, int);
235 
237 
240  vtkSetClampMacro(InterpolationMode, int,
242  vtkGetMacro(InterpolationMode, int);
244  this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
246  this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
248  this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
249  virtual const char *GetInterpolationModeAsString();
251 
253 
257  virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
258  virtual vtkAbstractImageInterpolator *GetInterpolator();
260 
262 
268  vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
269  vtkGetMacro(SlabMode, int);
271  this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
273  this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
275  this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
277  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, int);
296  vtkBooleanMacro(SlabTrapezoidIntegration, int);
297  vtkGetMacro(SlabTrapezoidIntegration, int);
299 
301 
310  vtkSetMacro(SlabSliceSpacingFraction, double);
311  vtkGetMacro(SlabSliceSpacingFraction, double);
313 
315 
319  vtkSetMacro(Optimization, int);
320  vtkGetMacro(Optimization, int);
321  vtkBooleanMacro(Optimization, int);
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]) {
386  this->SetOutputSpacing(a[0], a[1], a[2]); };
387  vtkGetVector3Macro(OutputSpacing, double);
388  void SetOutputSpacingToDefault();
390 
392 
396  virtual void SetOutputOrigin(double x, double y, double z);
397  virtual void SetOutputOrigin(const double a[3]) {
398  this->SetOutputOrigin(a[0], a[1], a[2]); };
399  vtkGetVector3Macro(OutputOrigin, double);
400  void SetOutputOriginToDefault();
402 
404 
408  virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
409  virtual void SetOutputExtent(const int a[6]) {
410  this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
411  vtkGetVector6Macro(OutputExtent, int);
412  void SetOutputExtentToDefault();
414 
416 
426  vtkSetMacro(OutputDimensionality, int);
427  vtkGetMacro(OutputDimensionality, int);
429 
434  vtkMTimeType GetMTime() VTK_OVERRIDE;
435 
439  void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;
440 
442 
450  void SetInterpolate(int t) {
451  if (t && !this->GetInterpolate()) {
452  this->SetInterpolationModeToLinear(); }
453  else if (!t && this->GetInterpolate()) {
454  this->SetInterpolationModeToNearestNeighbor(); } };
455  void InterpolateOn() {
456  this->SetInterpolate(1); };
457  void InterpolateOff() {
458  this->SetInterpolate(0); };
460  return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
462 
464 
469  void SetStencilData(vtkImageStencilData *stencil);
470  vtkImageStencilData *GetStencil();
472 
474 
478  vtkSetMacro(GenerateStencilOutput, int);
479  vtkGetMacro(GenerateStencilOutput, int);
480  vtkBooleanMacro(GenerateStencilOutput, int);
482 
484 
488  return this->GetOutputPort(1); }
489  vtkImageStencilData *GetStencilOutput();
490  void SetStencilOutput(vtkImageStencilData *stencil);
492 
493 protected:
494  vtkImageReslice();
495  ~vtkImageReslice();
496 
498  double ResliceAxesDirectionCosines[9];
499  double ResliceAxesOrigin[3];
503  int Wrap;
504  int Mirror;
505  int Border;
508  int SlabMode;
512  double ScalarShift;
513  double ScalarScale;
514  double BackgroundColor[4];
515  double OutputOrigin[3];
516  double OutputSpacing[3];
517  int OutputExtent[6];
528 
531 
537 
542  virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
543 
552  virtual void ConvertScalars(void *inPtr, void *outPtr,
553  int inputType, int inputNumComponents,
554  int count, int idX, int idY, int idZ,
555  int threadId);
556 
557  void ConvertScalarsBase(void *inPtr, void *outPtr,
558  int inputType, int inputNumComponents,
559  int count, int idX, int idY, int idZ, int threadId) {
560  this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
561  count, idX, idY, idZ, threadId); }
562 
563  void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
564  virtual void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) VTK_OVERRIDE;
565  virtual vtkImageData *AllocateOutputData(vtkDataObject *, vtkInformation *) VTK_OVERRIDE;
566  virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
567  vtkInformationVector *) VTK_OVERRIDE;
568  virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
569  vtkInformationVector *) VTK_OVERRIDE;
570  virtual int RequestData(vtkInformation *, vtkInformationVector **,
571  vtkInformationVector *) VTK_OVERRIDE;
572  virtual void ThreadedRequestData(vtkInformation *request,
573  vtkInformationVector **inputVector,
574  vtkInformationVector *outputVector,
575  vtkImageData ***inData,
576  vtkImageData **outData, int ext[6], int id) VTK_OVERRIDE;
577  virtual int FillInputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE;
578  virtual int FillOutputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE;
579 
580  vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
581  vtkInformation *outInfo);
582  vtkAbstractTransform *GetOptimizedTransform() {
583  return this->OptimizedTransform; };
584 
585 private:
586  vtkImageReslice(const vtkImageReslice&) VTK_DELETE_FUNCTION;
587  void operator=(const vtkImageReslice&) VTK_DELETE_FUNCTION;
588 };
589 
590 #endif
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
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:459
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
#define VTK_IMAGE_SLAB_MIN
#define VTK_RESLICE_CUBIC
Store vtkAlgorithm input/output information.
void SetSlabModeToMax()
Set the slab mode, for generating thick slices.
vtkMatrix4x4 * IndexMatrix
#define VTK_IMAGE_SLAB_SUM
#define VTK_IMAGE_SLAB_MEAN
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.
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
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
Detect and break reference loops.
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.
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:45
superclass for all geometric transformations
virtual vtkMTimeType GetMTime()
Return this object's modified time.
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
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.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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.
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.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int GetInterpolate()
Convenient methods for switching between nearest-neighbor and linear interpolation.
int HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
general representation of visualization data
Definition: vtkDataObject.h:64
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.