% Illustration of 2D FFT
%
% Samuli Siltanen Nov 2015

% Read in the image
im = imread('BigBen.jpg','jpg');
im = double(im);

% Compute the FFT
imF = fft2(im);

% Modify the transform (filtering)
imF2 = fftshift(imF);
tmp  = imF2;
tmp(...
    round(0.4*end):round(0.6*end),...
    round(0.4*end):round(0.6*end)) = 0;
imF2 = imF2-tmp;
%imF2 = fftshift(imF2);
imF2 = fftshift(tmp);


% Inverse transform
result = real(ifft2(imF2));

% Show image and FFT
figure(1)
clf
subplot(1,3,1)
imagesc(im)
colormap gray
axis equal
axis off
subplot(1,3,2)
imagesc(log(abs(fftshift(imF2))))
colormap gray
axis equal
axis off
subplot(1,3,3)
imagesc(result)
colormap gray
axis equal
axis off