ThinPlateSpline class
Fits a thin plate spline function to a set of points. Useful for interpolation of scattered points.
Contents
This class implements a generalization of the 2D thin plate spline to arbitrary dimensionality. The
constructor builds the thin plate spline function, and the Evaluate method evaluates this function
at a given point.
Constructors, destructors, assignment and conversion operators
- ThinPlateSpline(dip::FloatCoordinateArray coordinate, dip::FloatCoordinateArray const& value, dip::dfloat lambda = 0)
- Creates a function that maps
coordinatetovalue. more...
Functions
- auto Dimensionality() const -> dip::uint
- Returns the dimensionality of the spline. This is the dimensionality of both the input
and the output to
dip::ThinPlateSpline::Evaluate. - auto Evaluate(dip::FloatArray const& pt) const -> dip::FloatArray
- Evaluates the thin plate spline function at point
pt, which must havedip::ThinPlateSpline::Dimensionalityelements. - auto EvaluateUnsafe(dip::FloatArray const& pt) const -> dip::FloatArray
- Like
dip::ThinPlateSpline::Evaluate, but doesn’t check the input sizes. Use with caution. - auto NumberOfControlPoints() const -> dip::uint
- Returns the number of control points that define the spline.
Function documentation
ThinPlateSpline( dip::FloatCoordinateArray coordinate, dip::FloatCoordinateArray const& value, dip::dfloat lambda = 0)
Creates a function that maps coordinate to value.
coordinate gives the spatial location of samples, and value their values. The thin
plate spline function therefore maps coordinate to value. value[ ii ] corresponds to
coordinate[ ii ], both arrays must have the same number of elements.
This function also expects coordinate and value to have the same dimensionality. That is,
they both represent spatial coordinates in the same image. Internally, the function maps
coordinate to value - coordinate, Evaluate( pt ) adds pt to the interpolated
value at pt, and thus it looks externally as if the function maps to value rather than
value - coordinate. This improves extrapolation.
To use this class for warping, set coordinate to control points in the fixed image, and value
to corresponding points in the floating image. Then, for each point in the fixed image,
Evaluate will return the corresponding coordinates in the floating image, which can be
used to sample it.
If lambda is larger than 0, the mapping is not exact, leading to a smoother function.
When applied with a large coordinates array, this constructor can take quite a long time. It is worthwhile to split up such a problem into blocks.
The first input argument, coordinate, is taken by value and stored inside the object. Use
std::move to pass this argument if you no longer use it later.
dip::FloatArray Evaluate( dip::FloatArray const& pt) const
Evaluates the thin plate spline function at point pt, which must have dip::ThinPlateSpline::Dimensionality elements.
dip::FloatArray EvaluateUnsafe( dip::FloatArray const& pt) const
Like dip::ThinPlateSpline::Evaluate, but doesn’t check the input sizes. Use with caution.
dip::uint Dimensionality( ) const
Returns the dimensionality of the spline. This is the dimensionality of both the input
and the output to dip::ThinPlateSpline::Evaluate.
dip::uint NumberOfControlPoints( ) const
Returns the number of control points that define the spline.