%This demonstrates image rotation of the clown by 45 degrees.
clear;load clown.mat;X(201,201)=0;theta=pi/6;
N=size(X,1);SN=round(sqrt(2)*N);X(SN,SN)=0;Y(SN,SN)=0;%Zero-pad image so can rotate it.
figure,imagesc(X),colormap(gray),axis off,title('Zero-padded clown image')
A=[cos(theta),sin(theta);-sin(theta),cos(theta)];%Rotation matrix.
I=[floor([0:N^2-1]/N)',mod([0:N^2-1],N)']+1;
IS=(N+1)/2;JS=round(IS*sqrt(2));
I=I-IS;J=round(I*A);I=I+IS;J=J+JS;%Shift center of image to origin for rotation.
Y(SN*(J(:,1)-1)+J(:,2))=X(SN*(I(:,1)-1)+I(:,2));%Rotate image.
figure,imagesc(Y),colormap(gray),axis off,title('Clown image rotated by 45 degrees')
