This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

projective2d class

2-D Projective Geometric Transformation


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

Code Generation support: Yes.

MATLAB Function Block support: Yes.


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.

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 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 =


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);

Additional Capabilities

Code Generation

This function supports the generation of C code using MATLAB Coder™. For more information, see Code Generation for Image Processing.

When generating code, you can only specify singular objects—arrays of objects are not supported.

MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.

Was this topic helpful?