%% dft2demo4
% show symmetrically replicated image and log of shifted |DFT|

% S. Allen Broughton
%% get image
  load clown
% load chess
% load mandrill
X = X-mean(X(:));
Y = X;
Y = [Y,fliplr(Y)];
Y = [Y;flipud(Y)];

%% get 2D FFT of image
sFX = fftshift(fft2(X)); 
sFY = fftshift(fft2(Y)); 

%% display results 
figure(1)
subplot(2,2,1)
imagesc(X), colormap(gray)
title('original')
disp('Press a key'); pause;

subplot(2,2,2)
imagesc(log(1+abs(sFX))), colormap(gray)
title('original: log(1+|dft|)')
disp('Press a key'); pause;

subplot(2,2,3)
imagesc(Y), colormap(gray)
title('symmetric extension')
disp('Press a key'); pause;

subplot(2,2,4)
imagesc(log(1+abs(sFY))), colormap(gray)
title('symmetric extension: log(1+|dft|)')