VTK  9.2.6
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 
40 {
44 };
45 
46 class vtkDataObject;
47 class vtkImageData;
48 class vtkDataArray;
51 
52 class VTKIMAGINGCORE_EXPORT vtkAbstractImageInterpolator : public vtkObject
53 {
54 public:
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
61  virtual void Initialize(vtkDataObject* data);
62 
66  virtual void ReleaseData();
67 
72  void DeepCopy(vtkAbstractImageInterpolator* obj);
73 
79  virtual void Update();
80 
88  double Interpolate(double x, double y, double z, int component);
89 
97  bool Interpolate(const double point[3], double* value);
98 
102  void SetOutValue(double outValue);
103  double GetOutValue() { return this->OutValue; }
104 
110  void SetTolerance(double tol);
111  double GetTolerance() { return this->Tolerance; }
112 
119  void SetComponentOffset(int offset);
120  int GetComponentOffset() { return this->ComponentOffset; }
121 
128  void SetComponentCount(int count);
129  int GetComponentCount() { return this->ComponentCount; }
130 
135  int ComputeNumberOfComponents(int inputComponents);
136 
142  int GetNumberOfComponents();
143 
145 
150  void InterpolateIJK(const double point[3], double* value);
151  void InterpolateIJK(const float point[3], float* value);
153 
155 
161  bool CheckBoundsIJK(const double x[3]);
162  bool CheckBoundsIJK(const float x[3]);
164 
166 
173  void SetBorderMode(vtkImageBorderMode mode);
174  void SetBorderModeToClamp() { this->SetBorderMode(VTK_IMAGE_BORDER_CLAMP); }
175  void SetBorderModeToRepeat() { this->SetBorderMode(VTK_IMAGE_BORDER_REPEAT); }
176  void SetBorderModeToMirror() { this->SetBorderMode(VTK_IMAGE_BORDER_MIRROR); }
177  vtkImageBorderMode 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 
220  virtual void PrecomputeWeightsForExtent(const double matrix[16], const int extent[6],
221  int checkExtent[6], vtkInterpolationWeights*& weights);
222  virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6],
223  int checkExtent[6], vtkInterpolationWeights*& weights);
225 
229  virtual void FreePrecomputedWeights(vtkInterpolationWeights*& weights);
230 
232 
238  void InterpolateRow(
239  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, double* value, int n);
240  void InterpolateRow(
241  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, float* value, int n);
243 
245 
248  vtkGetVector3Macro(Spacing, double);
250 
252 
255  vtkGetVector3Macro(Origin, double);
257 
259 
262  vtkGetVector6Macro(Extent, int);
264 
265 protected:
267  ~vtkAbstractImageInterpolator() override;
268 
272  virtual void InternalUpdate() = 0;
273 
277  virtual void InternalDeepCopy(vtkAbstractImageInterpolator* obj) = 0;
278 
280 
283  virtual void GetInterpolationFunc(
284  void (**doublefunc)(vtkInterpolationInfo*, const double[3], double*));
285  virtual void GetInterpolationFunc(
286  void (**floatfunc)(vtkInterpolationInfo*, const float[3], float*));
288 
290 
293  virtual void GetRowInterpolationFunc(
294  void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
295  virtual void GetRowInterpolationFunc(
296  void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
298 
300 
303  virtual void GetSlidingWindowFunc(
304  void (**doublefunc)(vtkInterpolationWeights*, int, int, int, double*, int));
305  virtual void GetSlidingWindowFunc(
306  void (**floatfunc)(vtkInterpolationWeights*, int, int, int, float*, int));
308 
310  double StructuredBoundsDouble[6];
311  float StructuredBoundsFloat[6];
312  int Extent[6];
313  double Spacing[3];
314  double Origin[3];
315  double OutValue;
316  double Tolerance;
321 
322  // information needed by the interpolator funcs
324 
325  void (*InterpolationFuncDouble)(
326  vtkInterpolationInfo* info, const double point[3], double* outPtr);
327  void (*InterpolationFuncFloat)(vtkInterpolationInfo* info, const float point[3], float* outPtr);
328 
329  void (*RowInterpolationFuncDouble)(
330  vtkInterpolationWeights* weights, int idX, int idY, int idZ, double* outPtr, int n);
331  void (*RowInterpolationFuncFloat)(
332  vtkInterpolationWeights* weights, int idX, int idY, int idZ, float* outPtr, int n);
333 
334 private:
336  void operator=(const vtkAbstractImageInterpolator&) = delete;
337 };
338 
339 inline void vtkAbstractImageInterpolator::InterpolateIJK(const double point[3], double* value)
340 {
341  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
342 }
343 
344 inline void vtkAbstractImageInterpolator::InterpolateIJK(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  const double* bounds = this->StructuredBoundsDouble;
352  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
353  (x[2] < bounds[4]) || (x[2] > bounds[5]));
354 }
355 
356 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
357 {
358  const float* bounds = this->StructuredBoundsFloat;
359  return !((x[0] < bounds[0]) || (x[0] > bounds[1]) || (x[1] < bounds[2]) || (x[1] > bounds[3]) ||
360  (x[2] < bounds[4]) || (x[2] > bounds[5]));
361 }
362 
364  vtkInterpolationWeights*& weights, int xIdx, int yIdx, int zIdx, 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, float* value, int n)
371 {
372  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
373 }
374 
375 #endif
interpolate data values from images
abstract base class for most VTK objects
Definition: vtkObject.h:62
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).
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:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkImageBorderMode GetBorderMode()
The border mode (default: clamp).
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
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...
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
general representation of visualization data
Definition: vtkDataObject.h:65
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(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
void SetBorderModeToMirror()
The border mode (default: clamp).