Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# images.geotrans.PolynomialTransformation2D class

Package: images.geotrans

2-D Polynomial Geometric Transformation

## Description

An images.geotrans.PolynomialTransformation2D object encapsulates a 2-D polynomial geometric transformation.

## Construction

tform = images.geotrans.PolynomialTransformation2D(movingPoints,fixedPoints,degree) creates an images.geotrans.PolynomialTransformation2D object given m-by-2 matrices movingPoints, and fixedPoints which define matched control points in the moving and fixed images, respectively. Degree is a scalar with value 2, 3, or 4 that specifies the degree of the polynomial that is fit to the control points.

tform = images.geotrans.PolynomialTransformation2D(A,B) creates an images.geotrans.PolynomialTransformation2D object given polynomial coefficient vectors A and B. A is a vector of polynomial coefficients of length N that is used to determine U in the inverse transformation. B is a vector of polynomial coefficients of length N that is used to determine V in the inverse transformation. For polynomials of degree 2, 3, and 4, N is 6, 10, and 15, respectively.

## Input Arguments

expand all

### movingPoints — X and Y coordinates of control points in the image you want to transformm-by-2 double matrix

X and Y coordinates of control points in the image you want to transform, specified as an m-by-2 double matrix.

Example: fixedPoints = [11 11; 41 71];

Data Types: double

### fixedPoints — X and Y coordinates of control points in the base imagem-by-2 double matrix

X and Y coordinates of control points in the base image, specified as an m-by-2 double matrix.

Example: movingPoints = [14 44; 70 81];

Data Types: double

### A —

Polynomial coefficients used to determine U in inverse transformation

A is a double vector of length N that defines the polynomial coefficients used to determine U in the inverse transformation. For polynomials of degree 2, 3, and 4, N is 6, 10, and 15, respectively. The 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 +...`

### B —

Polynomial coefficients used to determine V in inverse transformation

B is a double vector of length N that defines the polynomial coefficients used to determine V in the inverse transformation. For polynomials of degree 2, 3, and 4, N is 6, 10, and 15, respectively. The 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 +...`

### Degree —

Degree of polynomial

Degree is a scalar that defines the degree of the polynomial transformation. Valid values are 2, 3, and 4.

## Properties

 Dimensionality Dimensionality of geometric transformation Describes the dimensionality of the geometric transformation for both input and output points.

## Methods

 images.geotrans.PolynomialTransformation2d.outputLimits Apply inverse 2-D geometric transformation to points images.geotrans.PolynomialTransformation2d.transformPointsInverse Apply inverse 2-D geometric transformation to points

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

## Examples

expand all

### Fit a second degree polynomial transformation to a set of fixed and moving control points

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

Create 2D 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 our PolynomialTransformation2D transformation at the control points.

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