invert

Invert geometric transformation

Syntax

invtform = invert(tform)

Description

example

invtform = invert(tform) returns the inverse of the geometric transformation tform.

Examples

collapse all

Create an affine2d object that defines a 30 degree rotation in the counterclockwise direction around the origin. View the transformation matrix stored in the T property.

theta = 30;
tform = affine2d([cosd(theta) sind(theta) 0; -sind(theta) cosd(theta) 0; 0 0 1]);
tform.T
ans = 3×3

    0.8660    0.5000         0
   -0.5000    0.8660         0
         0         0    1.0000

Invert the geometric transformation. The result is a new affine2d object.

invtform = invert(tform);
invtform.T
ans = 3×3

    0.8660   -0.5000         0
    0.5000    0.8660         0
         0         0    1.0000

This matrix represents a 30 degree rotation in the clockwise direction.

Test the Inverse Geometric Transformation

Read an image, and display it.

I = imread('pout.tif');
figure;
imshow(I)

Apply the forward geometric transformation, tform, to the image. Display the rotated image.

J = imwarp(I,tform);
figure;
imshow(J)

Apply the inverse geometric transformation, invtform, to the rotated image J.

K = imwarp(J,invtform);
imshow(K)

The final image, K, has the correct orientation. The two transformations introduced padding that surrounds the image, but the size, shape, and orientation of the image data have not changed.

Input Arguments

collapse all

Geometric transformation, specified as an affine2d, affine3d, or projective2d geometric transformation object.

Output Arguments

collapse all

Inverse geometric transformation, returned as a geometric transformation object. invtform is the same type of object as tform.

Introduced in R2013a