images.geotrans.PolynomialTransformation2D

2-D polynomial geometric transformation

Description

A PolynomialTransformation2D object encapsulates a 2-D polynomial geometric transformation.

Creation

You can create a PolynomialTransformation2D object using the following methods:

  • The fitgeotrans function, which estimates a geometric transformation that maps pairs of control points between two images.

  • The images.geotrans.PolynomialTransformation2D function described here. This function creates a PolynomialTransformation2D object using coordinates of fixed points and moving points, or the known polynomial coefficients for the forward and inverse transformation.

Syntax

tform = images.geotrans.PolynomialTransformation2D(movingPoints,fixedPoints,degree)
tform = images.geotrans.PolynomialTransformation2D(a,b)

Description

example

tform = images.geotrans.PolynomialTransformation2D(movingPoints,fixedPoints,degree) creates a PolynomialTransformation2D object and sets the Degree property. The function estimates the polynomial coefficients A and B from matrices movingPoints and fixedPoints that define matched control points in the moving and fixed images, respectively.

tform = images.geotrans.PolynomialTransformation2D(a,b) creates a PolynomialTransformation2D object and sets the A and B properties.

Input Arguments

expand all

x- and y-coordinates of control points in the moving image, specified as an m-by-2 matrix.

Data Types: double | single

x- and y-coordinates of control points in the fixed image, specified as an m-by-2 matrix.

Data Types: double | single

Properties

expand all

Polynomial coefficients used to determine U in the inverse transformation, specified as an n-element vector. For polynomials of degree 2, 3, and 4, n is 6, 10, and 15, respectively.

The quadratic (degree 2) polynomial coefficient vector A is ordered as follows:

U = A(1) + A(2).*X + A(3).*Y + A(4).*X.*Y + A(5).*X.^2 + A(6).*Y.^2

The cubic (degree 3) polynomial coefficient vector adds these terms:

... + A(7).*X.^2.*Y + A(8).*X.*Y.^2 + A(9).*X.^3 + A(10).*Y.^3

The quartic (degree 4) polynomial coefficient vector adds these terms:

... + A(11).*X.^3.*Y + A(12).*X.^2.*Y.^2 + A(12).*X.*Y.^3 + A(14).*X.^3 + A(15).*Y.^4

Data Types: double | single

Polynomial coefficients used to determine V in the inverse transformation, specified as an n-element vector. For polynomials of degree 2, 3, and 4, n is 6, 10, and 15, respectively.

The quadratic (degree 2) polynomial coefficient vector B is ordered as follows:

V = B(1) + B(2).*X + B(3).*Y + B(4).*X.*Y + B(5).*X.^2 + B(6).*Y.^2

The cubic (degree 3) polynomial coefficient vector adds these terms:

... + B(7).*X.^2.*Y + B(8).*X.*Y.^2 + B(9).*X.^3 + B(10).*Y.^3

The quartic (degree 4) polynomial coefficient vector adds these terms:

... + B(11).*X.^3.*Y + B(12).*X.^2.*Y.^2 + B(12).*X.*Y.^3 + B(14).*X.^3 + B(15).*Y.^4

Data Types: double | single

Degree of the polynomial transformation, specified as the scalar values 2, 3, or 4.

Dimensionality of the geometric transformation for both input and output points, specified as the value 2.

Object Functions

outputLimitsFind output spatial limits given input spatial limits
transformPointsInverseApply inverse geometric transformation

Examples

collapse all

Fit a second degree polynomial transformation to a set of fixed and moving control points that are actually related by an 2-D affine transformation.

Create 2-D affine transformation.

theta = 10;
tformAffine = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1]);

Arbitrarily choose six pairs of control points. A second degree polynomial requires six pairs of control points.

 fixedPoints = [10 20; 10 5; 2 3; 0 5; -5 3; -10 -20];

Apply forward geometric transformation to map fixed points to obtain effect of fixed and moving points that are related by some geometric transformation.

movingPoints = transformPointsForward(tformAffine,fixedPoints);

Estimate second degree PolynomialTransformation2D transformation that fits fixedPoints and movingPoints.

tformPolynomial = images.geotrans.PolynomialTransformation2D(movingPoints,fixedPoints,2);

Verify the fit of the PolynomialTransformation2D transformation at the control points.

movingPointsEstimated = transformPointsInverse(tformPolynomial,fixedPoints);
errorInFit = hypot(movingPointsEstimated(:,1)-movingPoints(:,1),...
                   movingPointsEstimated(:,2)-movingPoints(:,2))

More About

expand all

Introduced in R2013b