%pylab inline
from __future__ import print_function
from __future__ import division
Populating the interactive namespace from numpy and matplotlib
import wave
from scipy.io import wavfile
img = imread('sources/gc.jpg')
imshow(img)
<matplotlib.image.AxesImage at 0x11138ef90>
#images
subplot(131)
imshow(img[:,:,0])
colorbar()
subplot(132)
imshow(img[:,:,1])
colorbar()
subplot(133)
imshow(img[:,:,2])
colorbar()
gcf().set_figwidth(15)
#images grey
subplot(131)
imshow(img[:,:-30,0], cmap=cm.gray)
colorbar()
subplot(132)
imshow(img[:,:-30,1], cmap=cm.gray)
colorbar()
subplot(133)
imshow(img[:,:-30,2], cmap=cm.gray)
colorbar()
gcf().set_figwidth(15)
imshow(img[:,:,0] + img[:,:,1], cmap=cm.gray)
colorbar()
<matplotlib.colorbar.Colorbar at 0x111141b90>
imshow(img[:,:,0]/2 + img[:,:,1]/2, cmap=cm.gray)
colorbar()
<matplotlib.colorbar.Colorbar at 0x110cd5250>
imshow(img[:,:,0].astype(int16) + img[:,:,1].astype(int16), cmap=cm.gray)
colorbar()
<matplotlib.colorbar.Colorbar at 0x110f7d090>
imshow(sum(img, axis=2), cmap=cm.gray)
colorbar()
<matplotlib.colorbar.Colorbar at 0x114147c90>
#red
red_only = img.copy()
red_only[:,:,1] = 0
red_only[:,:,2] = 0
imshow(red_only)
<matplotlib.image.AxesImage at 0x118b03dd0>
#green
green_only = img.copy()
green_only[:,:,0] = 0
green_only[:,:,2] = 0
imshow(green_only)
<matplotlib.image.AxesImage at 0x1150728d0>
#blue
blue_only = img.copy()
blue_only[:,:,0] = 0
blue_only[:,:,1] = 0
imshow(blue_only)
<matplotlib.image.AxesImage at 0x11130c9d0>
#signal shape
sig = img[120,:, 1]
plot(sig)
sig.dtype
dtype('uint8')
sigout = list((sig.astype(int16) - 100) * 200)*30
plot(sigout)
[<matplotlib.lines.Line2D at 0x11484d790>]
#soundfile1
wavfile.write('sources/gc.wav', 44100, array(sigout, dtype=int16))
import IPython
IPython.display.Audio("sources/gc.wav")
#soundfile2
audioout = array(((img[:,:,0].astype(int16)- 100) * 200).flat)
wavfile.write('sources/gc2.wav', 44100, audioout)
IPython.display.Audio("sources/gc2.wav")
#soundfile3
audioout = array(((img[:,:,1].astype(int16)- 100) * 200).flat)
wavfile.write('sources/gc3.wav', 3000, audioout)
IPython.display.Audio("sources/gc3.wav")