# transformPointsInverse

Apply inverse geometric transformation

## Syntax

## Description

## Examples

### Apply Inverse Transformation of 2-D Geometric Transformation

Define a 3-by-3 geometric transformation matrix. This example specifies a matrix for an affine transformation consisting of vertical shear and horizontal stretch.

A = [1.5 0 0; 0.8 1 0; 0 0 1];

Create an `affinetform2d`

object from the transformation matrix.

tform = affinetform2d(A);

Apply the inverse geometric transformation to a point.

x = 7.5; y = 14; [u,v] = transformPointsInverse(tform,x,y)

u = 5

v = 10

### Transform Packed Coordinates Using Custom 2-D Transformation

Specify the packed (x,y) coordinates of five input points. The packed coordinates are stored in a 5-by-2 matrix, where the *x*-coordinate of each point is in the first column, and the *y*-coordinate of each point is in the second column.

XY = [10 15;11 32;15 34;2 7;2 10];

Define the inverse mapping function. The function accepts and returns points in packed (x,y) format.

inversefn = @(c) [c(:,1)+c(:,2),c(:,1)-c(:,2)]

`inversefn = `*function_handle with value:*
@(c)[c(:,1)+c(:,2),c(:,1)-c(:,2)]

Create a 2-D geometric transform object, `tform`

, that stores the inverse mapping function.

tform = geometricTransform2d(inversefn)

tform = geometricTransform2d with properties: InverseFcn: @(c)[c(:,1)+c(:,2),c(:,1)-c(:,2)] ForwardFcn: [] Dimensionality: 2

Apply the inverse geometric transform to the input points.

UV = transformPointsInverse(tform,XY)

`UV = `*5×2*
25 -5
43 -21
49 -19
9 -5
12 -8

### Apply Inverse Transformation of 3-D Geometric Transformation

Define a rigid geometric transformation consisting only of translation.

t = [10 20.5 15]; tform = transltform3d(t);

Apply the forward geometric transformation to an input point.

x = 11; y = 21.5; z = 16.01; [u,v,w] = transformPointsInverse(tform,x,y,z)

u = 1

v = 1

w = 1.0100

### Transform Packed Coordinates Using Custom 3-D Transformation

Specify the packed (*x*,*y*,*z*) coordinates of five input points. The packed coordinates are stored as a 5-by-3 matrix, where the first, second, and third columns contain the *x*-, *y*-, and* z- *coordinates,respectively.

XYZ = [5 25 20;10 5 25;15 10 5;20 15 10;25 20 15];

Define an inverse mapping function that accepts and returns points in packed (*x*,*y*,*z*) format.

inverseFcn = @(c) [c(:,1)+c(:,2),c(:,1)-c(:,2),c(:,3).^2];

Create a 3-D geometric transformation object, `tform`

, that stores this inverse mapping function.

tform = geometricTransform3d(inverseFcn)

tform = geometricTransform3d with properties: InverseFcn: @(c)[c(:,1)+c(:,2),c(:,1)-c(:,2),c(:,3).^2] ForwardFcn: [] Dimensionality: 3

Apply the inverse transformation of this 3-D geometric transformation to the input points.

UVW = transformPointsInverse(tform,XYZ)

`UVW = `*5×3*
30 -20 400
15 5 625
25 5 25
35 5 100
45 5 225

## Input Arguments

`tform`

— Geometric transformation

geometric transformation object

Geometric transformation, specified as a geometric transformation object listed in the table.

Geometric Transformation Object | Description |
---|---|

2-D
Linear Geometric Transformations | |

`transltform2d` | Translation transformation |

`rigidtform2d` | Rigid transformation: translation and rotation |

`simtform2d` | Similarity transformation: translation, rotation, and isotropic scaling |

`affinetform2d` | Affine transformation: translation, rotation, nonisotropic scaling, reflection, and shearing |

`projtform2d` | Projective transformation |

3-D
Linear Geometric Transformations | |

`transltform3d` | Translation transformation |

