38 #ifndef AIMS_LINEAR_INTERPOLATOR 39 #define AIMS_LINEAR_INTERPOLATOR 68 virtual bool isValid( Coordinate_t x, Coordinate_t y,
69 Coordinate_t z )
const = 0;
75 return isValid( point[ 0 ], point[ 1 ], point[ 2 ] );
79 inline Scalar_t
operator()( Coordinate_t x, Coordinate_t y,
80 Coordinate_t z )
const 83 return do_interpolation( x, y, z );
89 return do_interpolation( point[ 0 ], point[ 1 ], point[ 2 ] );
92 inline void operator()( Coordinate_t x, Coordinate_t y, Coordinate_t z,
93 std::vector<Scalar_t> & v )
const 96 do_interpolations( x, y, z, v );
100 std::vector<Scalar_t> &v )
const 103 do_interpolations( point[ 0 ], point[ 1 ], point[ 2 ], v );
107 inline Scalar_t
value( Coordinate_t x, Coordinate_t y,
108 Coordinate_t z )
const 110 return do_interpolation(x, y, z);
115 return do_interpolation( point[ 0 ], point[ 1 ], point[ 2 ] );
118 inline void values( Coordinate_t x, Coordinate_t y, Coordinate_t z,
119 std::vector<Scalar_t> &v )
const 121 do_interpolations(x, y, z, v);
125 std::vector<Scalar_t> &v )
const 127 do_interpolations( point[ 0 ], point[ 1 ], point[ 2 ], v );
133 virtual Scalar_t do_interpolation( Coordinate_t x, Coordinate_t y,
134 Coordinate_t z )
const = 0;
135 virtual void do_interpolations( Coordinate_t x,
138 std::vector<Scalar_t> &v )
const = 0;
147 template <
typename T>
155 class LinearInterpolatorFactory;
158 template <
typename T>
166 bool isValid( Coordinate_t x, Coordinate_t y, Coordinate_t z )
const;
173 Scalar_t do_interpolation( Coordinate_t x, Coordinate_t y,
174 Coordinate_t z )
const;
175 void do_interpolations( Coordinate_t x, Coordinate_t y, Coordinate_t z,
176 std::vector<Scalar_t> & )
const;
179 void _interpolationCoefficients( Coordinate_t xx,
186 Scalar_t linint(Scalar_t a, Scalar_t b, Scalar_t x) {
return a + x*(b-a); }
189 int _dimX, _dimY, _dimZ;
190 float _invsizeX, _invsizeY, _invsizeZ;
209 template <
typename T>
243 template <
typename T>
248 _dimX = _image.dimX();
249 _dimY = _image.dimY();
250 _dimZ = _image.dimZ();
252 assert(_image.sizeX() > 0);
253 _invsizeX = float(1.0 / _image.sizeX());
254 assert(_image.sizeY() > 0);
255 _invsizeY = float(1.0 / _image.sizeY());
256 assert(_image.sizeZ() > 0);
257 _invsizeZ = float(1.0 / _image.sizeZ());
262 template <
typename T>
269 template <
typename T>
278 return x >= hx && y >= hy && z >= hz &&
279 x < _image.dimX() * _image.sizeX() + hx &&
280 y < _image.dimY() * _image.sizeY() + hy &&
281 z < _image.dimZ() * _image.sizeZ() + hz;
286 template <
typename T>
319 template <
typename T>
325 int x, X, y, Y, z, Z;
327 _interpolationCoefficients(xx, x, X, ax, _dimX, _invsizeX);
328 _interpolationCoefficients(yy, y, Y, ay, _dimY, _invsizeY);
329 _interpolationCoefficients(zz, z, Z, az, _dimZ, _invsizeZ);
334 linint(_image( x, y, z ), _image( X, y, z ), ax),
335 linint(_image( x, Y, z ), _image( X, Y, z ), ax), ay),
337 linint(_image( x, y, Z ), _image( X, y, Z ), ax),
338 linint(_image( x, Y, Z ), _image( X, Y, Z ), ax), ay), az);
343 template <
typename T>
348 std::vector< Interpolator::Scalar_t > &
values )
const 350 values.resize( _image.dimT() );
351 int x, X, y, Y, z, Z;
353 _interpolationCoefficients(xx, x, X, ax, _dimX, _invsizeX);
354 _interpolationCoefficients(yy, y, Y, ay, _dimY, _invsizeY);
355 _interpolationCoefficients(zz, z, Z, az, _dimZ, _invsizeZ);
357 for(
int t = 0; t < _image.dimT(); ++t ) {
361 linint(_image( x, y, z, t ), _image( X, y, z, t ), ax),
362 linint(_image( x, Y, z, t ), _image( X, Y, z, t ), ax),
365 linint(_image( x, y, Z, t ), _image( X, y, Z, t ), ax),
366 linint(_image( x, Y, Z, t ), _image( X, Y, Z, t ), ax),
373 template <
typename T>
377 return _image.volume()->header();
382 #endif // ifdef AIMS_LINEAR_INTERPOLATOR carto::rc_ptr< Interpolator > getLinearInterpolator(const std::string &)
#define __deprecated__(msg)
void operator()(const Interpolator::Point_t &point, std::vector< Scalar_t > &v) const __attribute__((__deprecated__("use values() method instead")))
virtual ~LinearInterpolator()
Scalar_t value(const Interpolator::Point_t &point) const
Interpolate to get a value from point.
void operator()(Coordinate_t x, Coordinate_t y, Coordinate_t z, std::vector< Scalar_t > &v) const __attribute__((__deprecated__("use values() method instead")))
bool isValid(const Interpolator::Point_t &point) const
Return true if point can be used for interpolation.
virtual bool isValid(Coordinate_t x, Coordinate_t y, Coordinate_t z) const =0
Return true if point ( x, y, z ) can be used for interpolation.
The class for EcatSino data write operation.
void values(Coordinate_t x, Coordinate_t y, Coordinate_t z, std::vector< Scalar_t > &v) const
Interpolate to get a series of values from point ( x, y ,z )
Scalar_t operator()(Coordinate_t x, Coordinate_t y, Coordinate_t z) const __attribute__((__deprecated__("use value() method instead")))
class __attribute__((__deprecated__("Use Volume, which now manages views, instead."))) VolumeView
bool isValid(Coordinate_t x, Coordinate_t y, Coordinate_t z) const
Return true if point ( x, y, z ) can be used for interpolation.
virtual const carto::PropertySet & header() const =0
Return the header of the image.
void values(const Interpolator::Point_t &point, std::vector< Scalar_t > &v) const
Interpolate to get a series of values from point ( x, y ,z )
LinearInterpolator(const AimsData< T > &image)
Scalar_t value(Coordinate_t x, Coordinate_t y, Coordinate_t z) const
Interpolate to get a value from point ( x, y ,z ).
Scalar_t operator()(const Interpolator::Point_t &point) const __attribute__((__deprecated__("use value() method instead")))
virtual const carto::PropertySet & header() const
Return the header of the image.