我试图通过将其视为频谱将图像转换成在MATLAB的音频信号作为Aphex Twin之间上场的歌上的 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

“替代文字” “替代文字”

有帮助吗?

解决方案

有一些小的误解这里。

我会去通过这些问题出现的顺序,而不是严重性:

1)差一错误在spectrogramWindow的计算(图像)

在第一阵列条目应该是0Hz时的部件,下一个是N赫兹。所述阵列的最后一个元件应该是-N赫兹的分量。但是,你已经计算为0Hz。

我不知道MATLAB的语法,但是如果翻转图像,你有,然后将其追加到原来之前剥去顶部和底部的线条,你应该设置。

此外,也可以考虑像不追加到自身,并从图像中提取spectrogramWindow,应用一些功能,使其埃尔米特对称之后。

2)服用IFT的腹肌。没必要。不要做。

你走出IFFT的是什么,如果IFFT得到正确的输入,完全是真实的。

您所看到的复数值,因为输入是不实际厄米对称的,如上所述。切勿使用ABS()。如果必须欺骗,提取的实部,这将不会从虚分量折叠在垃圾。

3)你扔掉后半部分的信号的

一旦你从IFFT,表示你问的信号输出。不要在频率方面想起来了,这是现在的音频的时间序列。保持整个事情。

下面就是我看到它:

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

其他提示

只是研究完全一样的东西,发现这个perl脚本。想你可能会喜欢的链接。

http://devrand.org/show_item.html?item=64&page=Project

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top