Matlab FFT conj Ifft

384 Views Asked by At

i have 2 questions 1) How can i get something to work 2) Why does it do what it does.

1) In matlab i have an image. On the image i apply the function (-1)^(x+y) in order to center the DFT (fft). In my next step, i infact take the FFT of the image. Then, i would like to calculate the Complex Conjugate of the DTF. The convert back to the image. We should see that the image has rotated 180degrees

I cannot get my matlab code to work when i try and iFFT, it returns a double. How can i have it return back to the image(sizex, sizey), so i can apply the (-1)^(x+y) to get back to the original image.

2) Why does taking the complex conjugate in the freq domain rotate the image back in the spatial domain?

for i=1:1:sizex
   for j=1:1:sizey
       newImage(i,j) = img(i,j) * (-1)^(i+j);
%          newImage(i,j) = img(i,j);
   end
 end

%We then convert the new Centered image to Freq domain

DFTimage = fft(newImage); 

CCImage = conj(DFTimage);

iDFTImage = ifft(CCImage);
FINAL_IM = uint8(real(iDFTImage));
for i=1:1:sizex
   for j=1:1:sizey
       newImage2(i,j) = FINAL_IM(i,j) * (-1)^(i+j);
%          newImage(i,j) = img(i,j);
   end
end