%% sliceswap.m
% show effect of translation on a DFT

% S. Allen Broughton -  1 Oct 10

%% define pics 
load mandrill
size(X)
Y = [X(:,251:500),X(:,1:250)];
Z = [X(241:480,:);X(1:240,:)];
W = fftshift(X);
figure(1)
subplot(2,2,1)
imagesc(X)
subplot(2,2,2)
imagesc(Y)
colormap(gray) 
subplot(2,2,3)
imagesc(Z)
colormap(gray) 
subplot(2,2,4)
imagesc(W)
colormap(gray) 

%% find and display DFTs
fX = fftshift(fft2(X));
fY = fftshift(fft2(Y));
fZ = fftshift(fft2(Y));
fW = fftshift(fft2(W));

figure(2)
subplot(2,2,1)
imagesc(log(1+abs(fX)))
colormap(gray)
subplot(2,2,2)
imagesc(log(1+abs(fY)))
colormap(gray)
subplot(2,2,3)
imagesc(log(1+abs(fZ)))
subplot(2,2,4)
imagesc(log(1+abs(fW)))
