How do I take the FFT and then the IFFT of an image?

42 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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.
  1 个评论
Walter Roberson
Walter Roberson 2015-7-13
When you start with real data, then after the fft then ifft, the only imaginary part that should be present is due to round-off error. Although taking abs() instead of real() would numerically reduce the round-off error, using uint8() round()'s the data and the round-off error will never be large enough to make a difference on the round() step. There results of uint8(real(IFF)) and uint8(abs(IFF)) would be the same in these circumstances, but uint8(real(IFF)) would require less processor work.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by