필터 지우기
필터 지우기

inverse Fourier transform error

조회 수: 2 (최근 30일)
Xin Yang
Xin Yang 2015년 6월 10일
댓글: Xin Yang 2015년 6월 11일
Dear all, I have a question regarding inverser fourier transform.
I have the following code:
Test=imread('test.png');
FFT_Test=fft2(Test);
IFFT_Test=ifft2(FFT_Test);
Abs_FFT=abs(FFT_Test);
Angle_FFT=angle(FFT_Test);
Recon_FFT=Abs_FFT.*exp(i*Angle_FFT);
Result=ifft2(Recon_FFT);
I assume that "Result" and "IFFT_Test"/"Test" should be exactly the same, without imaginary part. However, it is not. The "abs(Result)" is the same as "IFFT_Test"/"Test", however, there appears some random phase in the "Result", which is really weird. On the left is my test image, and on the right is the random phase I get in the "Result". Can anybody help me?
Thanks a lot!

채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 10일
How are you doing the display of the images?
image(uint8(real(Result)))
looks fine to me for the images I tested with.
Result has some residual complex components, and will be of class double but with values nominally from 0 to 255 (but due to round-off you might get a slight negative value). Your original image is probably uint8(). The display routines treat double() color information differently than uint8() color, treating double() outside the range 0 to 1 as an error for 3D arrays (color images) and treating double() as 1-based indexing into the color map for 2D arrays (grayscale or two-level). uint8() 3D arrays are RGB Truecolor, and uint8() 2D arrays are 0-based indexing into the color map.
  댓글 수: 1
Xin Yang
Xin Yang 2015년 6월 10일
Hi, Walter,
Thanks for the answer! However, I am not sure that I understand why there is the complex residue in "Result". It's very small, but if there anything I can do to make sure the complex residue go away, and get double real numbers back?
Thanks a lot!
Xin

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Albatross
Albatross 2015년 6월 11일
Matlab fft and ifft calculates the discrete Fourier transform column-wise on a multi-dimensional array. I think you may need to do a non-conjugate transpose on your result array 'IFFT_Test' (.' is non-conjugate transpose) and then calculate the magnitude and phase of the transposed array. You will also need to do an fftshift but I don't know the order in which you will need to this, fftshift then transpose or transpose then fftshift. You will have to do this by trial and error.
It might be easier to use the dim argument in the (i)fft to perform the Fourier transform row-wise on your input array: (from Matlab help)
Y = fft(X,[],dim) and Y = fft(X,n,dim) applies the FFT operation across the dimension dim.
Use the dim argument on both the fft and ifft. If you do this then you should not need to transpose your array nor will you need to use fftshift (I think).
  댓글 수: 1
Xin Yang
Xin Yang 2015년 6월 11일
Thank you a lot! That's very helpful!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by