Using JES to manipulate sounds and images

One of the key topics for both GCSE and A-level Computing is data representation. Along with the usual number work (binary!) we are expected to look at how sounds and images are represented on a computer.

Whilst the theory behind this is not too complex – most students can appreciate what a pixel is and a sound sample – how it all hangs together to actually make an image and sound could do with being explored a bit further.

This year we have found JES (Jython environment for students) which provides a simple interface and functions that allow you to work with both images and sounds using Python code.

With a few lines of code you can pick an image file and then start to manipulate it pixel by pixel. It is quite easy to convert to greyscale or morph off into different colours.

jes4

A challenge was to take an original image of one caterpillar and then, with the same image size, turn it into a four smaller images.

jes5

It was great to come into a lesson and find one student having created a ‘musical expression of an image’. Basically his Python code looks at the pixel data of the image and represents the pixel data as a note. It was quite interesting to see how different images responded to his code and you could begin to pick up patterns and therefore relate how parts of the image created different sounds. Has the Mona Lisa ever been so musical?