`rigidtform3d` | Rigid transformation: translation and rotation |

`simtform3d` | Similarity transformation: translation, rotation, and isotropic scaling |

`affinetform3d` | Affine transformation: translation, rotation, nonisotropic scaling, reflection, and shearing |

Nonlinear Geometric Transformations | |

`geometricTransform2d` | Custom 2-D geometric transformation using point-wise mapping functions |

`geometricTransform3d` | Custom 3-D geometric transformation using point-wise mapping functions |

`LocalWeightedMeanTransformation2D` | 2-D local weighted means transformation |

`PiecewiseLinearTransformation2D` | 2-D piecewise linear transformation |

`PolynomialTransformation2D` | 2-D polynomial transformation |

**Note**

You can also specify `tform`

as an object of type
`rigid2d`

, `rigid3d`

, `affine2d`

, `affine3d`

, or `projective2d`

. However,
these objects are not recommended. For more information, see Compatibility Considerations.

`x`

— *x*-coordinates of points to be transformed

*m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array

*x*-coordinates of points to be transformed, specified as
an *m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array. The number of dimensions of `x`

matches
the dimensionality of `tform`

.

**Data Types: **`single`

| `double`

`y`

— *y*-coordinates of points to be transformed

*m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array

*y*-coordinates of points to be transformed, specified as
an *m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array. The size of `y`

must match the size of
`x`

.

**Data Types: **`single`

| `double`

`X`

— Coordinates of points to be transformed

*l*-by-*2* or
*l*-by-*3* numeric array

Coordinates of points to be transformed, specified as an
*l*-by-*2* or
*l*-by-*3* numeric array. The number
of columns of `X`

matches the dimensionality of
`tform`

.

The first column lists the *x*-coordinate of each point
to transform, and the second column lists the
*y*-coordinate. If `tform`

represents a
3-D geometric transformation, `X`

has size
*l*-by-*3* and the third column lists
the *z*-coordinate of the points to transform.

**Data Types: **`single`

| `double`

## Output Arguments

`u`

— *x*-coordinates of points after transformation

*m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array

*x*-coordinates of points after transformation, returned
as an *m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array. The number of dimensions of `u`

matches
the dimensionality of `tform`

.

**Data Types: **`single`

| `double`

`v`

— *y*-coordinates of points after transformation

*m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array

*y*-coordinates of points after transformation, returned
as an *m*-by-*n* or
*m*-by-*n*-by-*p*
numeric array. The size of `v`

matches the size of
`u`

.

**Data Types: **`single`

| `double`

`w`

— *z*-coordinates of points after transformation

*m*-by-*n*-by-*p*
numeric array

*z*-coordinates of points after transformation, returned
as an *m*-by-*n*-by-*p*
numeric array. The size of `w`

matches the size of
`u`

.

**Data Types: **`single`

| `double`

`U`

— Coordinates of points after transformation

numeric array

Coordinates of points after transformation, returned as a numeric array.
The size of `U`

matches the size of
`X`

.

The first column lists the *x*-coordinate of each point
after transformation, and the second column lists the
*y*-coordinate. If `tform`

represents a
3-D geometric transformation, the third column lists the
*z*-coordinate of the points after
transformation.

**Data Types: **`single`

| `double`

## Version History

**Introduced in R2013a**

### R2022b: Supports new geometric transformation objects

Starting in R2022b, most Image Processing Toolbox™ functions create and perform geometric transformations using the
premultiply convention. Accordingly, you can now specify `tform`

as a geometric transformation object that uses the premultiply convention, such as
an `affinetform2d`

object.

Although `transformPointsInverse`

still supports objects that
use the postmultiply convention, such as an `affine2d`

object, these objects are
not recommended. You can streamline your geometric transformation workflows by
switching to the new premultiply geometric transformation objects. For more
information, see Migrate Geometric Transformations to Premultiply Convention.

There is no change to the support for nonlinear geometric transformation objects.

## See Also

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)