我正在尝试将图像视为频谱图,从而在 MATLAB 中将图像转换为音频信号就像 Aphex Twin 的歌曲中那样舔窗者 http://www.bastwood.com/aphex.php。不幸的是,我很难得到结果。
这是我现在所拥有的:
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'));
结果看起来像原始图像。我将非常感谢任何帮助!我刚刚学习信号处理,所以如果有明显的误解,请不要感到惊讶。谢谢!
Edit:谢谢戴夫!我成功了!我最终得到了这个:
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