what is wrong with ifft process on this image?

20 ビュー (過去 30 日間)
2NOR_Kh
2NOR_Kh 2023 年 4 月 13 日
コメント済み: 2NOR_Kh 2023 年 10 月 9 日
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 件のコメント
Walter Roberson
Walter Roberson 2023 年 4 月 13 日
Sorry, I do not know how to use hilbert transform.
William Rose
William Rose 2023 年 4 月 13 日
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.

サインインしてコメントする。

採用された回答

William Rose
William Rose 2023 年 4 月 13 日
img = imread("cameraman.tif");
figure, subplot(121); imshow(img); title('Original');
[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));
img_fft=fft2(img);
img_back=abs(ifft2(img_fft))/m;
subplot(122); imshow(img_back); title('Returned Image')
Try it.
  2 件のコメント
2NOR_Kh
2NOR_Kh 2023 年 4 月 13 日
I have to also apply fftshift and abs on my signal then apply some changes on the spectrum and agter those changes taking the signal back to time domain.
So, I need to reconstruct my time domain signal from the:
FE=fftshift(abs(fft(liver_padd(:,1))));
which liver padd is a RF ultrasound scan of liver and liver_padd(:,1) is the first line of this data.
William Rose
William Rose 2023 年 4 月 13 日
Your original question was why your script using fft2() and ifft2() did not return the original image. @Walter Roberson explained why the script failed: you lost the phase info by using abs() on the FFT of the image. I gave an example of how to use fft2() and ifft2() to get back the original image.
It seems to me like you are now asking a different question: how to filter and reconstruct a 1D time domain signal which is embedded as column 1 of a 2D RF ultrasound scan. That is a good quesiton but it is quite different. Do I understand correctly? If so, I suggest you attach a sample liver_padd image which includes the time domain signal as column 1.
What is the sampling rate of the 1-D time-domain signal? Is the time domain signal the position of a vessel edge as a function of time?

サインインしてコメントする。

その他の回答 (1 件)

Mehri Mehrnia
Mehri Mehrnia 2023 年 10 月 9 日
what is that division by m??
  1 件のコメント
2NOR_Kh
2NOR_Kh 2023 年 10 月 9 日
to normalize the pixel values. but if you use a different function than imshow, you maght not need it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by