Class ThinPlateSplineTransform
Object
ThinPlateSplineTransform
- All Implemented Interfaces:
MathTransform
A 2D transformation using Thin Plate Splines (TPS) for smoothly interpolating between a set of control points. This
transform is useful for georeferencing scanned maps or warping images based on Ground Control Points (GCPs).
This implementation uses separate TPS interpolators for the X and Y dimensions.
-
Constructor Summary
ConstructorsConstructorDescriptionThinPlateSplineTransform
(List<MappedPosition> positions) Constructs a Thin Plate Spline transform from a list ofMappedPosition
instances.ThinPlateSplineTransform
(List<Coordinate> sourcePoints, List<Coordinate> targetPoints) Constructs a Thin Plate Spline transform from lists of source and target coordinates. -
Method Summary
Modifier and TypeMethodDescriptionderivative
(Position point) Estimates the Jacobian matrix (first-order partial derivatives) of the transformation at a given point using central differences.int
Gets the dimension of input points.int
Gets the dimension of output points.inverse()
Returns the inverse of this transformation by swapping the source and target points.boolean
Tests whether this transform does not move any points.toString()
Returns a human-readable description of this transform.toWKT()
Returns the Well-Known Text (WKT) representation of the transform.void
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.void
transform
(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.void
transform
(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.void
transform
(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values.Transforms a 2D position using the thin plate spline transformation.
-
Constructor Details
-
ThinPlateSplineTransform
Constructs a Thin Plate Spline transform from lists of source and target coordinates.- Parameters:
sourcePoints
- list of source coordinates (e.g., image coordinates)targetPoints
- list of target coordinates (e.g., map coordinates)- Throws:
IllegalArgumentException
- if the two lists are not of equal length
-
ThinPlateSplineTransform
Constructs a Thin Plate Spline transform from a list ofMappedPosition
instances.- Parameters:
positions
- list of mappings from source to target positions- Throws:
IllegalArgumentException
- if the list is null, empty, or mismatched
-
-
Method Details
-
getSourceDimensions
public int getSourceDimensions()Gets the dimension of input points.- Specified by:
getSourceDimensions
in interfaceMathTransform
- Returns:
- The dimension of input points.
-
getTargetDimensions
public int getTargetDimensions()Gets the dimension of output points.- Specified by:
getTargetDimensions
in interfaceMathTransform
- Returns:
- The dimension of output points.
-
transform
public Position transform(Position ptSrc, Position ptDst) throws MismatchedDimensionException, TransformException Transforms a 2D position using the thin plate spline transformation.- Specified by:
transform
in interfaceMathTransform
- Parameters:
ptSrc
- the source positionptDst
- the destination position to store the result (or null to create a new one)- Returns:
- the transformed position
- Throws:
MismatchedDimensionException
- if dimensions are invalidTransformException
- if the transformation fails
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order:(x0,y0,z0, x1,y1,z1 ...).
- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- the array containing the source point coordinates.srcOff
- the offset to the first point to be transformed in the source array.dstPts
- the array into which the transformed point coordinates are returned. May be the same thansrcPts
.dstOff
- the offset to the location of the first transformed point that is stored in the destination array.numPts
- the number of point objects to be transformed.- Throws:
TransformException
- if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform tothis
.
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order:(x0,y0,z0, x1,y1,z1 ...).
- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- the array containing the source point coordinates.srcOff
- the offset to the first point to be transformed in the source array.dstPts
- the array into which the transformed point coordinates are returned. May be the same thansrcPts
.dstOff
- the offset to the location of the first transformed point that is stored in the destination array.numPts
- the number of point objects to be transformed.- Throws:
TransformException
- if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform tothis
.
-
transform
public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order:(x0,y0,z0, x1,y1,z1 ...).
- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- the array containing the source point coordinates.srcOff
- the offset to the first point to be transformed in the source array.dstPts
- the array into which the transformed point coordinates are returned.dstOff
- the offset to the location of the first transformed point that is stored in the destination array.numPts
- the number of point objects to be transformed.- Throws:
TransformException
- if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform tothis
.
-
transform
public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException Transforms a list of coordinate point ordinal values. This method is provided for efficiently transforming many points. The supplied array of ordinal values will contain packed ordinal values. For example, if the source dimension is 3, then the ordinals will be packed in this order:(x0,y0,z0, x1,y1,z1 ...).
- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- the array containing the source point coordinates.srcOff
- the offset to the first point to be transformed in the source array.dstPts
- the array into which the transformed point coordinates are returned.dstOff
- the offset to the location of the first transformed point that is stored in the destination array.numPts
- the number of point objects to be transformed.- Throws:
TransformException
- if a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform tothis
.
-
derivative
Estimates the Jacobian matrix (first-order partial derivatives) of the transformation at a given point using central differences.- Specified by:
derivative
in interfaceMathTransform
- Parameters:
point
- the position to evaluate the derivative at- Returns:
- a 2×2 matrix representing the derivative
- Throws:
MismatchedDimensionException
- if dimensions are invalidTransformException
- if the transformation fails
-
inverse
Returns the inverse of this transformation by swapping the source and target points.- Specified by:
inverse
in interfaceMathTransform
- Returns:
- the inverse transform
- Throws:
UnsupportedOperationException
- if inversion is not supported
-
isIdentity
public boolean isIdentity()Tests whether this transform does not move any points.- Specified by:
isIdentity
in interfaceMathTransform
- Returns:
true
if thisMathTransform
is an identity transform;false
otherwise.
-
toWKT
Returns the Well-Known Text (WKT) representation of the transform.- Specified by:
toWKT
in interfaceMathTransform
- Returns:
- the WKT string
- Throws:
UnsupportedOperationException
- If this object can't be formatted as WKT.
-
toString
Returns a human-readable description of this transform.
-