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) VTK_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 
184  virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
185 
192  virtual bool IsSeparable() = 0;
193 
195 
205  virtual void PrecomputeWeightsForExtent(
206  const double matrix[16], const int extent[6], int checkExtent[6],
207  vtkInterpolationWeights *&weights);
208  virtual void PrecomputeWeightsForExtent(
209  const float matrix[16], const int extent[6], int checkExtent[6],
210  vtkInterpolationWeights *&weights);
212 
216  virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights);
217 
219 
225  void InterpolateRow(
226  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
227  double *value, int n);
228  void InterpolateRow(
229  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
230  float *value, int n);
232 
234 
237  vtkGetVector3Macro(Spacing, double);
239 
241 
244  vtkGetVector3Macro(Origin, double);
246 
248 
251  vtkGetVector6Macro(Extent, int);
253 
255 
259  VTK_LEGACY(int *GetWholeExtent());
260  VTK_LEGACY(void GetWholeExtent(int extent[6]));
262 
263 protected:
265  ~vtkAbstractImageInterpolator() VTK_OVERRIDE;
266 
270  virtual void InternalUpdate() = 0;
271 
275  virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj) = 0;
276 
278 
281  virtual void GetInterpolationFunc(
282  void (**doublefunc)(
283  vtkInterpolationInfo *, const double [3], double *));
284  virtual void GetInterpolationFunc(
285  void (**floatfunc)(
286  vtkInterpolationInfo *, const float [3], float *));
288 
290 
293  virtual void GetRowInterpolationFunc(
294  void (**doublefunc)(
295  vtkInterpolationWeights *, int, int, int, double *, int));
296  virtual void GetRowInterpolationFunc(
297  void (**floatfunc)(
298  vtkInterpolationWeights *, int, int, int, float *, int));
300 
302  double StructuredBoundsDouble[6];
303  float StructuredBoundsFloat[6];
304  int Extent[6];
305  double Spacing[3];
306  double Origin[3];
307  double OutValue;
308  double Tolerance;
312 
313  // information needed by the interpolator funcs
315 
316  void (*InterpolationFuncDouble)(
317  vtkInterpolationInfo *info, const double point[3], double *outPtr);
318  void (*InterpolationFuncFloat)(
319  vtkInterpolationInfo *info, const float point[3], float *outPtr);
320 
321  void (*RowInterpolationFuncDouble)(
322  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
323  double *outPtr, int n);
324  void (*RowInterpolationFuncFloat)(
325  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
326  float *outPtr, int n);
327 
328 private:
329 
331  void operator=(const vtkAbstractImageInterpolator&) VTK_DELETE_FUNCTION;
332 };
333 
335  const double point[3], double *value)
336 {
337  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
338 }
339 
341  const float point[3], float *value)
342 {
343  this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
344 }
345 
346 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
347 {
348  const double *bounds = this->StructuredBoundsDouble;
349  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) ||
350  (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
351  (x[2] < bounds[4]) || (x[2] > bounds[5]));
352 }
353 
354 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
355 {
356  const float *bounds = this->StructuredBoundsFloat;
357  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) ||
358  (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
359  (x[2] < bounds[4]) || (x[2] > bounds[5]));
360 }
361 
363  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
364  double *value, int n)
365 {
366  this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
367 }
368 
370  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
371  float *value, int n)
372 {
373  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
374 }
375 
376 #endif
interpolate data values from images
abstract base class for most VTK objects
Definition: vtkObject.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetBorderModeToRepeat()
The border mode (default: clamp).
virtual void Update()
Updates the extensions string.
#define VTK_IMAGE_BORDER_REPEAT
#define VTK_IMAGE_BORDER_CLAMP
void InterpolateIJK(const double point[3], double *value)
A version of Interpolate that takes structured coords instead of data coords.
a simple class to control print indentation
Definition: vtkIndent.h:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
int GetBorderMode()
The border mode (default: clamp).
#define VTK_IMAGE_BORDER_MIRROR
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...
general representation of visualization data
Definition: vtkDataObject.h:58
void SetBorderModeToClamp()
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 SetBorderModeToMirror()
The border mode (default: clamp).