image rotation by application of a 2D rotation matrix

조회 수: 7 (최근 30일)
Nastassja Riemermann
Nastassja Riemermann 2019년 3월 27일
답변: KSSV 2019년 3월 27일
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);

답변 (1개)

KSSV
KSSV 2019년 3월 27일
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.

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by