projective2d class

2-D Projective Geometric Transformation


A projective2d object encapsulates a 2-D projective geometric transformation.


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

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

Code Generation: projective2d 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


3-by-3 matrix that specifies a valid projective transformation of the form:

 A = [a b c;
      d e f;
      g h i]

Default: Identity transformation



3-by-3 double-precision, floating point matrix that defines the 2-D forward projective transformation.

The matrix T uses the convention:

[x y 1] = [u v 1] * T

where T has the form:

[a b c;...
 d e f;...
 g h i];


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


invertInvert geometric transformation
outputLimitsFind output spatial limits given input spatial limits
transformPointsForwardApply forward geometric transformation
transformPointsInverseApply 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.


expand all

Create a Projective2d Object

Create a projective2d object that defines the transformation.

theta = 10;
tform = projective2d([cosd(theta) -sind(theta) 0.001; sind(theta) cosd(theta) 0.01; 0 0 1]);
tform = 

  projective2d with properties:

                 T: [3x3 double]
    Dimensionality: 2

Apply forward geometric transformation to an input point.

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


Y =


Apply inverse geometric transformation to output point from previous step to recover the point we started with.

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


V =


Apply Projective Transformation to Image Using the imwarp Function

Read image.

A = imread('pout.tif');

Create geometric transformation object.

theta = 10;
tform = projective2d([cosd(theta) -sind(theta) 0.001; sind(theta) cosd(theta) 0.01; 0 0 1]);

Apply transformation and view image.

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

Was this topic helpful?