image rotation by application of a 2D rotation matrix
    4 次查看(过去 30 天)
  
       显示 更早的评论
    
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);
0 个评论
回答(1 个)
  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. 
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

