VTK  9.5.20250621
vtkImageReslice.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
83#ifndef vtkImageReslice_h
84#define vtkImageReslice_h
85
86#include "vtkImagingCoreModule.h" // For export macro
88#include "vtkWrappingHints.h"
89
90// interpolation mode constants
91#define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
92#define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
93#define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
94
95VTK_ABI_NAMESPACE_BEGIN
96class vtkImageData;
98class vtkMatrix4x4;
102
104{
105public:
108
109 void PrintSelf(ostream& os, vtkIndent indent) override;
110
112
128 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
130
132
138 void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1,
139 double y2, double z0, double z1, double z2);
140 void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
141 {
142 this->SetResliceAxesDirectionCosines(x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
143 }
144 void SetResliceAxesDirectionCosines(const double xyz[9])
145 {
146 this->SetResliceAxesDirectionCosines(
147 xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5], xyz[6], xyz[7], xyz[8]);
148 }
149 void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
151 {
152 this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]);
153 }
155 {
156 this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
157 return this->ResliceAxesDirectionCosines;
158 }
160
162
168 void SetResliceAxesOrigin(double x, double y, double z);
169 void SetResliceAxesOrigin(const double xyz[3])
170 {
171 this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]);
172 }
173 void GetResliceAxesOrigin(double xyz[3]);
175 {
176 this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
177 return this->ResliceAxesOrigin;
178 }
180
182
192 vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
194
196
206 vtkGetObjectMacro(InformationInput, vtkImageData);
208
210
217 vtkSetMacro(TransformInputSampling, vtkTypeBool);
218 vtkBooleanMacro(TransformInputSampling, vtkTypeBool);
219 vtkGetMacro(TransformInputSampling, vtkTypeBool);
221
223
228 vtkSetMacro(AutoCropOutput, vtkTypeBool);
229 vtkBooleanMacro(AutoCropOutput, vtkTypeBool);
230 vtkGetMacro(AutoCropOutput, vtkTypeBool);
232
234
237 vtkSetMacro(Wrap, vtkTypeBool);
238 vtkGetMacro(Wrap, vtkTypeBool);
239 vtkBooleanMacro(Wrap, vtkTypeBool);
241
243
247 vtkSetMacro(Mirror, vtkTypeBool);
248 vtkGetMacro(Mirror, vtkTypeBool);
249 vtkBooleanMacro(Mirror, vtkTypeBool);
251
253
263 vtkSetMacro(Border, vtkTypeBool);
264 vtkGetMacro(Border, vtkTypeBool);
265 vtkBooleanMacro(Border, vtkTypeBool);
267
269
274 vtkSetMacro(BorderThickness, double);
275 vtkGetMacro(BorderThickness, double);
277
281 vtkSetClampMacro(InterpolationMode, int, VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
282 vtkGetMacro(InterpolationMode, int);
283 void SetInterpolationModeToNearestNeighbor() { this->SetInterpolationMode(VTK_RESLICE_NEAREST); }
284 void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_RESLICE_LINEAR); }
285 void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_RESLICE_CUBIC); }
286 virtual const char* GetInterpolationModeAsString();
288
290
297
299
305 vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
306 vtkGetMacro(SlabMode, int);
307 void SetSlabModeToMin() { this->SetSlabMode(VTK_IMAGE_SLAB_MIN); }
308 void SetSlabModeToMax() { this->SetSlabMode(VTK_IMAGE_SLAB_MAX); }
309 void SetSlabModeToMean() { this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); }
310 void SetSlabModeToSum() { this->SetSlabMode(VTK_IMAGE_SLAB_SUM); }
311 virtual const char* GetSlabModeAsString();
313
315
318 vtkSetMacro(SlabNumberOfSlices, int);
319 vtkGetMacro(SlabNumberOfSlices, int);
321
323
328 vtkSetMacro(SlabTrapezoidIntegration, vtkTypeBool);
329 vtkBooleanMacro(SlabTrapezoidIntegration, vtkTypeBool);
330 vtkGetMacro(SlabTrapezoidIntegration, vtkTypeBool);
332
334
343 vtkSetMacro(SlabSliceSpacingFraction, double);
344 vtkGetMacro(SlabSliceSpacingFraction, double);
346
348
352 vtkSetMacro(Optimization, vtkTypeBool);
353 vtkGetMacro(Optimization, vtkTypeBool);
354 vtkBooleanMacro(Optimization, vtkTypeBool);
356
358
365 vtkSetMacro(ScalarShift, double);
366 vtkGetMacro(ScalarShift, double);
368
370
377 vtkSetMacro(ScalarScale, double);
378 vtkGetMacro(ScalarScale, double);
380
382
392 vtkSetMacro(OutputScalarType, int);
393 vtkGetMacro(OutputScalarType, int);
395
397
400 vtkSetVector4Macro(BackgroundColor, double);
401 vtkGetVector4Macro(BackgroundColor, double);
403
405
408 void SetBackgroundLevel(double v) { this->SetBackgroundColor(v, v, v, v); }
409 double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; }
411
413
417 virtual void SetOutputSpacing(double x, double y, double z);
418 virtual void SetOutputSpacing(const double a[3]) { this->SetOutputSpacing(a[0], a[1], a[2]); }
419 vtkGetVector3Macro(OutputSpacing, double);
422
424
433 virtual void SetOutputDirection(double xx, double xy, double xz, double yx, double yy, double yz,
434 double zx, double zy, double zz);
435 virtual void SetOutputDirection(const double a[9])
436 {
437 this->SetOutputDirection(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
438 }
439 vtkGetVector3Macro(OutputDirection, double);
442
444
448 virtual void SetOutputOrigin(double x, double y, double z);
449 virtual void SetOutputOrigin(const double a[3]) { this->SetOutputOrigin(a[0], a[1], a[2]); }
450 vtkGetVector3Macro(OutputOrigin, double);
453
455
459 virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
460 virtual void SetOutputExtent(const int a[6])
461 {
462 this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]);
463 }
464 vtkGetVector6Macro(OutputExtent, int);
467
469
479 vtkSetMacro(OutputDimensionality, int);
480 vtkGetMacro(OutputDimensionality, int);
482
488
493
495
503 void SetInterpolate(int t)
504 {
505 if (t && !this->GetInterpolate())
506 {
507 this->SetInterpolationModeToLinear();
508 }
509 else if (!t && this->GetInterpolate())
510 {
511 this->SetInterpolationModeToNearestNeighbor();
512 }
513 }
514 void InterpolateOn() { this->SetInterpolate(1); }
515 void InterpolateOff() { this->SetInterpolate(0); }
516 int GetInterpolate() { return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); }
518
520
528
530
534 vtkSetMacro(GenerateStencilOutput, vtkTypeBool);
535 vtkGetMacro(GenerateStencilOutput, vtkTypeBool);
536 vtkBooleanMacro(GenerateStencilOutput, vtkTypeBool);
538
540
547
548protected:
551
553 double ResliceAxesDirectionCosines[9];
554 double ResliceAxesOrigin[3];
570 double BackgroundColor[4];
571 double OutputDirection[9];
572 double OutputOrigin[3];
573 double OutputSpacing[3];
574 int OutputExtent[6];
586
589
595
600 virtual int ConvertScalarInfo(int& scalarType, int& numComponents);
601
610 virtual void ConvertScalars(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
611 int count, int idX, int idY, int idZ, int threadId);
612
613 void ConvertScalarsBase(void* inPtr, void* outPtr, int inputType, int inputNumComponents,
614 int count, int idX, int idY, int idZ, int threadId)
615 {
616 this->ConvertScalars(
617 inPtr, outPtr, inputType, inputNumComponents, count, idX, idY, idZ, threadId);
618 }
619
626
628 vtkInformation* inInfo, const double outDirection[9], double bounds[6]);
629 void AllocateOutputData(vtkImageData* output, vtkInformation* outInfo, int* uExtent) override;
635 vtkInformationVector* outputVector, vtkImageData*** inData, vtkImageData** outData, int ext[6],
636 int id) override;
637 int FillInputPortInformation(int port, vtkInformation* info) override;
638 int FillOutputPortInformation(int port, vtkInformation* info) override;
639
641 vtkAbstractTransform* GetOptimizedTransform() { return this->OptimizedTransform; }
642
643private:
644 vtkImageReslice(const vtkImageReslice&) = delete;
645 void operator=(const vtkImageReslice&) = delete;
646};
647
648VTK_ABI_NAMESPACE_END
649#endif
interpolate data values from images
superclass for all geometric transformations
Proxy object to connect input/output ports.
vtkAlgorithmOutput * GetOutputPort()
general representation of visualization data
Detect and break reference loops.
topologically and geometrically regular array of data
Reslices a volume along a new set of axes.
void InterpolateOff()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void SetResliceAxesDirectionCosines(const double x[3], const double y[3], const double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
vtkImageStencilData * GetStencil()
Use a stencil to limit the calculations to a specific region of the output.
virtual void SetOutputOrigin(const double a[3])
Set the origin for the output data.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ReportReferences(vtkGarbageCollector *) override
Report object referenced by instances of this class.
int FillInputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f)
Set the extent for the output data.
void SetResliceAxesDirectionCosines(const double xyz[9])
Specify the direction cosines for the ResliceAxes (i.e.
vtkTypeBool TransformInputSampling
void GetAutoCroppedOutputBounds(vtkInformation *inInfo, const double outDirection[9], double bounds[6])
double * GetResliceAxesOrigin()
Specify the origin for the ResliceAxes (i.e.
virtual void SetResliceTransform(vtkAbstractTransform *)
Set a transform to be applied to the resampling grid that has been defined via the ResliceAxes and th...
int RequestInformationBase(vtkInformationVector **, vtkInformationVector *)
For derived classes, this should be called at the very end of RequestInformation() to ensure that var...
virtual const char * GetInterpolationModeAsString()
void SetResliceAxesDirectionCosines(double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)
Specify the direction cosines for the ResliceAxes (i.e.
vtkTypeBool HasConvertScalars
This should be set to 1 by derived classes that override the ConvertScalars method.
void SetSlabModeToMean()
Set the slab mode, for generating thick slices.
void InterpolateOn()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void SetResliceAxesOrigin(double x, double y, double z)
Specify the origin for the ResliceAxes (i.e.
void SetResliceAxesOrigin(const double xyz[3])
Specify the origin for the ResliceAxes (i.e.
virtual void ConvertScalars(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
This should be overridden by derived classes that operate on the interpolated data before it is place...
void GetResliceAxesDirectionCosines(double xyz[9])
Specify the direction cosines for the ResliceAxes (i.e.
virtual void SetOutputExtent(const int a[6])
Set the extent for the output data.
virtual void SetOutputOrigin(double x, double y, double z)
Set the origin for the output data.
vtkTypeBool Optimization
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
void SetOutputSpacingToDefault()
Set the voxel spacing for the output data.
virtual void SetOutputDirection(const double a[9])
Set the direction for the output data.
void SetStencilOutput(vtkImageStencilData *stencil)
Get the output stencil.
void ThreadedRequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector, vtkImageData ***inData, vtkImageData **outData, int ext[6], int id) override
If the subclass does not define an Execute method, then the task will be broken up,...
vtkImageStencilData * GetStencilOutput()
Get the output stencil.
virtual vtkAbstractImageInterpolator * GetInterpolator()
Set the interpolator to use.
void SetInterpolationModeToCubic()
virtual void SetOutputDirection(double xx, double xy, double xz, double yx, double yy, double yz, double zx, double zy, double zz)
Set the direction for the output data.
int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses can reimplement this method to translate the update extent requests from each output port ...
double SlabSliceSpacingFraction
vtkImageData * AllocateOutputData(vtkDataObject *, vtkInformation *) override
Allocate the output data.
int GetInterpolate()
Convenient methods for switching between nearest-neighbor and linear interpolation.
void GetResliceAxesOrigin(double xyz[3])
Specify the origin for the ResliceAxes (i.e.
void SetSlabModeToMin()
Set the slab mode, for generating thick slices.
virtual void SetOutputSpacing(const double a[3])
Set the voxel spacing for the output data.
double GetBackgroundLevel()
Set background grey level (for single-component images).
virtual int ConvertScalarInfo(int &scalarType, int &numComponents)
This should be overridden by derived classes that operate on the interpolated data before it is place...
~vtkImageReslice() override
void SetOutputDirectionToDefault()
Set the direction for the output data.
void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent) override
Allocate the output data.
void SetSlabModeToMax()
Set the slab mode, for generating thick slices.
vtkAbstractTransform * OptimizedTransform
vtkTypeBool SlabTrapezoidIntegration
vtkMatrix4x4 * IndexMatrix
vtkMTimeType GetMTime() override
When determining the modified time of the filter, this check the modified time of the transform and m...
vtkTypeBool AutoCropOutput
vtkTypeBool GenerateStencilOutput
vtkMatrix4x4 * ResliceAxes
virtual void SetOutputSpacing(double x, double y, double z)
Set the voxel spacing for the output data.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called in response to a REQUEST_DATA request from the executive.
static vtkImageReslice * New()
void ConvertScalarsBase(void *inPtr, void *outPtr, int inputType, int inputNumComponents, int count, int idX, int idY, int idZ, int threadId)
double * GetResliceAxesDirectionCosines()
Specify the direction cosines for the ResliceAxes (i.e.
vtkAbstractTransform * ResliceTransform
virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler)
Set the interpolator to use.
virtual void SetResliceAxes(vtkMatrix4x4 *)
This method is used to set up the axes for the output voxels.
vtkAbstractImageInterpolator * Interpolator
vtkAlgorithmOutput * GetStencilOutputPort()
Get the output stencil.
void SetInterpolationModeToNearestNeighbor()
void SetOutputExtentToDefault()
Set the extent for the output data.
virtual const char * GetSlabModeAsString()
Set the slab mode, for generating thick slices.
void SetInterpolate(int t)
Convenient methods for switching between nearest-neighbor and linear interpolation.
vtkAbstractTransform * GetOptimizedTransform()
void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3])
Specify the direction cosines for the ResliceAxes (i.e.
vtkMatrix4x4 * GetIndexMatrix(vtkInformation *inInfo, vtkInformation *outInfo)
vtkImageData * InformationInput
void SetBackgroundLevel(double v)
Set background grey level (for single-component images).
void SetOutputOriginToDefault()
Set the origin for the output data.
virtual void SetInformationInput(vtkImageData *)
Set a vtkImageData from which the default Spacing, Origin, and WholeExtent of the output will be copi...
void SetInterpolationModeToLinear()
int FillOutputPortInformation(int port, vtkInformation *info) override
These method should be reimplemented by subclasses that have more than a single input or single outpu...
void SetStencilData(vtkImageStencilData *stencil)
Use a stencil to limit the calculations to a specific region of the output.
void SetSlabModeToSum()
Set the slab mode, for generating thick slices.
efficient description of an image stencil
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Superclass for mapping scalar values to colors.
Generic filter that has one input.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_RESLICE_CUBIC
#define VTK_RESLICE_NEAREST
#define VTK_RESLICE_LINEAR
#define VTK_IMAGE_SLAB_MAX
#define VTK_IMAGE_SLAB_MIN
#define VTK_IMAGE_SLAB_SUM
#define VTK_IMAGE_SLAB_MEAN
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO