我正在尝试通过谱减法来增强超声信号。该信号在时域中,并且包含噪声。我已将信号划分为2微秒的汉明窗口,并计算了这些帧的傅里叶变换。然后,我选择了3个连续的帧,我将其解释为噪声。我平均了这3帧的幅度谱,并从每一帧的幅度谱中减去了平均值。然后,我将所有负的幅度谱定义为零,并通过将新的幅度谱与相位谱相结合来重建增强的傅立叶变换。这为我提供了一系列每帧的复数。现在我想用傅立叶逆变换把这个序列转换回时域。然而,这个操作为我提供了一个我不知道如何使用的复数。
我在几篇文章中读到,从逆傅立叶变换获得复数输出是正常的。然而,复数的使用是分开的。有些人说忽略虚构的部分,因为它应该非常小(e-15),但在我的例子中它是不可忽略的(0.01-0.5)。老实说,我现在不知道如何处理这些数字,因为我希望傅立叶逆变换只给出实数。希望是很小的虚构部分,但不幸的是..
# General parameters
#
total_samples = length(time_or) # Total numbers of samples in the current series
max_time = max(time_or) # Length of the measurement in microseconds
sampling_freq = 1/(max_time/1000000)*total_samples # Sampling frequency
frame_length_t = 2 # In microseconds (time)
frame_length_s = round(frame_length_t/1000000*sampling_freq) # In samples per frame
overlap = frame_length_s/2 # Overlap in number of frames, set to 50% overlap
#
# Transform the frame to frequency domain
#
fft_frames = specgram(amp, n=frame_length_s, Fs=125, window=hamming(frame_length_s), overlap=overlap)
mag_spec=abs(fft_frames[["S"]])
phase_spec=atan(Im(fft_frames[["S"]])/Re(fft_frames[["S"]]))
#
# Determine the arrival time of noise
#
cutoff= 10 #determine the percentage of the signal that has to be cut off
dnr=us_data[(length(us_data[,1])*(cutoff/100)):length(us_data[,1]), ]
noise_arr=(length(us_data[,1])-length(dnr[,1])+min(which(dnr[,2]>0.01)))*0.008
#
# Select the frames for noise spectrum estimation
#
noise_spec=0
noise_spec=mag_spec[,noise_arr]
noise_spec=noise_spec+mag_spec[, (noise_arr+1)]
noise_spec=noise_spec+mag_spec[, (noise_arr+2)]
noise_spec_check=noise_spec/3
#
# Subtract the estimated noise spectrum from every frame
#
est_mag_spec=mag_spec-noise_spec_check
est_mag_spec[est_mag_spec < 0] = 0
#
# Transform back to frequency spectrum
#
j=complex(real=0, imaginary=1)
enh_spec = est_mag_spec*exp(j*phase_spec)
#
# Transform back to time domain
#
install.packages("pracma")
library("pracma")
enh_time=fft(enh_spec[,2], inverse=TRUE)
我希望有任何人对如何处理这些复数有想法。也许我之前在处理方法上犯了一个错误,但我已经检查了很多次,它对我来说似乎是很可靠的。这是该过程的最后一步,真正希望在傅立叶反变换后获得良好的时域信号。
发布于 2019-06-07 21:51:53
使用傅立叶变换转换数据时,一个基本的故障排除辅助工具是这样的概念:您可以进行fft,然后提取数据并进行逆fft,然后恢复原始数据……我建议你使用玩具输入的时域数据来做这件事。假设是一个1 Khz的音波,它是你的时域数据…将其发送到fft调用中,该调用将返回其频域表示的数组...不对该数据做任何处理,将其发送到逆fft ( ifft ) ...返回的数据将是您原始的1 Khz音频波形...现在就这样做,以获得它的力量的欣赏,并在您的项目中使用此技巧来确认您正在进行中……或者,如果你从频域数据开始,你也可以这样做...
freq domain data -> ifft -> time domain data -> fft -> same freq domain data
或
time domain -> fft -> freq domain -> ifft -> same time domain data
请在此处查看更多详细信息Get frequency with highest amplitude from FFT
https://stackoverflow.com/questions/56489571
复制相似问题