image rotation by application of a 2D rotation matrix

5 visualizaciones (últimos 30 días)
Nastassja Riemermann
Nastassja Riemermann el 27 de Mzo. de 2019
Respondida: KSSV el 27 de Mzo. de 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);

Respuestas (1)

KSSV
KSSV el 27 de Mzo. de 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.

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by