# Implementing rotation in frequency domain and map it back to spatial domain

Please consider the following small example:

x=im2double(imread('cameraman.tif'));
X=fft2(x);

Xr=imrotate(fftshift(X),90);

xRec=ifft2(ifftshift(Xr));

figure;
subplot(2,2,1);
imshow(x);
subplot(2,2,2);
imshow(xRec);
subplot(2,2,3);
imshow(log(fftshift(abs(X))+1),[]);
subplot(2,2,4);
imshow(fftshift(log(abs(fft2(xRec))+1)),[]);

%magnitudes of both have same total energy
sum(sum(abs(X)))-sum(sum(abs(Xr)))


the result xRec is indeed rotated by 90 degrees when reconstructed from rotated Fourier domain, but a dark band appears in the center. Can someone help me to implemented in the correct manner? The goal is of course to show the Fourier rotation property. That rotation in one domain is equivalent to rotation in the other. even more interesting, if i remove the ifftshift I almost get my rotated cameraman but with artefacts ! also some trick with polar coordinates is mentioned here (slide 22) ... but I would need help ...