Write a MATLAB code to rotate the image with (i)90 angle (ii) 180 angle (iii) 270 angle without using built in function



CODE:
clear all;
close all;
clc;
a=imread('cameraman.tif');
c=a;

x=256;
for i=1:256
    x=256;
    for j=1:256
        if x>1
        t(x,i)=a(i,j);
        end
        x=x-1;
    end
end


x=256;
for i=1:256
    x=256;
    for j=1:256
        if x>1
        s(x,i)=t(i,j);
        end
        x=x-1;
    end
end


x=256;
for i=1:256
    x=256;
    for j=1:256
        if x>1
        q(x,i)=s(i,j);
        end
        x=x-1;
    end
end


subplot(2,2,1);
imshow(c);
title('image of cameramen','color','r'); 
subplot(2,2,2);
imshow(t);
title('image of rotated 90 degree cameraman','color','m'); 
subplot(2,2,3);
imshow(s);
title('image of rotated 180 degree cameramen','color','r'); 
subplot(2,2,4);
imshow(q);
title('image of rotated 270 degree cameramen','color','m'); 

OUTPUT: