2-D piecewise linear geometric transformation
PiecewiseLinearTransformation2D object stores information
about a 2-D piecewise linear geometric transformation and enables inverse
You can create a
PiecewiseLinearTransformation2D object in these
fitgeotform2dfunction, which estimates a geometric transformation that maps pairs of control points between two images.
images.geotrans.PiecewiseLinearTransformation2Dfunction described here. This function creates a
PiecewiseLinearTransformation2Dobject using coordinates of fixed points and moving points.
tform = images.geotrans.PiecewiseLinearTransformation2D(
PiecewiseLinearTransformation2D object that maps
control points in the moving image,
control points in the fixed image,
fixedPoints, using a
piecewise linear transformation. You can select control points using the
movingPoints — Control points in moving image
Control points in the moving image, specified as an m-by-2 matrix, where m is greater than or equal to 4. Each row specifies the (x, y) coordinate of a control point.
fixedPoints — Control points in fixed image
Control points in the fixed image, specified as an m-by-2 matrix, where m is greater than or equal to 4. Each row specifies the (x, y) coordinate of a control point.
Dimensionality — Dimensionality of the geometric transformation
Dimensionality of the geometric transformation for both input and output points, specified as the value 2.
|Find output spatial limits given input spatial limits|
|Apply inverse geometric transformation|
Fit Piecewise Linear Transformation
Choose six pairs of control points and moving points. For simplicity, this example selects moving points that are translated 5 pixels horizontally and 10 pixels vertically from the fixed points.
fixedPoints = [10 20; 10 5; 2 3; 0 5; -5 3; -10 -20]; movingPoints = [15 30; 15 15; 5 13; 5 15; 0 13; -5 -10];
Estimate a piecewise linear transformation that fits
tform = images.geotrans.PiecewiseLinearTransformation2D(movingPoints,fixedPoints)
tform = PiecewiseLinearTransformation2D with properties: Dimensionality: 2
Verify that the inverse transformation maps the fixed points to the moving points.
movingPointsComputed = transformPointsInverse(tform,fixedPoints)
movingPointsComputed = 6×2 15.0000 30.0000 15.0000 15.0000 5.0000 13.0000 5.0000 15.0000 -0.0000 13.0000 -5.0000 -10.0000
In a piecewise linear transformation, linear (affine) transformations are applied separately to each triangular region of the image .
Find a Delaunay triangulation of the fixed control points. For more information, see Working with Delaunay Triangulations.
Using the three vertices of each triangle, infer an affine mapping from fixed to moving coordinates. The mapping is affine for each triangle and continuous across the control points, but is not continuously differentiable.
You must define at least two triangles with distinct mappings by specifying at least four non-colinear control point pairs. More control point pairs can yield more triangular regions.
PiecewiseLinearTransformation2D object removes control points
that are vertices of degenerate fold-over triangles. When
fixedPoints do not list
the control points in the same order, the object may not eliminate all fold-over
triangles. To resolve this error, ensure that control points in the moving and fixed
image are ordered identically.
 Goshtasby, Ardeshir. “Piecewise Linear Mapping Functions for Image Registration.” Pattern Recognition 19, no. 6 (January 1986): 459–66. https://doi.org/10.1016/0031-3203(86)90044-0.
Introduced in R2013b