有没有一种方法可以将频谱图转换回信号 [英] Is there a way to invert a spectrogram back to signal

查看:73
本文介绍了有没有一种方法可以将频谱图转换回信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的算法中,我创建了一个频谱图并对数据进行了处理:

In my algorithm I created a spectogram and did manipulation on the data:

import scipy.signal as signal

data = spio.loadmat(mat_file, squeeze_me=True)['records'][:, i]
data = data- np.mean(data)
data = data/ np.max(np.abs(data))
freq, time, Sxx = signal.spectrogram(data, fs=250000, window=signal.get_window("hamming", 480), nperseg=None, noverlap=360, nfft=480)
// ...
// manipulation on Sxx
// ...

是否有将频率,时间和Sxx恢复为信号状态的信号?

Is there anyway to revert the freq, time, and Sxx back to signal?

推荐答案

否,这是不可能的.要计算频谱图,您可以将输入的时域信号划分为(半重叠)的数据块,每个数据块均乘以相应的 FFT ,为您提供一个复杂的向量,该向量指示每个频率仓的幅度和相位.频谱图的每一列最终都是通过取一个FFT的绝对平方来形成的(通常您会丢掉负频率,因为PSD对于真实的输入信号是对称的).通过取绝对平方,您将丢失任何相位信息.这使得不可能准确地重建原始的时域信号.

No, this is not possible. To calculate a spectrogram, you divide your input time-domain signal into (half overlapping) chunks of data, which each are multiplied by an appropriate window function, after which you do a FFT, which gives you a complex vector that indicates the amplitude and phase for every frequency bin. Each column of the spectrogram is finally formed by taking the absolute square of one FFT (and normally you throw away the negative frequencies, since a PSD is symmetric for a real input signal). By taking the absolute square, you lose any phase information. This makes it impossible to accurately reconstruct the original time-domain signal.

由于您的耳朵不在乎相位信息(您的大脑会感觉到类似于声谱图的东西),因此可能有可能重构出一个声音大致相同的信号.基本上可以通过相反地执行所有上述步骤,同时为FFT选择一个随机相位来完成.

Since your ear doesn't care about phase information (your brain would sense something similar as a spectrogram), it might however be possible to reconstruct a signal that sounds approximately the same. This could basically be done by doing all the described steps in reverse, while choosing a random phase for the FFT.

请注意,您的代码存在一个问题:您创建了一个名为 signal 的变量,该变量隐藏"了以相同名称导入的scipy.signal模块.

Note that there is one issue with your code: you create a variable named signal, which 'shadows' the scipy.signal module which you import with the same name.

这篇关于有没有一种方法可以将频谱图转换回信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