VTK  9.2.6
vtkAbstractImageInterpolator.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAbstractImageInterpolator.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=========================================================================*/
29
30#ifndef vtkAbstractImageInterpolator_h
31#define vtkAbstractImageInterpolator_h
32
33#include "vtkImagingCoreModule.h" // For export macro
34#include "vtkObject.h"
35
42
43class vtkDataObject;
44class vtkImageData;
45class vtkDataArray;
48
49class VTKIMAGINGCORE_EXPORT vtkAbstractImageInterpolator : public vtkObject
50{
51public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
58 virtual void Initialize(vtkDataObject* data);
59
63 virtual void ReleaseData();
64
70
76 virtual void Update();
77
85 double Interpolate(double x, double y, double z, int component);
86
94 bool Interpolate(const double point[3], double* value);
95
99 void SetOutValue(double outValue);
100 double GetOutValue() { return this->OutValue; }
101
107 void SetTolerance(double tol);
108 double GetTolerance() { return this->Tolerance; }
109
116 void SetComponentOffset(int offset);
117 int GetComponentOffset() { return this->ComponentOffset; }
118
125 void SetComponentCount(int count);
126 int GetComponentCount() { return this->ComponentCount; }
127
132 int ComputeNumberOfComponents(int inputComponents);
133
140
142
147 void InterpolateIJK(const double point[3], double* value);
148 void InterpolateIJK(const float point[3], float* value);
150
152
158 bool CheckBoundsIJK(const double x[3]);
159 bool CheckBoundsIJK(const float x[3]);
161
163
177
185 void SetSlidingWindow(bool x);
186 void SlidingWindowOn() { this->SetSlidingWindow(true); }
187 void SlidingWindowOff() { this->SetSlidingWindow(false); }
188 bool GetSlidingWindow() { return this->SlidingWindow; }
189
196 virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
197
204 virtual bool IsSeparable() = 0;
205
207
217 virtual void PrecomputeWeightsForExtent(const double matrix[16], const int extent[6],
218 int checkExtent[6], vtkInterpolationWeights*& weights);
219 virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6],
220 int checkExtent[6], vtkInterpolationWeights*& weights);
222
227
229
235 void InterpolateRow(
236 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n);
237 void InterpolateRow(
238 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n);
240
242
245 vtkGetVector3Macro(Spacing, double);
247
249
252 vtkGetVector3Macro(Origin, double);
254
256
259 vtkGetVector6Macro(Extent, int);
261
262protected:
265
269 virtual void InternalUpdate() = 0;
270
275
277
281 void (**doublefunc)(vtkInterpolationInfo*, const double[3], double*));
283 void (**floatfunc)(vtkInterpolationInfo*, const float[3], float*));
285
287
291 void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
293 void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
295
297
301 void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
303 void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
305
309 int Extent[6];
310 double Spacing[3];
311 double Origin[3];
312 double OutValue;
313 double Tolerance;
318
319 // information needed by the interpolator funcs
321
323 vtkInterpolationInfo* info, const double point[3], double* outPtr);
324 void (*InterpolationFuncFloat)(vtkInterpolationInfo* info, const float point[3], float* outPtr);
325
327 vtkInterpolationWeights* weights, int idX, int idY, int idZ, double* outPtr, int n);
329 vtkInterpolationWeights* weights, int idX, int idY, int idZ, float* outPtr, int n);
330
331private:
333 void operator=(const vtkAbstractImageInterpolator&) = delete;
334};
335
336inline void vtkAbstractImageInterpolator::InterpolateIJK(const double point[3], double* value)
337{
338 this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
339}
340
341inline void vtkAbstractImageInterpolator::InterpolateIJK(const float point[3], float* value)
342{
343 this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
344}
345
347{
348 const double* bounds = this->StructuredBoundsDouble;
349 return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
350 (x[2] < bounds[4]) || (x[2] > bounds[5]));
351}
352
354{
355 const float* bounds = this->StructuredBoundsFloat;
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
361 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n)
362{
363 this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
364}
365
367 vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n)
368{
369 this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
370}
371
372#endif
virtual void Update()
Update the interpolator.
void SetBorderMode(vtkImageBorderMode mode)
The border mode (default: clamp).
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...
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
virtual void ComputeSupportSize(const double matrix[16], int support[3])=0
Get the support size for use in computing update extents.
virtual bool IsSeparable()=0
True if the interpolation is separable, which means that the weights can be precomputed in order to a...
void SetBorderModeToClamp()
The border mode (default: clamp).
~vtkAbstractImageInterpolator() override
int ComputeNumberOfComponents(int inputComponents)
Compute the number of output components based on the ComponentOffset, ComponentCount,...
void SetComponentCount(int count)
This method specifies the number of components to extract.
virtual void GetRowInterpolationFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
Get the row interpolation functions.
virtual void GetSlidingWindowFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
Get the sliding window interpolation functions.
void SetComponentOffset(int offset)
This method specifies which component of the input will be interpolated, or if ComponentCount is also...
virtual void ReleaseData()
Release any data stored by the interpolator.
void SetSlidingWindow(bool x)
Enable sliding window for separable kernels.
virtual void Initialize(vtkDataObject *data)
Initialize the interpolator with the data that you wish to interpolate.
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.
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...
void SetBorderModeToMirror()
The border mode (default: clamp).
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...
vtkImageBorderMode GetBorderMode()
The border mode (default: clamp).
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.
void SetOutValue(double outValue)
The value to return when the point is out of bounds.
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void GetSlidingWindowFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
Get the sliding window interpolation functions.
int GetNumberOfComponents()
Get the number of components that will be returned when Interpolate() is called.
virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights)
Free the weights that were provided by PrecomputeWeightsForExtent.
void DeepCopy(vtkAbstractImageInterpolator *obj)
Copy the interpolator.
virtual void GetRowInterpolationFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
Get the row interpolation functions.
virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj)=0
Subclass-specific copy.
virtual void GetInterpolationFunc(void(**doublefunc)(vtkInterpolationInfo *, const double[3], double *))
Get the interpolation functions.
void SetBorderModeToRepeat()
The border mode (default: clamp).
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
virtual void InternalUpdate()=0
Subclass-specific updates.
virtual void GetInterpolationFunc(void(**floatfunc)(vtkInterpolationInfo *, const float[3], float *))
Get the interpolation functions.
void InterpolateIJK(const double point[3], double *value)
A version of Interpolate that takes structured coords instead of data coords.
const char * GetBorderModeAsString()
The border mode (default: clamp).
bool Interpolate(const double point[3], double *value)
Sample the input data.
void SetTolerance(double tol)
The tolerance to apply when checking whether a point is out of bounds.
general representation of visualization data
topologically and geometrically regular array of data
a simple class to control print indentation
Definition vtkIndent.h:34
#define vtkDataArray