% Fourier Transform Rotate Operator Demo
close all; clear all;
% Define Initial box

xwidth = 64;
ywidth = 32;

% Create a white box on a black background image
M= 256; N = 256;
image1 = zeros(M,N);

x0 = M/2 - xwidth/2;
y0 = N/2 - ywidth/2;

box = ones(xwidth,ywidth);
%box at centre
image1(x0:x0+xwidth-1,y0:y0+ywidth-1) = box;

% Define Rotation in degrees
rot = 45; 
image2 = imrotate(image1, rot,'bilinear','crop');

figure(1)
imshow(image1);
title('Image 1');

figure(2)
imshow(image2);
title('Image 2');

% Compute  Fourier Transfoms.

imft1 = fftshift(fft2(double(image1)));
imft2 = fftshift(fft2(double(image2)));


figure(3)
imagesc(abs(imft1))
title('Fourier Transform of Image 1 (imft1)');

figure(4)
imagesc(abs(imft2))
title('Fourier Transform of Image 2 (imft2)');

