VTK
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 =========================================================================*/
33 #ifndef vtkAbstractImageInterpolator_h
34 #define vtkAbstractImageInterpolator_h
35 
36 #include "vtkImagingCoreModule.h" // For export macro
37 #include "vtkObject.h"
38 
39 #define VTK_IMAGE_BORDER_CLAMP 0
40 #define VTK_IMAGE_BORDER_REPEAT 1
41 #define VTK_IMAGE_BORDER_MIRROR 2
42 
43 class vtkDataObject;
44 class vtkImageData;
45 class vtkDataArray;
48 
49 class VTKIMAGINGCORE_EXPORT vtkAbstractImageInterpolator : public vtkObject
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  virtual void Initialize(vtkDataObject *data);
59 
63  virtual void ReleaseData();
64 
70 
76  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 
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 
170  void SetBorderMode(int mode);
172  this->SetBorderMode(VTK_IMAGE_BORDER_CLAMP); }
174  this->SetBorderMode(VTK_IMAGE_BORDER_REPEAT); }
176  this->SetBorderMode(VTK_IMAGE_BORDER_MIRROR); }
177  int GetBorderMode() { return this->BorderMode; }
178  const char *GetBorderModeAsString();
180 
188  void SetSlidingWindow(bool x);
189  void SlidingWindowOn() { this->SetSlidingWindow(true); }
190  void SlidingWindowOff() { this->SetSlidingWindow(false); }
191  bool GetSlidingWindow() { return this->SlidingWindow; }
192 
199  virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
200 
207  virtual bool IsSeparable() = 0;
208 
210 
221  const double matrix[16], const int extent[6], int checkExtent[6],
222  vtkInterpolationWeights *&weights);
224  const float matrix[16], const int extent[6], int checkExtent[6],
225  vtkInterpolationWeights *&weights);
227 
232 
234 
240  void InterpolateRow(
241  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
242  double *value, int n);
243  void InterpolateRow(
244  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
245  float *value, int n);
247 
249 
252  vtkGetVector3Macro(Spacing, double);
254 
256 
259  vtkGetVector3Macro(Origin, double);
261 
263 
266  vtkGetVector6Macro(Extent, int);
268 
270 
274  VTK_LEGACY(int *GetWholeExtent());
275  VTK_LEGACY(void GetWholeExtent(int extent[6]));
277 
278 protected:
281 
285  virtual void InternalUpdate() = 0;
286 
291 
293 
296  virtual void GetInterpolationFunc(
297  void (**doublefunc)(
298  vtkInterpolationInfo *, const double [3], double *));
299  virtual void GetInterpolationFunc(
300  void (**floatfunc)(
301  vtkInterpolationInfo *, const float [3], float *));
303 
305 
309  void (**doublefunc)(
310  vtkInterpolationWeights *, int, int, int, double *, int));
312  void (**floatfunc)(
313  vtkInterpolationWeights *, int, int, int, float *, int));
315 
317 
320  virtual void GetSlidingWindowFunc(
321  void (**doublefunc)(
322  vtkInterpolationWeights *, int, int, int, double *, int));
323  virtual void GetSlidingWindowFunc(
324  void (**floatfunc)(
325  vtkInterpolationWeights *, int, int, int, float *, int));
327 
329  double StructuredBoundsDouble[6];
330  float StructuredBoundsFloat[6];
331  int Extent[6];
332  double Spacing[3];
333  double Origin[3];
334  double OutValue;
335  double Tolerance;
340 
341  // information needed by the interpolator funcs
343 
344  void (*InterpolationFuncDouble)(
345  vtkInterpolationInfo *info, const double point[3], double *outPtr);
346  void (*InterpolationFuncFloat)(
347  vtkInterpolationInfo *info, const float point[3], float *outPtr);
348 
349  void (*RowInterpolationFuncDouble)(
350  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
351  double *outPtr, int n);
352  void (*RowInterpolationFuncFloat)(
353  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
354  float *outPtr, int n);
355 
356 private:
357 
359  void operator=(const vtkAbstractImageInterpolator&) = delete;
360 };
361 
363  const double point[3], double *value)
364 {
365  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
366 }
367 
369  const float point[3], float *value)
370 {
371  this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
372 }
373 
374 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
375 {
376  const double *bounds = this->StructuredBoundsDouble;
377  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) ||
378  (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
379  (x[2] < bounds[4]) || (x[2] > bounds[5]));
380 }
381 
382 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
383 {
384  const float *bounds = this->StructuredBoundsFloat;
385  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) ||
386  (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
387  (x[2] < bounds[4]) || (x[2] > bounds[5]));
388 }
389 
391  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
392  double *value, int n)
393 {
394  this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
395 }
396 
398  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
399  float *value, int n)
400 {
401  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
402 }
403 
404 #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:336
vtkAbstractImageInterpolator::FreePrecomputedWeights
virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights)
Free the weights that were provided by PrecomputeWeightsForExtent.
vtkAbstractImageInterpolator::GetSlidingWindow
bool GetSlidingWindow()
Definition: vtkAbstractImageInterpolator.h:191
vtkAbstractImageInterpolator::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**floatfunc)(vtkInterpolationInfo *, const float[3], float *))
vtkAbstractImageInterpolator::ComponentCount
int ComponentCount
Definition: vtkAbstractImageInterpolator.h:338
vtkAbstractImageInterpolator::SetComponentCount
void SetComponentCount(int count)
This method specifies the number of components to extract.
vtkX3D::component
@ component
Definition: vtkX3D.h:175
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:337
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:220
vtkAbstractImageInterpolator::vtkAbstractImageInterpolator
vtkAbstractImageInterpolator()
vtkAbstractImageInterpolator::GetTolerance
double GetTolerance()
Definition: vtkAbstractImageInterpolator.h:108
vtkX3D::data
@ data
Definition: vtkX3D.h:315
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:346
vtkInterpolationInfo
Definition: vtkImageInterpolatorInternals.h:27
vtkAbstractImageInterpolator::InterpolationFuncDouble
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
Definition: vtkAbstractImageInterpolator.h:344
vtkAbstractImageInterpolator::SlidingWindowOn
void SlidingWindowOn()
Definition: vtkAbstractImageInterpolator.h:189
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:60
VTK_IMAGE_BORDER_MIRROR
#define VTK_IMAGE_BORDER_MIRROR
Definition: vtkAbstractImageInterpolator.h:41
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:55
vtkAbstractImageInterpolator::SlidingWindowOff
void SlidingWindowOff()
Definition: vtkAbstractImageInterpolator.h:190
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:374
vtkAbstractImageInterpolator::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj)=0
Subclass-specific copy.
vtkAbstractImageInterpolator::StructuredBoundsFloat
float StructuredBoundsFloat[6]
Definition: vtkAbstractImageInterpolator.h:330
vtkAbstractImageInterpolator::GetSlidingWindowFunc
virtual void GetSlidingWindowFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
vtkAbstractImageInterpolator::~vtkAbstractImageInterpolator
~vtkAbstractImageInterpolator() override
vtkAbstractImageInterpolator::OutValue
double OutValue
Definition: vtkAbstractImageInterpolator.h:334
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:236
VTK_IMAGE_BORDER_CLAMP
#define VTK_IMAGE_BORDER_CLAMP
Definition: vtkAbstractImageInterpolator.h:39
vtkX3D::offset
@ offset
Definition: vtkX3D.h:438
vtkAbstractImageInterpolator::GetComponentCount
int GetComponentCount()
Definition: vtkAbstractImageInterpolator.h:126
vtkAbstractImageInterpolator::SetBorderMode
void SetBorderMode(int mode)
The border mode (default: clamp).
vtkAbstractImageInterpolator::SetBorderModeToRepeat
void SetBorderModeToRepeat()
Definition: vtkAbstractImageInterpolator.h:173
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:349
vtkAbstractImageInterpolator::Update
void Update()
Update the interpolator.
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
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:362
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:40
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:390
vtkAbstractImageInterpolator::Tolerance
double Tolerance
Definition: vtkAbstractImageInterpolator.h:335
vtkAbstractImageInterpolator::SetBorderModeToMirror
void SetBorderModeToMirror()
Definition: vtkAbstractImageInterpolator.h:175
vtkAbstractImageInterpolator::GetOutValue
double GetOutValue()
Definition: vtkAbstractImageInterpolator.h:100
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkAbstractImageInterpolator::SetBorderModeToClamp
void SetBorderModeToClamp()
Definition: vtkAbstractImageInterpolator.h:171
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:328
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:247
vtkAbstractImageInterpolator::InterpolationInfo
vtkInterpolationInfo * InterpolationInfo
Definition: vtkAbstractImageInterpolator.h:342
vtkX3D::extent
@ extent
Definition: vtkX3D.h:345
vtkAbstractImageInterpolator::SlidingWindow
bool SlidingWindow
Definition: vtkAbstractImageInterpolator.h:339
vtkAbstractImageInterpolator::SetOutValue
void SetOutValue(double outValue)
The value to return when the point is out of bounds.
vtkAbstractImageInterpolator::GetComponentOffset
int GetComponentOffset()
Definition: vtkAbstractImageInterpolator.h:117
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:50
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:65
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:352
vtkAbstractImageInterpolator::StructuredBoundsDouble
double StructuredBoundsDouble[6]
Definition: vtkAbstractImageInterpolator.h:329
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:177