MATLAB Answers

construct and apply affine transformation matrix

4 views (last 30 days)
Fatma Elzahraa Ahmed
Fatma Elzahraa Ahmed on 14 Sep 2015
Hello, I am trying to construct affine transformation matrix through a parameter vactror of rotation angle, scaling, shearing and displacement values. The vector is organized as follow:
phai=[rotationAngle, scalingCoefX, scalingCoefY, shearingCoefX, shearingCoefY, translationCoefX, translationCoefY]';
To construct the affine transformation matrix I apply the following code:
rotation=[cos(phai(1)) sin(phai(1)) 0; -sin(phai(1))cos(phai(1)) 0; 0 0 1];
scaling=[phai(2) 0 0; 0 phai(3) 0; 0 0 1];
shearingY=[1 0 0; phai(5) 1 0; 0 0 1];
shearingX=[1 phai(4) 0; 0 1 0; 0 0 1];
translation=[1 0 0; 0 1 0; phai(6) phai(7) 1];
T=rotation*scaling*shearingY*shearingX*translation;
T = maketform('affine',T);
Then to apply the result to an image (c) I use the perform:
c=imtransform(c,T);
My question is: is this code right because it takes a lot of time to be executed? is there any suggestions to speed up the execution in the case that the code is right?
Thank you very much

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.