image rotation by application of a 2D rotation matrix

6 Ansichten (letzte 30 Tage)
Nastassja Riemermann
Nastassja Riemermann am 27 Mär. 2019
Beantwortet: KSSV am 27 Mär. 2019
I'm working on a homework assignment where we have to rotate a .png image using three successive shear transformations with homogenous coordinates, and that worked fine. Next we're supposed to achieve the same rotation using "a single 2D rotation matrix", which I assume means using non-homogenous coordinates, and I got the following error:
Error using *
MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar.
Error in problem0614 (line 20) imge = rotation*imga;
Can someone help me figure out the proper way to do this? My code is below:
function problem0614()
clc;
imga=imread('coins.png');
figure;
% imshow(imga);
theta=pi/4;
a = -tan(theta/2);
b = sin(theta);
shear1 = [1 a 0; 0 1 0; 0 0 1];
shear2 = [1 0 0; b 1 0; 0 0 1];
T1 = maketform('affine', shear1);
T2 = maketform('affine', shear2);
imgb = imtransform(imga,T1);
imgc = imtransform(imgb,T2);
imgd = imtransform(imgc,T1);
% imshow(imgb);
% imshow(imgc);
% imshow(imgd);
rotation = [cos(theta) -sin(theta); sin(theta) cos(theta)];
imge = rotation*imga;
imshow(imge);

Antworten (1)

KSSV
KSSV am 27 Mär. 2019
You cannot work like that...you need to get locations of pixels and then multiply these locations to the rotation matrix. YOu may refer this link for the same question.

Kategorien

Mehr zu Geometric Transformation and Image Registration finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by