In this project, I had to work with ppm images, create some effects and then make a collage.
This is the image I worked with.
First I created a putPixmap function which could paste a picture(source) on any destination picture at a given location. I then created some functions which changed the color of specified picture in many ways.
In the putPixmap function, I added a feature so that it would flip the picture when x= width of picture.
The code snippet looks like this:
if x == source.getWidth():
a = x + source.getWidth()
destination.setPixel(a - j, y + i, (r,g,b ) )
destination.setPixel(x + j, y + i, (r,g,b ) )
(Look carefully at the picture given below, the picture is flipped)
I used putMap function and those effects to create a collage which showed different color properties of the same picture.
I then created a testBlue function which can test if the pixel is very blue and change those pixels to stripes of different colors.
This picture shows how effective this code is. It even changed the blue color of my pant.
I created the function putPixmapWithoutBlue() to copy only the non-blue pixels of my image to create a scene.
I then tried to create bigCollage function which could take create a collage of five pictures. In this collage, the first picture on the command line will be the central picture and the remaining will be the corner pictures.If the there is one picture on command line,it would create four other versions of that image using the filters.
Similarly, if there are two pictures on command line, it makes a collage which has the first picture at the centre and second picture at the corners.
The pictures below show the collage if there are three, four and five images* as command line parameters.
(With five pictures)
I learned from this project that it is fun to work with the pixels. I also learned that I can too recreate some effects of photoshop using Python. In this project, I can more familiar with command line parameters.
*Downloaded from http://www.math.umbc.edu/~rouben/2003-09-math625/images.html