% Fourier Transform Linear Operator Demo
close all; clear all;
% Create a white box on a black background image
M= 256; N = 256;
image1 = zeros(M,N);
box = ones(64,64);
%box at centre
image1(97:160,97:160) = box;


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


% Create another  white box on a black background image
M= 256; N = 256;
image2 = zeros(M,N);
box = ones(32,32);
%box at centre
image2(37:68,37:68) = box;


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

% Make composite image
image3 = image1 + image2;

figure(3)
imshow(image3)
title('Image 3');

% Compute Fourier Transforms.

imft1 = fft2(double(image1));
imft2 = fft2(double(image2));
imft3 = fft2(double(image3));

figure(4)
imagesc(abs(fftshift(imft1) + fftshift(imft2)))
title('Image 1 + Image 2 Spectra');

figure(5)
imagesc(abs(fftshift(imft3)))
title('imft3 Spectra');

figure(6)
imagesc(abs(fftshift(imft1) + fftshift(imft2) - fftshift(imft3)))
title('Difference (Image 1 + Image 2) - imft3 Spectra');

figure(7)
imshow(ifft2(imft1 + imft2));
title('Inverse FT of imft1 + imft2');





