I'm trying to convert an image into an audio signal in MATLAB by treating it as a spectrogram as in Aphex Twin's song on Windowlicker. Unfortunately, I'm having trouble getting a result.
Here it what I have at the moment:
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
So, I'm taking Inverse Fourier Transforms on columns of my image and then putting them together to form a signal. Also, this function uses the Image Processing Toolbox for MATLAB to read in images. The goal is to have some variation of
spectrogram(imagetosignal('image', 'bmp'));
result in something that looks like the original image. I would very much appreciate any help! I'm just learning signal processing, so don't be surprised if there's an obvious misconception. Thanks!
Edit: Thanks Dave! I got it working! I ended up with this:
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