查看单个帖子
旧 2019-12-10, 16:49   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 MATLAB中的反频谱图A La Aphex Twin

我试图通过将其视为一个频谱将图像转换成音频信号在MATLAB 中的Aphex双对Windowlicker歌曲 。不幸的是,我很难获得结果。

这是我目前所拥有的:

function signal = imagetosignal(path, format) % Read in the image and make it symmetric. image = imread(path, format); image = [image; flipud(image)]; [row, column] = size(image); signal = []; % Take the ifft of each column of pixels and piece together the real-valued results. for i = 1 : column spectrogramWindow = image(:, i); R = abs(ifft(spectrogramWindow)); % Take only the results for the positive frequencies. signalWindow = R(1 : row / 2.0); signal = [signal; signalWindow]; end end 因此,我要对图像的列进行傅立叶逆变换,然后将它们放在一起以形成信号。同样,此功能使用MATLAB的Image Processing Toolbox读取图像。目的是要对

spectrogram(imagetosignal('image', 'bmp')); 结果看起来像原始图像。我将不胜感激任何帮助!我只是在学习信号处理,所以如果有明显的误解,请不要感到惊讶。谢谢!

编辑 :谢谢戴夫!我知道了!我结束了这个:

function signal = imagetosignal(path, format) % Read in the image and make it symmetric. image = imread(path, format); image = [image; flipud(image)]; [row, column] = size(image); signal = []; % Take the ifft of each column of pixels and piece together the results. for i = 1 : column spectrogramWindow = image(:, i); signalWindow = real(ifft(spectrogramWindow)); signal = [signal; signalWindow]; end end


回答:
这里有一些小的误解。

我将按照出现的顺序而不是严重性来解决问题:

1)SpectrogramWindow计算中的一一错误(图片)

第一个数组项应该是0Hz的分量,下一个是N Hz。数组的最后一个元素应该是-N Hz的分量。但是,您已经计算出0Hz。

我不确定matlab的语法,但是如果您按原样翻转图像,然后在将其追加到原始图像之前先去除顶部和底部的线条,则应该进行设置。

或者,您可以考虑不将图像附加到自身,并从图像中提取spectrogramWindow之后,应用一些函数使其对称于厄米。

2)采取IFT的原则。没必要。不要那样做

如果iFFT得到正确的输入,您从iFFT中得到的结果将是完全真实的。

如上所述,您会看到复杂的值,因为输入实际上不是Hermitian对称的。切勿使用Abs()。如果必须作弊,请提取实部,该实部不会从虚构部分折叠成垃圾。

3)您将丢弃信号的后半部分。

从iFFT获得输出后,即表示您要的信号。不要以频率来考虑它,它现在是一个音频时间序列。保留整个东西。

这是我的看法:

spectrogramWindow = image(:, i); spectrogramWindow = [spectrogramWindow;reverse(spectrogramWindow(skip first and last))] signalWindow = ifft(spectrogramWindow); signal = [signal; signalWindow];

更多&回答...
poster 当前离线   回复时引用此帖