VTK  9.0.1
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 =========================================================================*/
30 #ifndef vtkAbstractImageInterpolator_h
31 #define vtkAbstractImageInterpolator_h
32 
33 #include "vtkImagingCoreModule.h" // For export macro
34 #include "vtkObject.h"
35 
36 #define VTK_IMAGE_BORDER_CLAMP 0
37 #define VTK_IMAGE_BORDER_REPEAT 1
38 #define VTK_IMAGE_BORDER_MIRROR 2
39 
40 class vtkDataObject;
41 class vtkImageData;
42 class vtkDataArray;
45 
46 class VTKIMAGINGCORE_EXPORT vtkAbstractImageInterpolator : public vtkObject
47 {
48 public:
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
55  virtual void Initialize(vtkDataObject* data);
56 
60  virtual void ReleaseData();
61 
67 
73  void Update();
74 
82  double Interpolate(double x, double y, double z, int component);
83 
91  bool Interpolate(const double point[3], double* value);
92 
96  void SetOutValue(double outValue);
97  double GetOutValue() { return this->OutValue; }
98 
104  void SetTolerance(double tol);
105  double GetTolerance() { return this->Tolerance; }
106 
114  int GetComponentOffset() { return this->ComponentOffset; }
115 
122  void SetComponentCount(int count);
123  int GetComponentCount() { return this->ComponentCount; }
124 
129  int ComputeNumberOfComponents(int inputComponents);
130 
137 
139 
144  void InterpolateIJK(const double point[3], double* value);
145  void InterpolateIJK(const float point[3], float* value);
147 
149 
155  bool CheckBoundsIJK(const double x[3]);
156  bool CheckBoundsIJK(const float x[3]);
158 
160 
167  void SetBorderMode(int mode);
168  void SetBorderModeToClamp() { this->SetBorderMode(VTK_IMAGE_BORDER_CLAMP); }
169  void SetBorderModeToRepeat() { this->SetBorderMode(VTK_IMAGE_BORDER_REPEAT); }
170  void SetBorderModeToMirror() { this->SetBorderMode(VTK_IMAGE_BORDER_MIRROR); }
171  int GetBorderMode() { return this->BorderMode; }
172  const char* GetBorderModeAsString();
174 
182  void SetSlidingWindow(bool x);
183  void SlidingWindowOn() { this->SetSlidingWindow(true); }
184  void SlidingWindowOff() { this->SetSlidingWindow(false); }
185  bool GetSlidingWindow() { return this->SlidingWindow; }
186 
193  virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
194 
201  virtual bool IsSeparable() = 0;
202 
204 
214  virtual void PrecomputeWeightsForExtent(const double matrix[16], const int extent[6],
215  int checkExtent[6], vtkInterpolationWeights*& weights);
216  virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6],
217  int checkExtent[6], vtkInterpolationWeights*& weights);
219 
224 
226 
232  void InterpolateRow(
233  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n);
234  void InterpolateRow(
235  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n);
237 
239 
242  vtkGetVector3Macro(Spacing, double);
244 
246 
249  vtkGetVector3Macro(Origin, double);
251 
253 
256  vtkGetVector6Macro(Extent, int);
258 
260 
264  VTK_LEGACY(int* GetWholeExtent());
265  VTK_LEGACY(void GetWholeExtent(int extent[6]));
267 
268 protected:
271 
275  virtual void InternalUpdate() = 0;
276 
281 
283 
286  virtual void GetInterpolationFunc(
287  void (**doublefunc)(vtkInterpolationInfo*, const double[3], double*));
288  virtual void GetInterpolationFunc(
289  void (**floatfunc)(vtkInterpolationInfo*, const float[3], float*));
291 
293 
297  void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
299  void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
301 
303 
306  virtual void GetSlidingWindowFunc(
307  void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
308  virtual void GetSlidingWindowFunc(
309  void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
311 
313  double StructuredBoundsDouble[6];
314  float StructuredBoundsFloat[6];
315  int Extent[6];
316  double Spacing[3];
317  double Origin[3];
318  double OutValue;
319  double Tolerance;
324 
325  // information needed by the interpolator funcs
327 
328  void (*InterpolationFuncDouble)(
329  vtkInterpolationInfo* info, const double point[3], double* outPtr);
330  void (*InterpolationFuncFloat)(vtkInterpolationInfo* info, const float point[3], float* outPtr);
331 
332  void (*RowInterpolationFuncDouble)(
333  vtkInterpolationWeights* weights, int idX, int idY, int idZ, double* outPtr, int n);
334  void (*RowInterpolationFuncFloat)(
335  vtkInterpolationWeights* weights, int idX, int idY, int idZ, float* outPtr, int n);
336 
337 private:
339  void operator=(const vtkAbstractImageInterpolator&) = delete;
340 };
341 
342 inline void vtkAbstractImageInterpolator::InterpolateIJK(const double point[3], double* value)
343 {
344  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
345 }
346 
347 inline void vtkAbstractImageInterpolator::InterpolateIJK(const float point[3], float* value)
348 {
349  this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
350 }
351 
352 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
353 {
354  const double* bounds = this->StructuredBoundsDouble;
355  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
356  (x[2] < bounds[4]) || (x[2] > bounds[5]));
357 }
358 
359 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
360 {
361  const float* bounds = this->StructuredBoundsFloat;
362  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
363  (x[2] < bounds[4]) || (x[2] > bounds[5]));
364 }
365 
367  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n)
368 {
369  this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
370 }
371 
373  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n)
374 {
375  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
376 }
377 
378 #endif
vtkAbstractImageInterpolator::GetSlidingWindowFunc
virtual void GetSlidingWindowFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
Get the sliding window interpolation functions.
vtkAbstractImageInterpolator::BorderMode
int BorderMode
Definition: vtkAbstractImageInterpolator.h:320
vtkAbstractImageInterpolator::FreePrecomputedWeights
virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights)
Free the weights that were provided by PrecomputeWeightsForExtent.
vtkAbstractImageInterpolator::GetSlidingWindow
bool GetSlidingWindow()
Definition: vtkAbstractImageInterpolator.h:185
vtkAbstractImageInterpolator::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**floatfunc)(vtkInterpolationInfo *, const float[3], float *))
vtkAbstractImageInterpolator::ComponentCount
int ComponentCount
Definition: vtkAbstractImageInterpolator.h:322
vtkAbstractImageInterpolator::SetComponentCount
void SetComponentCount(int count)
This method specifies the number of components to extract.
vtkX3D::component
@ component
Definition: vtkX3D.h:181
vtkAbstractImageInterpolator::GetRowInterpolationFunc
virtual void GetRowInterpolationFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
Get the row interpolation functions.
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.
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkAbstractImageInterpolator::vtkAbstractImageInterpolator
vtkAbstractImageInterpolator()
vtkAbstractImageInterpolator::GetTolerance
double GetTolerance()
Definition: vtkAbstractImageInterpolator.h:105
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkAbstractImageInterpolator::SetComponentOffset
void SetComponentOffset(int offset)
This method specifies which component of the input will be interpolated, or if ComponentCount is also...
vtkAbstractImageInterpolator::InterpolationFuncFloat
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
Definition: vtkAbstractImageInterpolator.h:330
vtkInterpolationInfo
Definition: vtkImageInterpolatorInternals.h:27
vtkAbstractImageInterpolator::InterpolationFuncDouble
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
Definition: vtkAbstractImageInterpolator.h:328
vtkAbstractImageInterpolator::SlidingWindowOn
void SlidingWindowOn()
Definition: vtkAbstractImageInterpolator.h:183
vtkAbstractImageInterpolator::ComputeNumberOfComponents
int ComputeNumberOfComponents(int inputComponents)
Compute the number of output components based on the ComponentOffset, ComponentCount,...
vtkAbstractImageInterpolator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
VTK_IMAGE_BORDER_MIRROR
#define VTK_IMAGE_BORDER_MIRROR
Definition: vtkAbstractImageInterpolator.h:38
vtkAbstractImageInterpolator::GetNumberOfComponents
int GetNumberOfComponents()
Get the number of components that will be returned when Interpolate() is called.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
vtkAbstractImageInterpolator::SlidingWindowOff
void SlidingWindowOff()
Definition: vtkAbstractImageInterpolator.h:184
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:352
vtkAbstractImageInterpolator::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj)=0
Subclass-specific copy.
vtkAbstractImageInterpolator::StructuredBoundsFloat
float StructuredBoundsFloat[6]
Definition: vtkAbstractImageInterpolator.h:314
vtkAbstractImageInterpolator::GetSlidingWindowFunc
virtual void GetSlidingWindowFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
vtkAbstractImageInterpolator::~vtkAbstractImageInterpolator
~vtkAbstractImageInterpolator() override
vtkAbstractImageInterpolator::OutValue
double OutValue
Definition: vtkAbstractImageInterpolator.h:318
vtkAbstractImageInterpolator::ReleaseData
virtual void ReleaseData()
Release any data stored by the interpolator.
vtkAbstractImageInterpolator::GetWholeExtent
void GetWholeExtent(int extent[6])
vtkAbstractImageInterpolator::DeepCopy
void DeepCopy(vtkAbstractImageInterpolator *obj)
Copy the interpolator.
vtkX3D::point
@ point
Definition: vtkX3D.h:242
VTK_IMAGE_BORDER_CLAMP
#define VTK_IMAGE_BORDER_CLAMP
Definition: vtkAbstractImageInterpolator.h:36
vtkX3D::offset
@ offset
Definition: vtkX3D.h:444
vtkAbstractImageInterpolator::GetComponentCount
int GetComponentCount()
Definition: vtkAbstractImageInterpolator.h:123
vtkAbstractImageInterpolator::SetBorderMode
void SetBorderMode(int mode)
The border mode (default: clamp).
vtkAbstractImageInterpolator::SetBorderModeToRepeat
void SetBorderModeToRepeat()
Definition: vtkAbstractImageInterpolator.h:169
vtkAbstractImageInterpolator::ComputeSupportSize
virtual void ComputeSupportSize(const double matrix[16], int support[3])=0
Get the support size for use in computing update extents.
vtkAbstractImageInterpolator::RowInterpolationFuncDouble
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:332
vtkAbstractImageInterpolator::Update
void Update()
Update the interpolator.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
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:342
vtkAbstractImageInterpolator::SetSlidingWindow
void SetSlidingWindow(bool x)
Enable sliding window for separable kernels.
vtkAbstractImageInterpolator::InternalUpdate
virtual void InternalUpdate()=0
Subclass-specific updates.
vtkAbstractImageInterpolator::Initialize
virtual void Initialize(vtkDataObject *data)
Initialize the interpolator with the data that you wish to interpolate.
vtkObject.h
VTK_IMAGE_BORDER_REPEAT
#define VTK_IMAGE_BORDER_REPEAT
Definition: vtkAbstractImageInterpolator.h:37
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:366
vtkAbstractImageInterpolator::Tolerance
double Tolerance
Definition: vtkAbstractImageInterpolator.h:319
vtkAbstractImageInterpolator::SetBorderModeToMirror
void SetBorderModeToMirror()
Definition: vtkAbstractImageInterpolator.h:170
vtkAbstractImageInterpolator::GetOutValue
double GetOutValue()
Definition: vtkAbstractImageInterpolator.h:97
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkAbstractImageInterpolator::SetBorderModeToClamp
void SetBorderModeToClamp()
Definition: vtkAbstractImageInterpolator.h:168
vtkAbstractImageInterpolator::GetWholeExtent
int * GetWholeExtent()
Get the whole extent of the data being interpolated, including parts of the data that are not current...
vtkAbstractImageInterpolator::Scalars
vtkDataArray * Scalars
Definition: vtkAbstractImageInterpolator.h:312
vtkAbstractImageInterpolator::Interpolate
bool Interpolate(const double point[3], double *value)
Sample the input data.
vtkAbstractImageInterpolator::PrecomputeWeightsForExtent
virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6], int checkExtent[6], vtkInterpolationWeights *&weights)
vtkInterpolationWeights
Definition: vtkImageInterpolatorInternals.h:40
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::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::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**doublefunc)(vtkInterpolationInfo *, const double[3], double *))
Get the interpolation functions.
vtkX3D::mode
@ mode
Definition: vtkX3D.h:253
vtkAbstractImageInterpolator::InterpolationInfo
vtkInterpolationInfo * InterpolationInfo
Definition: vtkAbstractImageInterpolator.h:326
vtkX3D::extent
@ extent
Definition: vtkX3D.h:351
vtkAbstractImageInterpolator::SlidingWindow
bool SlidingWindow
Definition: vtkAbstractImageInterpolator.h:323
vtkAbstractImageInterpolator::SetOutValue
void SetOutValue(double outValue)
The value to return when the point is out of bounds.
vtkAbstractImageInterpolator::GetComponentOffset
int GetComponentOffset()
Definition: vtkAbstractImageInterpolator.h:114
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:47
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:60
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::RowInterpolationFuncFloat
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:334
vtkAbstractImageInterpolator::StructuredBoundsDouble
double StructuredBoundsDouble[6]
Definition: vtkAbstractImageInterpolator.h:313
vtkAbstractImageInterpolator::GetRowInterpolationFunc
virtual void GetRowInterpolationFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
vtkAbstractImageInterpolator::GetBorderModeAsString
const char * GetBorderModeAsString()
vtkAbstractImageInterpolator::GetBorderMode
int GetBorderMode()
Definition: vtkAbstractImageInterpolator.h:171