matlab - MATLAB 中的反向谱图 A La Aphex Twin

标签 matlab image-manipulation signal-processing fft inverse

我正在尝试将图像转换为 MATLAB 中的音频信号,方法是将其视为频谱图 as in Aphex Twin's song on 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 的图像处理工具箱来读取图像。目标是有一些变化

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

alt text alt text

最佳答案

这里有一些小的误解。

我将按照发生的顺序而不是严重程度来解决问题:

1) spectrogramWindow (image) 计算中的失一误差

第一个数组条目应该是 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];

关于matlab - MATLAB 中的反向谱图 A La Aphex Twin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1230906/

相关文章:

matlab - 加强 MATLAB 中矩阵的显示

string - 比较字符串的最后一个字符

image - 模拟设备背光对人类图像感知的影响

java - 让我的 Java 程序通过拖放来显示图像

c - 我的c程序退出时如何创建文件?

iphone - 如何在 iOS 上比较两个语音样本?

Matlab:不正确的索引矩阵引用(或 outsmarting matlab)

matlab - 如何在 Matlab 中旋转 2D 散点图

css - 相对于设置为位置 :fixed 的流体宽度元素的位置内容

MATLAB - FFT 中缺少基础