已经检查了这个SO Question,但我的问题是如何在计算后对图像进行更改显示,并且代码会更好地解释,我已经标记了哪里是困惑的行:
% code written by Zulqurnain Jutt
img1 = imread('rotme.jpg');
img = img1;
[r,m] = size(img);
promt = 'Enter Angle to Rotate an image:=:';
x = input(promt);
% making antirotate matrix
coss = cos(x);
sinn = sin(x);
antirotate = floor( [coss -sinn 0;sinn coss 0; 0 0 1] );
for i=1:r
for j=1:m
%forming point matrix
pointMat = [i-1;j-1;1];
%multiplying both matrix
mul = floor(antirotate*pointMat);
% swapping points
if mul(1)<0
mul(1) = abs(mul(1));
end
if mul(2)<0
mul(2) = abs(mul(2));
end
img( (mul(1)+1) , (mul(2)+1) ) = img(i,j); % Here Lies my problem
end
end
imshow(img);
Problem 1: "Why the output in imshow after assigning the new pixel values giving me three different images as output red , green , blue. is there any way to fix it and get one image as output?"
Problem 2: "i am converting negative coordinates to positive is this okay?"
注意:这是作业问题,我不是要隐藏它 . 但需要帮助