what is wrong with ifft process on this image?
Show older comments
I want to apply some processing and changes on my 2D signal and then take it back to time/spatial domain by using ifft, but I dont know why the ifft gave me something weird. So I simplified it to a simple image and then applied fft and then ifft as the code below:
I expect the inverse fft gave me the image again but why this happens?
clear all;
img = imread("cameraman.tif");
figure, imshow(img);
[m, n]=size(img);
img_fft = fftshift(abs(fft2(img)));
img_fft_shifted = ifftshift(img_fft);
img_fft_mag = abs(img_fft_shifted);
img_back = abs(ifft2(ifftshift(img_fft_mag))/(m));
figure, imshow(img_back);
6 Comments
When you take the abs() of the fft2(), you are getting rid of all of the phase information and exaggerating the magnitudes.
Note that the result of abs() is not going to depend on whether you have shifted version or the original version, so doing the fft shift then abs then ifftshift is the same as just taking abs
Also note that the original data is uint8 but the processed data will not be.
format long g
img = imread("cameraman.tif");
figure, imshow(img);
processed = ifft2(abs(fft2(img)));
[min(processed(:)), max(processed(:))]
surf(processed)
rs = uint8(min(processed, 255));
imshow(rs)
Walter Roberson
on 13 Apr 2023
You can see that because of the abs(), the range of values you get returned is fairly high; if you imagesc() or imshow(img, []) to show the range scaled linearly, then you get an all-black output. You have to clip the values to get back something -- and that something will not look like the original because you lost the phase information.
William Rose
on 13 Apr 2023
@Walter Roberson, thank you for your comments. I always learn a lot from them.
2NOR_Kh
on 13 Apr 2023
Walter Roberson
on 13 Apr 2023
Sorry, I do not know how to use hilbert transform.
William Rose
on 13 Apr 2023
RF_Signal is a complex function of time. You do not need the phase part of this complex signal. YOu want to apply a filter to the magnitude spectrum of the signal and reconstruct the filtered signal from its spectrum, without its phase.
I do not think this is possible. This discussion is made more complicated by the fact that the complex signal has a phase in the time domain and a hase (which is different) in the frequency domain. You do not need the time domain phase informaiton. But you do need the phase info in the frequency domain in order to recontruct the original time domain signal. Throw away the time-domain phase info atthe very end, after you have done the frequency domain filtering and have done the inverse transform.
I could be wrong since I am not experienced with complex time domain signals.
One interesting feature of the HIlbert transform which may or may no be relevant is that it can filnd the minimum phase associated with an amplitude spectrum of the response of a causal system.
Accepted Answer
More Answers (1)
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




