File Exchange

image thumbnail

Hiding image in sound (im2sound)

version (2.42 KB) by Stephen
Converts an image into a sound file. Played through a spectrum analyser, the image is revealed.


Updated 13 Mar 2011

View License

This simple to use function hides images sounds. When played back though a spectrum analyser the image reappears. It is a technique which has been used previously by artists such as Aphex Twin, Venetian Snares and Nine Inch Nails.

The images are divided so one axis corresponds to time and the other corresponds to frequency space. The amplitude of each frequency is determined by the pixel intensity at that point.

Cite As

Stephen (2021). Hiding image in sound (im2sound) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

renitra r

I am have this problem, when click run the prog. the prog. asked me to enter the input argument by typing it?

mainText(filename, ext, f_sample, f_low, ...
f_high, amp_mod, sample_t)


Hi, sorry for the late reply.

With regards to the distortion the input parameters I found to have the most significant were the 'f_sample' (sampling frequency) and 'sample_t' (sample length).

The settings I found to be most suitable are listed at the top of the m-file. They are:
f_sample = 44000 (Hz)
f_low = 40 (Hz)
f_high = 6000 (Hz)
amp_mod = 0.00002
sample_t = 10 (seconds)

I used that sampling frequency because I believe it is the one used on music CDs. Alternatively, increasing t_sample will also improve image quality (decrease distortion), but then you end up with longer files.

I don't use any plugins with Sonic Visualiser, just the vanilla version from their website. I open the audio file, then click 'Pane', then 'Add Spectrogram'. Next I resize the spectrogram using the silver wheels on the bottom right of the black window, so the image is vaguely the same aspect ratio as the original image. I use the controls on the right of the image to fine tune the image till it appears clearest. With a sample_f = 44000Hz and t_sample = 10s I find the best settings in Sonic Visualiser are:
'Color' - 'Default'
'Scale' - 'dBV^2'
'Window' - '8192' '93.75%'
'Bins' - 'All Bins' 'Linear'

Finally I change the contrast using the dial to the right of the 'Scale' controls.

I'm not sure what you mean by "In which application this technique is used by artist's such as Aphex Twin". I assume you're asking which software he used to achieve this effect. Unfortunately I don't know how he did it, but as far as I can tell, however he did it the result is the same as using this m-file.

I've not really considered the applications of this technique beyond the entertainment value of being able to hide images in sound - such as putting them in songs as an 'Easter Egg'. I suppose you could encode secret messages at frequencies not audible to human hearing, but it wouldn't be very secure as this is very easy to decrypt. That would be more as a fun way of sending messages between friends than anything else.

I hope all that makes sense and answers your questions.


Chetan More

understood how to use sonicc visualiser. Thaks...
Got the original image reappeared,
but not same, some distortion are there, can we do something to remove distortions..
I am not getting what are the effects(use) of pluginsin the sonic visualiser.Tell which plugins are used for WINDOWS?.
In which application this technique is used by artist's such as Aphex Twin.. as told by you.
What will be the applications of this technique?

Chetan More

I am not getting, how to use sonic visualiser to reconstruct image from sound file.Will you give me some guidance, please..

Chetan More

y = wavread('filename') loads a WAVE file specified by the string filename, returning the sampled data in y. The .wav extension is appended if no extension is given. Amplitude values are in the range [-1,+1]
but i tried by using this but i am not getting to get exact brightness levels of pixel...
Please to help me related to this.
Just i wanna match matrix values..same as that of we got from image.


Hi, this m-file doesn't allow you to convert from sound to image, but you can do this using a spectral analyser. The one I like is called Sonic Visualiser (

If the sound has an image encoded in the frequency space as a function of time you should be able to see the image in the output.

I hope that helps.

Chetan More

Sir,are we able to convert sound into image? Please tell me if available..

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!