Already checked This SO Question , but my question is how to make changes appear to image after the calculation , and code will explain better , i have marked the line where is am confused:
% 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?"
Note: it is homework question, and i am not hidding it. but is need help