Accelerating the pace of engineering and science

affine2d class

2-D Affine Geometric Transformation

Description

An affine2d object encapsulates a 2-D affine geometric transformation.

Construction

tform = affine2d() creates an affine2d object with default property settings that correspond to the identity transformation.

tform = affine2d(A) creates an affine2d object given an input 3-by-3 matrix A that specifies a valid affine transformation.

Code Generation: affine2d supports the generation of efficient, production-quality C/C++ code from MATLAB. When generating code, you can only specify singular objects—arrays of objects are not supported. To see a complete list of all the list of toolbox functions that support code generation, see List of Supported Functions with Usage Notes.

Input Arguments

 A 3-by-3 matrix that specifies a valid affine transformation of the form: ```A = [a b 0; c d 0; e f 1]; ```Default: Identity transformation

Properties

 T 3-by-3 double-precision, floating point matrix that defines the 2-D forward affine transformation The matrix T uses the convention: [x y 1] = [u v 1] * T where T has the form: ``` [a b 0; c d 0; e f 1]; ``` Dimensionality Describes the dimensionality of the geometric transformation for both input and output points

Methods

 invert Invert geometric transformation isRigid Determine if transformation is rigid transformation isSimilarity Determine if transformation is similarity transformation isTranslation Determine if transformation is pure translation outputLimits Find output spatial limits given input spatial limits transformPointsForward Apply forward geometric transformation transformPointsInverse Apply inverse geometric transformation

Copy Semantics

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

Examples

expand all

Define 10-Degree Rotation in the Counter-Clockwise Direction

Create an affine2d object that defines the transformation.

```theta = 10;

tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1])```
```tform =

affine2d with properties:

T: [3x3 double]
Dimensionality: 2```

Apply forward geometric transformation to an input (U,V) point (5,10).

`[X,Y] = transformPointsForward(tform,5,10)`
```X =

6.6605

Y =

8.9798```

Apply inverse geometric transformation to output (X,Y) point from the previous step to recover the original points from the inverse transformation.

`[U,V] = transformPointsInverse(tform,X,Y)`
```U =

5.0000

V =

10
```

Apply 10-Degree Counter-Clockwise rotation to Image Using imwarp Function

`A = imread('pout.tif');`

Create an affine2d object that defines the transformation.

```theta = 10;

tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1])```
```tform =

affine2d with properties:

T: [3x3 double]
Dimensionality: 2```

Apply geometric transformation to image.

```outputImage = imwarp(A,tform);
figure, imshow(outputImage);```