STIR  6.2.0
Public Member Functions | List of all members
stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT > Class Template Reference

A class for n-dimensional BSpline interpolation when the input samples are on a regular grid. More...

#include "stir/numerics/BSplinesRegularGrid.h"

Inheritance diagram for stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >:
Inheritance graph
[legend]

Public Member Functions

Array< num_dimensions, out_elemT > get_coefficients () const
 
 BSplinesRegularGrid (const Array< num_dimensions, in_elemT > &input, const BSplineType &this_type=cubic)
 constructor given an array of samples and the spline type
 
 BSplinesRegularGrid (const Array< num_dimensions, in_elemT > &input, const BasicCoordinate< num_dimensions, BSplineType > &this_type)
 constructor given an array of samples and a different spline type for every dimension
 
 BSplinesRegularGrid (const BSplineType &this_type=cubic)
 constructor that only sets the spline type More...
 
 BSplinesRegularGrid (const BasicCoordinate< num_dimensions, BSplineType > &this_type)
 constructor that only sets a different spline type for every dimension More...
 
 ~BSplinesRegularGrid ()
 destructor
 
void set_coef (const Array< num_dimensions, in_elemT > &input)
 Compute the coefficients for the B-splines from an array of samples. More...
 
const out_elemT operator() (const BasicCoordinate< num_dimensions, pos_type > &relative_positions) const
 Compute value of the interpolator. More...
 
const BasicCoordinate< num_dimensions, out_elemT > gradient (const BasicCoordinate< num_dimensions, pos_type > &relative_positions) const
 Compute gradient of the interpolator. More...
 

Detailed Description

template<int num_dimensions, typename out_elemT, typename in_elemT = out_elemT, typename constantsT = in_elemT>
class stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >

A class for n-dimensional BSpline interpolation when the input samples are on a regular grid.

This class provides essentially an n-dimensional function, so can be used as a function object.

Example
Array<3,float> some_data = ....;
BSplinesRegularGrid<3, float> interpolator(cubic);
interpolator.set_coef(some_data);
Coordinate3D<double> position(1.2, 3.4, 5.6);
float value = interpolator(position);
\warning The implementation currently uses mirror boundary conditions. This means you
can ask for values of the interpolator outside the original grid, but the results
might not be what you expect.

Constructor & Destructor Documentation

◆ BSplinesRegularGrid() [1/2]

template<int num_dimensions, typename out_elemT, typename in_elemT = out_elemT, typename constantsT = in_elemT>
stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >::BSplinesRegularGrid ( const BSplineType this_type = cubic)
inlineexplicit

constructor that only sets the spline type

You need to call set_coef() first before you will get a sensible result.

◆ BSplinesRegularGrid() [2/2]

template<int num_dimensions, typename out_elemT, typename in_elemT = out_elemT, typename constantsT = in_elemT>
stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >::BSplinesRegularGrid ( const BasicCoordinate< num_dimensions, BSplineType > &  this_type)
inlineexplicit

constructor that only sets a different spline type for every dimension

You need to call set_coef() first before you will get a sensible result.

Member Function Documentation

◆ set_coef()

template<int num_dimensions, typename out_elemT , typename in_elemT, typename constantsT >
void stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >::set_coef ( const Array< num_dimensions, in_elemT > &  input)
inline

Compute the coefficients for the B-splines from an array of samples.

When the order of the spline is larger than 1, the coefficients multiplying the basic splines are not equal to the samples. This variable stores them for further use.

Todo:
rename

◆ operator()()

template<int num_dimensions, typename out_elemT , typename in_elemT , typename constantsT >
const out_elemT stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >::operator() ( const BasicCoordinate< num_dimensions, pos_type > &  relative_positions) const
inline

Compute value of the interpolator.

Parameters
relative_positionsA coordinate with respect to the original grid coordinates as used by the input array. In particular, if the input array was not 0-based, your relative_positions should not be either.
Returns
the interpolated value.
Todo:
should probably be templated in pos_type.

◆ gradient()

template<int num_dimensions, typename out_elemT , typename in_elemT , typename constantsT >
const BasicCoordinate< num_dimensions, out_elemT > stir::BSpline::BSplinesRegularGrid< num_dimensions, out_elemT, in_elemT, constantsT >::gradient ( const BasicCoordinate< num_dimensions, pos_type > &  relative_positions) const
inline

Compute gradient of the interpolator.

Parameters
relative_positionsA coordinate with respect to the original grid coordinates as used by the input array. In particular, if the input array was not 0-based, your relative_positions should not be either.
Returns
the gradient
Todo:
should probably be templated in pos_type.

The documentation for this class was generated from the following files: