我正在尝试将图像转换为 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