MATLAB: How to take the FFT and then the IFFT of an image

3.0imageImage Processing Toolboxprocessingr12toolbox

If I take the FFT of an image and then take the IFFT of it, I do not get the original image back. All I get is a black image.

Best Answer

The FFT function will return a complex double array. If you read in a .JPG or a .TIF file, you will notice that they are UINT8 arrays. So, you will have to take the real part of the IFFT and then convert it back into UINT8. Try the example below:
IM=imread('flowers.tif'); % Read in a image
whos
image(IM); % Display image
FF = fft(IM); % Take FFT
whos
IFF = ifft(FF); % take IFFT
whos
FINAL_IM = uint8(real(IFF)); % Take real part and convert back to UINT8
whos
figure
imshow(FINAL_IM) % Get back original image.
The WHOS calls in the above code will output the stored variable information so you can see where the conversion to UINT8 is taking place.
Related Question