VTK: Imaging/Core/vtkAbstractImageInterpolator.h Source File

| VTK 9.3.1

vtkAbstractImageInterpolator.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
21 #ifndef vtkAbstractImageInterpolator_h
22 #define vtkAbstractImageInterpolator_h
23
24 #include "vtkImagingCoreModule.h" // For export macro
25 #include "vtkObject.h"
26
27 enum vtkImageBorderMode : int
28 {
29 VTK_IMAGE_BORDER_CLAMP = 0,
30 VTK_IMAGE_BORDER_REPEAT = 1,
31 VTK_IMAGE_BORDER_MIRROR = 2,
32 };
33
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkDataObject;
36 class vtkImageData;
37 class vtkDataArray;
38 struct vtkInterpolationInfo;
39 struct vtkInterpolationWeights;
40
41 class VTKIMAGINGCORE_EXPORT vtkAbstractImageInterpolator : public vtkObject
42 {
43 public:
44 vtkTypeMacro(vtkAbstractImageInterpolator, vtkObject);
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
50 virtual void Initialize(vtkDataObject* data);
51
55 virtual void ReleaseData();
56
61 void DeepCopy(vtkAbstractImageInterpolator* obj);
62
68 virtual void Update();
69
77 double Interpolate(double x, double y, double z, int component);
78
86 bool Interpolate(const double point[3], double* value);
87
91 void SetOutValue(double outValue);
92 double GetOutValue() { return this->OutValue; }
93
99 void SetTolerance(double tol);
100 double GetTolerance() { return this->Tolerance; }
101
108 void SetComponentOffset(int offset);
109 int GetComponentOffset() { return this->ComponentOffset; }
110
117 void SetComponentCount(int count);
118 int GetComponentCount() { return this->ComponentCount; }
119
124 int ComputeNumberOfComponents(int inputComponents);
125
131 int GetNumberOfComponents();
132
134
139 void InterpolateIJK(const double point[3], double* value);
140 void InterpolateIJK(const float point[3], float* value);
142
144
150 bool CheckBoundsIJK(const double x[3]);
151 bool CheckBoundsIJK(const float x[3]);
153
155
162 void SetBorderMode(vtkImageBorderMode mode);
163 void SetBorderModeToClamp() { this->SetBorderMode(VTK_IMAGE_BORDER_CLAMP); }
164 void SetBorderModeToRepeat() { this->SetBorderMode(VTK_IMAGE_BORDER_REPEAT); }
165 void SetBorderModeToMirror() { this->SetBorderMode(VTK_IMAGE_BORDER_MIRROR); }
166 vtkImageBorderMode GetBorderMode() { return this->BorderMode; }
167 const char* GetBorderModeAsString();
169
177 void SetSlidingWindow(bool x);
178 void SlidingWindowOn() { this->SetSlidingWindow(true); }
179 void SlidingWindowOff() { this->SetSlidingWindow(false); }
180 bool GetSlidingWindow() { return this->SlidingWindow; }
181
188 virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
189
196 virtual bool IsSeparable() = 0;
197
199
209 virtual void PrecomputeWeightsForExtent(const double matrix[16], const int extent[6],
210 int checkExtent[6], vtkInterpolationWeights*& weights);
211 virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6],
212 int checkExtent[6], vtkInterpolationWeights*& weights);
214
218 virtual void FreePrecomputedWeights(vtkInterpolationWeights*& weights);
219
221
227 void InterpolateRow(
228 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n);
229 void InterpolateRow(
230 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n);
232
234
237 vtkGetVector3Macro(Spacing, double);
239
241
244 vtkGetVectorMacro(Direction, double, 9);
246
248
251 vtkGetVector3Macro(Origin, double);
253
255
258 vtkGetVector6Macro(Extent, int);
260
261 protected:
262 vtkAbstractImageInterpolator();
263 ~vtkAbstractImageInterpolator() override;
264
268 virtual void InternalUpdate() = 0;
269
273 virtual void InternalDeepCopy(vtkAbstractImageInterpolator* obj) = 0;
274
278 void CoordinateToIJK(const double point[3], double ijk[3]);
279
281
284 virtual void GetInterpolationFunc(
285 void (**doublefunc)(vtkInterpolationInfo*, const double[3], double*));
286 virtual void GetInterpolationFunc(
287 void (**floatfunc)(vtkInterpolationInfo*, const float[3], float*));
289
291
294 virtual void GetRowInterpolationFunc(
295 void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
296 virtual void GetRowInterpolationFunc(
297 void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
299
301
304 virtual void GetSlidingWindowFunc(
305 void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
306 virtual void GetSlidingWindowFunc(
307 void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
309
310 vtkDataArray* Scalars;
311 double StructuredBoundsDouble[6];
312 float StructuredBoundsFloat[6];
313 int Extent[6];
314 double Spacing[3];
315 double Direction[9];
316 double InverseDirection[9];
317 double Origin[3];
318 double OutValue;
319 double Tolerance;
320 vtkImageBorderMode BorderMode;
321 int ComponentOffset;
322 int ComponentCount;
323 bool UseDirection;
324 bool SlidingWindow;
325
326 // information needed by the interpolator funcs
327 vtkInterpolationInfo* InterpolationInfo;
328
329 void (*InterpolationFuncDouble)(
330 vtkInterpolationInfo* info, const double point[3], double* outPtr);
331 void (*InterpolationFuncFloat)(vtkInterpolationInfo* info, const float point[3], float* outPtr);
332
333 void (*RowInterpolationFuncDouble)(
334 vtkInterpolationWeights* weights, int idX, int idY, int idZ, double* outPtr, int n);
335 void (*RowInterpolationFuncFloat)(
336 vtkInterpolationWeights* weights, int idX, int idY, int idZ, float* outPtr, int n);
337
338 private:
339 vtkAbstractImageInterpolator(const vtkAbstractImageInterpolator&) = delete;
340 void operator=(const vtkAbstractImageInterpolator&) = delete;
341 };
342
343 inline void vtkAbstractImageInterpolator::InterpolateIJK(const double point[3], double* value)
344 {
345 this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
346 }
347
348 inline void vtkAbstractImageInterpolator::InterpolateIJK(const float point[3], float* value)
349 {
350 this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
351 }
352
353 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
354 {
355 const double* bounds = this->StructuredBoundsDouble;
356 return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
357 (x[2] < bounds[4]) || (x[2] > bounds[5]));
358 }
359
360 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
361 {
362 const float* bounds = this->StructuredBoundsFloat;
363 return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
364 (x[2] < bounds[4]) || (x[2] > bounds[5]));
365 }
366
367 inline void vtkAbstractImageInterpolator::InterpolateRow(
368 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n)
369 {
370 this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
371 }
372
373 inline void vtkAbstractImageInterpolator::InterpolateRow(
374 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n)
375 {
376 this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
377 }
378
379 VTK_ABI_NAMESPACE_END
380 #endif
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:42
vtkAbstractImageInterpolator::Update
virtual void Update()
Update the interpolator.
vtkAbstractImageInterpolator::SetBorderMode
void SetBorderMode(vtkImageBorderMode mode)
The border mode (default: clamp).
vtkAbstractImageInterpolator::PrecomputeWeightsForExtent
virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6], int checkExtent[6], vtkInterpolationWeights *&weights)
If the data is going to be sampled on a regular grid, then the interpolation weights can be precomput...
vtkAbstractImageInterpolator::InterpolationFuncDouble
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
Definition: vtkAbstractImageInterpolator.h:329
vtkAbstractImageInterpolator::ComputeSupportSize
virtual void ComputeSupportSize(const double matrix[16], int support[3])=0
Get the support size for use in computing update extents.
vtkAbstractImageInterpolator::UseDirection
bool UseDirection
Definition: vtkAbstractImageInterpolator.h:323
vtkAbstractImageInterpolator::IsSeparable
virtual bool IsSeparable()=0
True if the interpolation is separable, which means that the weights can be precomputed in order to a...
vtkAbstractImageInterpolator::GetComponentCount
int GetComponentCount()
Definition: vtkAbstractImageInterpolator.h:118
vtkAbstractImageInterpolator::SetBorderModeToClamp
void SetBorderModeToClamp()
The border mode (default: clamp).
Definition: vtkAbstractImageInterpolator.h:163
vtkAbstractImageInterpolator::~vtkAbstractImageInterpolator
~vtkAbstractImageInterpolator() override
vtkAbstractImageInterpolator::GetBorderModeAsString
const char * GetBorderModeAsString()
The border mode (default: clamp).
vtkAbstractImageInterpolator::GetOutValue
double GetOutValue()
Definition: vtkAbstractImageInterpolator.h:92
vtkAbstractImageInterpolator::ComputeNumberOfComponents
int ComputeNumberOfComponents(int inputComponents)
Compute the number of output components based on the ComponentOffset, ComponentCount,...
vtkAbstractImageInterpolator::SetComponentCount
void SetComponentCount(int count)
This method specifies the number of components to extract.
vtkAbstractImageInterpolator::InterpolationInfo
vtkInterpolationInfo * InterpolationInfo
Definition: vtkAbstractImageInterpolator.h:327
vtkAbstractImageInterpolator::OutValue
double OutValue
Definition: vtkAbstractImageInterpolator.h:318
vtkAbstractImageInterpolator::vtkAbstractImageInterpolator
vtkAbstractImageInterpolator()
vtkAbstractImageInterpolator::Scalars
vtkDataArray * Scalars
Definition: vtkAbstractImageInterpolator.h:310
vtkAbstractImageInterpolator::GetRowInterpolationFunc
virtual void GetRowInterpolationFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
Get the row interpolation functions.
vtkAbstractImageInterpolator::StructuredBoundsDouble
double StructuredBoundsDouble[6]
Definition: vtkAbstractImageInterpolator.h:311
vtkAbstractImageInterpolator::StructuredBoundsFloat
float StructuredBoundsFloat[6]
Definition: vtkAbstractImageInterpolator.h:312
vtkAbstractImageInterpolator::GetComponentOffset
int GetComponentOffset()
Definition: vtkAbstractImageInterpolator.h:109
vtkAbstractImageInterpolator::GetSlidingWindowFunc
virtual void GetSlidingWindowFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
Get the sliding window interpolation functions.
vtkAbstractImageInterpolator::SetComponentOffset
void SetComponentOffset(int offset)
This method specifies which component of the input will be interpolated, or if ComponentCount is also...
vtkAbstractImageInterpolator::ReleaseData
virtual void ReleaseData()
Release any data stored by the interpolator.
vtkAbstractImageInterpolator::Tolerance
double Tolerance
Definition: vtkAbstractImageInterpolator.h:319
vtkAbstractImageInterpolator::SetSlidingWindow
void SetSlidingWindow(bool x)
Enable sliding window for separable kernels.
vtkAbstractImageInterpolator::Initialize
virtual void Initialize(vtkDataObject *data)
Initialize the interpolator with the data that you wish to interpolate.
vtkAbstractImageInterpolator::CheckBoundsIJK
bool CheckBoundsIJK(const double x[3])
Check an x,y,z point to see if it is within the bounds for the structured coords of the image.
Definition: vtkAbstractImageInterpolator.h:353
vtkAbstractImageInterpolator::SlidingWindowOn
void SlidingWindowOn()
Definition: vtkAbstractImageInterpolator.h:178
vtkAbstractImageInterpolator::PrecomputeWeightsForExtent
virtual void PrecomputeWeightsForExtent(const double matrix[16], const int extent[6], int checkExtent[6], vtkInterpolationWeights *&weights)
If the data is going to be sampled on a regular grid, then the interpolation weights can be precomput...
vtkAbstractImageInterpolator::SetBorderModeToMirror
void SetBorderModeToMirror()
The border mode (default: clamp).
Definition: vtkAbstractImageInterpolator.h:165
vtkAbstractImageInterpolator::Interpolate
double Interpolate(double x, double y, double z, int component)
Get the result of interpolating the specified component of the input data, which should be set to zer...
vtkAbstractImageInterpolator::CoordinateToIJK
void CoordinateToIJK(const double point[3], double ijk[3])
Convert XYZ coordinate to IJK continuous index.
vtkAbstractImageInterpolator::BorderMode
vtkImageBorderMode BorderMode
Definition: vtkAbstractImageInterpolator.h:320
vtkAbstractImageInterpolator::GetSlidingWindow
bool GetSlidingWindow()
Definition: vtkAbstractImageInterpolator.h:180
vtkAbstractImageInterpolator::GetBorderMode
vtkImageBorderMode GetBorderMode()
The border mode (default: clamp).
Definition: vtkAbstractImageInterpolator.h:166
vtkAbstractImageInterpolator::InterpolateRow
void InterpolateRow(vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx, double *value, int n)
Get a row of samples, using the weights that were precomputed by PrecomputeWeightsForExtent.
Definition: vtkAbstractImageInterpolator.h:367
vtkAbstractImageInterpolator::SetOutValue
void SetOutValue(double outValue)
The value to return when the point is out of bounds.
vtkAbstractImageInterpolator::SlidingWindow
bool SlidingWindow
Definition: vtkAbstractImageInterpolator.h:324
vtkAbstractImageInterpolator::RowInterpolationFuncDouble
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:333
vtkAbstractImageInterpolator::InterpolationFuncFloat
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
Definition: vtkAbstractImageInterpolator.h:331
vtkAbstractImageInterpolator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractImageInterpolator::GetSlidingWindowFunc
virtual void GetSlidingWindowFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
Get the sliding window interpolation functions.
vtkAbstractImageInterpolator::GetNumberOfComponents
int GetNumberOfComponents()
Get the number of components that will be returned when Interpolate() is called.
vtkAbstractImageInterpolator::FreePrecomputedWeights
virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights)
Free the weights that were provided by PrecomputeWeightsForExtent.
vtkAbstractImageInterpolator::DeepCopy
void DeepCopy(vtkAbstractImageInterpolator *obj)
Copy the interpolator.
vtkAbstractImageInterpolator::GetRowInterpolationFunc
virtual void GetRowInterpolationFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
Get the row interpolation functions.
vtkAbstractImageInterpolator::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj)=0
Subclass-specific copy.
vtkAbstractImageInterpolator::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**doublefunc)(vtkInterpolationInfo *, const double[3], double *))
Get the interpolation functions.
vtkAbstractImageInterpolator::SetBorderModeToRepeat
void SetBorderModeToRepeat()
The border mode (default: clamp).
Definition: vtkAbstractImageInterpolator.h:164
vtkAbstractImageInterpolator::SlidingWindowOff
void SlidingWindowOff()
Definition: vtkAbstractImageInterpolator.h:179
vtkAbstractImageInterpolator::GetTolerance
double GetTolerance()
Definition: vtkAbstractImageInterpolator.h:100
vtkAbstractImageInterpolator::RowInterpolationFuncFloat
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:335
vtkAbstractImageInterpolator::InternalUpdate
virtual void InternalUpdate()=0
Subclass-specific updates.
vtkAbstractImageInterpolator::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**floatfunc)(vtkInterpolationInfo *, const float[3], float *))
Get the interpolation functions.
vtkAbstractImageInterpolator::InterpolateIJK
void InterpolateIJK(const double point[3], double *value)
A version of Interpolate that takes structured coords instead of data coords.
Definition: vtkAbstractImageInterpolator.h:343
vtkAbstractImageInterpolator::ComponentCount
int ComponentCount
Definition: vtkAbstractImageInterpolator.h:322
vtkAbstractImageInterpolator::Interpolate
bool Interpolate(const double point[3], double *value)
Sample the input data.
vtkAbstractImageInterpolator::ComponentOffset
int ComponentOffset
Definition: vtkAbstractImageInterpolator.h:321
vtkAbstractImageInterpolator::SetTolerance
void SetTolerance(double tol)
The tolerance to apply when checking whether a point is out of bounds.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::mode
@ mode
Definition: vtkX3D.h:247
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkX3D::extent
@ extent
Definition: vtkX3D.h:345
vtkX3D::offset
@ offset
Definition: vtkX3D.h:438
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkInterpolationInfo
Definition: vtkImageInterpolatorInternals.h:18
vtkInterpolationWeights
Definition: vtkImageInterpolatorInternals.h:34
vtkImageBorderMode
vtkImageBorderMode
Definition: vtkAbstractImageInterpolator.h:28
VTK_IMAGE_BORDER_REPEAT
@ VTK_IMAGE_BORDER_REPEAT
Definition: vtkAbstractImageInterpolator.h:30
VTK_IMAGE_BORDER_CLAMP
@ VTK_IMAGE_BORDER_CLAMP
Definition: vtkAbstractImageInterpolator.h:29
VTK_IMAGE_BORDER_MIRROR
@ VTK_IMAGE_BORDER_MIRROR
Definition: vtkAbstractImageInterpolator.h:31
vtkObject.h