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 =========================================================================*/
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 
66  void DeepCopy(vtkAbstractImageInterpolator *obj);
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 
113  void SetComponentOffset(int offset);
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 
136  int GetNumberOfComponents();
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);
169  this->SetBorderMode(VTK_IMAGE_BORDER_CLAMP); }
171  this->SetBorderMode(VTK_IMAGE_BORDER_REPEAT); }
173  this->SetBorderMode(VTK_IMAGE_BORDER_MIRROR); }
174  int GetBorderMode() { return this->BorderMode; }
175  const char *GetBorderModeAsString();
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(
218  const double matrix[16], const int extent[6], int checkExtent[6],
219  vtkInterpolationWeights *&weights);
220  virtual void PrecomputeWeightsForExtent(
221  const float matrix[16], const int extent[6], int checkExtent[6],
222  vtkInterpolationWeights *&weights);
224 
228  virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights);
229 
231 
237  void InterpolateRow(
238  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
239  double *value, int n);
240  void InterpolateRow(
241  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
242  float *value, int n);
244 
246 
249  vtkGetVector3Macro(Spacing, double);
251 
253 
256  vtkGetVector3Macro(Origin, double);
258 
260 
263  vtkGetVector6Macro(Extent, int);
265 
267 
271  VTK_LEGACY(int *GetWholeExtent());
272  VTK_LEGACY(void GetWholeExtent(int extent[6]));
274 
275 protected:
277  ~vtkAbstractImageInterpolator() override;
278 
282  virtual void InternalUpdate() = 0;
283 
287  virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj) = 0;
288 
290 
293  virtual void GetInterpolationFunc(
294  void (**doublefunc)(
295  vtkInterpolationInfo *, const double [3], double *));
296  virtual void GetInterpolationFunc(
297  void (**floatfunc)(
298  vtkInterpolationInfo *, const float [3], float *));
300 
302 
305  virtual void GetRowInterpolationFunc(
306  void (**doublefunc)(
307  vtkInterpolationWeights *, int, int, int, double *, int));
308  virtual void GetRowInterpolationFunc(
309  void (**floatfunc)(
310  vtkInterpolationWeights *, int, int, int, float *, int));
312 
314 
317  virtual void GetSlidingWindowFunc(
318  void (**doublefunc)(
319  vtkInterpolationWeights *, int, int, int, double *, int));
320  virtual void GetSlidingWindowFunc(
321  void (**floatfunc)(
322  vtkInterpolationWeights *, int, int, int, float *, int));
324 
326  double StructuredBoundsDouble[6];
327  float StructuredBoundsFloat[6];
328  int Extent[6];
329  double Spacing[3];
330  double Origin[3];
331  double OutValue;
332  double Tolerance;
337 
338  // information needed by the interpolator funcs
340 
341  void (*InterpolationFuncDouble)(
342  vtkInterpolationInfo *info, const double point[3], double *outPtr);
343  void (*InterpolationFuncFloat)(
344  vtkInterpolationInfo *info, const float point[3], float *outPtr);
345 
346  void (*RowInterpolationFuncDouble)(
347  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
348  double *outPtr, int n);
349  void (*RowInterpolationFuncFloat)(
350  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
351  float *outPtr, int n);
352 
353 private:
354 
356  void operator=(const vtkAbstractImageInterpolator&) = delete;
357 };
358 
360  const double point[3], double *value)
361 {
362  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
363 }
364 
366  const float point[3], float *value)
367 {
368  this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
369 }
370 
371 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
372 {
373  const double *bounds = this->StructuredBoundsDouble;
374  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) ||
375  (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
376  (x[2] < bounds[4]) || (x[2] > bounds[5]));
377 }
378 
379 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
380 {
381  const float *bounds = this->StructuredBoundsFloat;
382  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) ||
383  (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
384  (x[2] < bounds[4]) || (x[2] > bounds[5]));
385 }
386 
388  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
389  double *value, int n)
390 {
391  this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
392 }
393 
395  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
396  float *value, int n)
397 {
398  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
399 }
400 
401 #endif
vtkAbstractImageInterpolator::BorderMode
int BorderMode
Definition: vtkAbstractImageInterpolator.h:333
vtkAbstractImageInterpolator::GetSlidingWindow
bool GetSlidingWindow()
Definition: vtkAbstractImageInterpolator.h:188
vtkAbstractImageInterpolator::ComponentCount
int ComponentCount
Definition: vtkAbstractImageInterpolator.h:335
vtkX3D::component
Definition: vtkX3D.h:175
vtkAbstractImageInterpolator::ComponentOffset
int ComponentOffset
Definition: vtkAbstractImageInterpolator.h:334
vtkX3D::value
Definition: vtkX3D.h:220
vtkAbstractImageInterpolator::GetTolerance
double GetTolerance()
Definition: vtkAbstractImageInterpolator.h:105
vtkX3D::data
Definition: vtkX3D.h:315
vtkAbstractImageInterpolator::InterpolationFuncFloat
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
Definition: vtkAbstractImageInterpolator.h:343
vtkInterpolationInfo
Definition: vtkImageInterpolatorInternals.h:26
vtkAbstractImageInterpolator::InterpolationFuncDouble
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
Definition: vtkAbstractImageInterpolator.h:341
vtkAbstractImageInterpolator::SlidingWindowOn
void SlidingWindowOn()
Definition: vtkAbstractImageInterpolator.h:186
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
VTK_IMAGE_BORDER_MIRROR
#define VTK_IMAGE_BORDER_MIRROR
Definition: vtkAbstractImageInterpolator.h:38
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkAbstractImageInterpolator::SlidingWindowOff
void SlidingWindowOff()
Definition: vtkAbstractImageInterpolator.h:187
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:371
vtkAbstractImageInterpolator::StructuredBoundsFloat
float StructuredBoundsFloat[6]
Definition: vtkAbstractImageInterpolator.h:327
vtkAbstractImageInterpolator::OutValue
double OutValue
Definition: vtkAbstractImageInterpolator.h:331
vtkX3D::point
Definition: vtkX3D.h:236
VTK_IMAGE_BORDER_CLAMP
#define VTK_IMAGE_BORDER_CLAMP
Definition: vtkAbstractImageInterpolator.h:36
vtkX3D::offset
Definition: vtkX3D.h:438
vtkAbstractImageInterpolator::GetComponentCount
int GetComponentCount()
Definition: vtkAbstractImageInterpolator.h:123
vtkAbstractImageInterpolator::SetBorderModeToRepeat
void SetBorderModeToRepeat()
Definition: vtkAbstractImageInterpolator.h:170
vtkAbstractImageInterpolator::RowInterpolationFuncDouble
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:346
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
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:359
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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:387
vtkAbstractImageInterpolator::Tolerance
double Tolerance
Definition: vtkAbstractImageInterpolator.h:332
vtkAbstractImageInterpolator::SetBorderModeToMirror
void SetBorderModeToMirror()
Definition: vtkAbstractImageInterpolator.h:172
vtkAbstractImageInterpolator::GetOutValue
double GetOutValue()
Definition: vtkAbstractImageInterpolator.h:97
vtkX3D::info
Definition: vtkX3D.h:376
vtkAbstractImageInterpolator::SetBorderModeToClamp
void SetBorderModeToClamp()
Definition: vtkAbstractImageInterpolator.h:168
vtkAbstractImageInterpolator::Scalars
vtkDataArray * Scalars
Definition: vtkAbstractImageInterpolator.h:325
vtkInterpolationWeights
Definition: vtkImageInterpolatorInternals.h:39
vtkX3D::mode
Definition: vtkX3D.h:247
vtkAbstractImageInterpolator::InterpolationInfo
vtkInterpolationInfo * InterpolationInfo
Definition: vtkAbstractImageInterpolator.h:339
vtkX3D::extent
Definition: vtkX3D.h:345
vtkAbstractImageInterpolator::SlidingWindow
bool SlidingWindow
Definition: vtkAbstractImageInterpolator.h:336
vtkAbstractImageInterpolator::GetComponentOffset
int GetComponentOffset()
Definition: vtkAbstractImageInterpolator.h:114
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:46
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkAbstractImageInterpolator::RowInterpolationFuncFloat
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:349
vtkAbstractImageInterpolator::StructuredBoundsDouble
double StructuredBoundsDouble[6]
Definition: vtkAbstractImageInterpolator.h:326
vtkAbstractImageInterpolator::GetBorderMode
int GetBorderMode()
Definition: vtkAbstractImageInterpolator.h:174