已经检查了这个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);
问题1:&#34;为什么在分配新像素值后imshow中的输出会给出三个不同的图像作为输出红色,绿色,蓝色。有没有办法解决它并获得一个图像作为输出?&#34;
问题2:&#34;我将负坐标转换为正数是否可以?&#34;
注意:这是作业问题,我不是要隐藏它。但是需要帮助