Class ThinPlateSpline2D
TPS is a smooth spline-based interpolation for warping, image registration, and surface fitting. This implementation solves for the spline weights using radial basis functions and an affine component to interpolate scalar values at arbitrary 2D locations.
Each instance fits a surface from control points (x, y) to scalar values v
. To model 2D transformations
(e.g., (x, y) → (x', y')), construct two instances: one for x' and one for y'.
Reference:
-
Constructor Summary
ConstructorsConstructorDescriptionThinPlateSpline2D
(CoordinateSequence sourcePoints, double[] values) Constructs a Thin Plate Spline (TPS) interpolator using the given control points and target values. -
Method Summary
Modifier and TypeMethodDescriptiondouble
interpolate
(double xVal, double yVal) Interpolates a value at the given 2D location using the thin plate spline surface.
-
Constructor Details
-
ThinPlateSpline2D
Constructs a Thin Plate Spline (TPS) interpolator using the given control points and target values.This class fits a smooth interpolating surface through the control points, minimizing the bending energy of the surface. The resulting function can be evaluated at arbitrary (x, y) locations to obtain interpolated values.
- Parameters:
sourcePoints
- The source control points in 2D space. Must contain at least 3 unique points.values
- The target values at each control point, of the same length assourcePoints
.- Throws:
IllegalArgumentException
- if the number of source points does not match the number of values, or if there are duplicate source coordinates.
-
-
Method Details
-
interpolate
public double interpolate(double xVal, double yVal) Interpolates a value at the given 2D location using the thin plate spline surface.The returned value is computed based on the previously fitted surface that passes through all control points. The function is smooth and differentiable, with minimum bending energy.
- Parameters:
xVal
- The x-coordinate of the input point.yVal
- The y-coordinate of the input point.- Returns:
- The interpolated value at the given location.
-