Class ThinPlateSpline2D

Object
ThinPlateSpline2D

public class ThinPlateSpline2D extends Object
A 2D Thin Plate Spline (TPS) interpolator.

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 Details

    • ThinPlateSpline2D

      public ThinPlateSpline2D(CoordinateSequence sourcePoints, double[] values)
      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 as sourcePoints.
      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.