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) VTK_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 
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 
139  int GetNumberOfComponents();
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 
187  virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
188 
195  virtual bool IsSeparable() = 0;
196 
198 
208  virtual void PrecomputeWeightsForExtent(
209  const double matrix[16], const int extent[6], int checkExtent[6],
210  vtkInterpolationWeights *&weights);
211  virtual void PrecomputeWeightsForExtent(
212  const float matrix[16], const int extent[6], int checkExtent[6],
213  vtkInterpolationWeights *&weights);
215 
219  virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights);
220 
222 
228  void InterpolateRow(
229  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
230  double *value, int n);
231  void InterpolateRow(
232  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
233  float *value, int n);
235 
237 
240  vtkGetVector3Macro(Spacing, double);
242 
244 
247  vtkGetVector3Macro(Origin, double);
249 
251 
254  vtkGetVector6Macro(Extent, int);
256 
258 
262  VTK_LEGACY(int *GetWholeExtent());
263  VTK_LEGACY(void GetWholeExtent(int extent[6]));
265 
266 protected:
269 
273  virtual void InternalUpdate() = 0;
274 
278  virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj) = 0;
279 
281 
284  virtual void GetInterpolationFunc(
285  void (**doublefunc)(
286  vtkInterpolationInfo *, const double [3], double *));
287  virtual void GetInterpolationFunc(
288  void (**floatfunc)(
289  vtkInterpolationInfo *, const float [3], float *));
291 
293 
296  virtual void GetRowInterpolationFunc(
297  void (**doublefunc)(
298  vtkInterpolationWeights *, int, int, int, double *, int));
299  virtual void GetRowInterpolationFunc(
300  void (**floatfunc)(
301  vtkInterpolationWeights *, int, int, int, float *, int));
303 
305  double StructuredBoundsDouble[6];
306  float StructuredBoundsFloat[6];
307  int Extent[6];
308  double Spacing[3];
309  double Origin[3];
310  double OutValue;
311  double Tolerance;
315 
316  // information needed by the interpolator funcs
318 
319  void (*InterpolationFuncDouble)(
320  vtkInterpolationInfo *info, const double point[3], double *outPtr);
321  void (*InterpolationFuncFloat)(
322  vtkInterpolationInfo *info, const float point[3], float *outPtr);
323 
324  void (*RowInterpolationFuncDouble)(
325  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
326  double *outPtr, int n);
327  void (*RowInterpolationFuncFloat)(
328  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
329  float *outPtr, int n);
330 
331 private:
332 
334  void operator=(const vtkAbstractImageInterpolator&) VTK_DELETE_FUNCTION;
335 };
336 
338  const double point[3], double *value)
339 {
340  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
341 }
342 
344  const float point[3], float *value)
345 {
346  this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
347 }
348 
349 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
350 {
351  double *bounds = this->StructuredBoundsDouble;
352  return !((x[0] < bounds[0]) | (x[0] > bounds[1]) |
353  (x[1] < bounds[2]) | (x[1] > bounds[3]) |
354  (x[2] < bounds[4]) | (x[2] > bounds[5]));
355 }
356 
357 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
358 {
359  float *bounds = this->StructuredBoundsFloat;
360  return !((x[0] < bounds[0]) | (x[0] > bounds[1]) |
361  (x[1] < bounds[2]) | (x[1] > bounds[3]) |
362  (x[2] < bounds[4]) | (x[2] > bounds[5]));
363 }
364 
366  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
367  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,
374  float *value, int n)
375 {
376  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
377 }
378 
379 #endif
vtkpiston::DeepCopy
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkAbstractImageInterpolator::BorderMode
int BorderMode
Definition: vtkAbstractImageInterpolator.h:312
vtkAbstractImageInterpolator::ComponentCount
int ComponentCount
Definition: vtkAbstractImageInterpolator.h:314
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkAbstractImageInterpolator::ComponentOffset
int ComponentOffset
Definition: vtkAbstractImageInterpolator.h:313
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkAbstractImageInterpolator::GetTolerance
double GetTolerance()
Definition: vtkAbstractImageInterpolator.h:108
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkAbstractImageInterpolator::InterpolationFuncFloat
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
Definition: vtkAbstractImageInterpolator.h:321
vtkInterpolationInfo
Definition: vtkImageInterpolatorInternals.h:26
vtkAbstractImageInterpolator::InterpolationFuncDouble
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
Definition: vtkAbstractImageInterpolator.h:319
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
VTK_IMAGE_BORDER_MIRROR
#define VTK_IMAGE_BORDER_MIRROR
Definition: vtkAbstractImageInterpolator.h:41
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
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:349
vtkAbstractImageInterpolator::StructuredBoundsFloat
float StructuredBoundsFloat[6]
Definition: vtkAbstractImageInterpolator.h:306
vtkAbstractImageInterpolator::OutValue
double OutValue
Definition: vtkAbstractImageInterpolator.h:310
vtkX3D::point
@ point
Definition: vtkX3D.h:236
Update
virtual void Update()
Updates the extensions string.
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::SetBorderModeToRepeat
void SetBorderModeToRepeat()
Definition: vtkAbstractImageInterpolator.h:173
vtkAbstractImageInterpolator::RowInterpolationFuncDouble
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:324
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
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:337
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: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:365
vtkAbstractImageInterpolator::Tolerance
double Tolerance
Definition: vtkAbstractImageInterpolator.h:311
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::Scalars
vtkDataArray * Scalars
Definition: vtkAbstractImageInterpolator.h:304
vtkInterpolationWeights
Definition: vtkImageInterpolatorInternals.h:39
vtkX3D::mode
@ mode
Definition: vtkX3D.h:247
vtkAbstractImageInterpolator::InterpolationInfo
vtkInterpolationInfo * InterpolationInfo
Definition: vtkAbstractImageInterpolator.h:317
vtkX3D::extent
@ extent
Definition: vtkX3D.h:345
vtkAbstractImageInterpolator::GetComponentOffset
int GetComponentOffset()
Definition: vtkAbstractImageInterpolator.h:117
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:49
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkAbstractImageInterpolator::RowInterpolationFuncFloat
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:327
vtkAbstractImageInterpolator::StructuredBoundsDouble
double StructuredBoundsDouble[6]
Definition: vtkAbstractImageInterpolator.h:305
vtkAbstractImageInterpolator::GetBorderMode
int GetBorderMode()
Definition: vtkAbstractImageInterpolator.h:177