inverse Fourier transform error
3 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
採用された回答
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 件)
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).
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!