# MAT-201A ASSIGNMENT 1¶

Sonification on an Image Here I have used a spiral image and performed some operations on it to produce audio which is in the audible range for humans. The image I have used here is a spiral image which helps in developing a more pronounced waveform.

In [15]:
%pylab inline
from __future__ import print_function
from __future__ import division
import IPython

Populating the interactive namespace from numpy and matplotlib

In [16]:
from scipy.io import wavfile

In [17]:
img = imread('image2.png')


Using a spiral grayscale image to create more pronounced sounds

In [18]:
imshow(img)

Out[18]:
<matplotlib.image.AxesImage at 0x1100a73d0>

Plotting the image as a signal, by going along column 550.

In [19]:
sig = img[550,:, 1]
plot(sig)
sig.dtype

Out[19]:
dtype('float32')

Multiplying the obtained signal with a cosine oscillator and then writing it to an output file. The obtained signal is made to go through amplitude modulation , by multiplying it with a cosine function, in order to modify the audio to get a dip and rise in the audio ,and hence a different more visibly variable audio.

In [39]:
wt = linspace(0, pi, 1280)
ossilation=cos(wt)
audioout = array(((img[550,:,0].astype(int16))))
final2=audioout*ossilation
plot(final2)

wavfile.write('output1.wav', 441000, final1)
IPython.display.Audio (data=final2, filename=None, url=None, embed=True, rate=44100, autoplay=False)

Out[39]:

Performing the same function but on the flattened array of the image above. This is done so as to realise what the complete image would sound like instead of just one coloum of the image.

In [38]:
wt = linspace(0, 100 * pi, 1310720)
ossilation=cos(wt)
audioout = array(((img[:,:,0].astype(int16))).flat)
final=audioout*ossilation*8000
plot(final)
xlim(0,20000)

wavfile.write('output2.wav', 44100, final)
IPython.display.Audio (data=final, filename=None, url=None, embed=True, rate=44100, autoplay=False)

Out[38]: