Jonathan's CS 151 Project 4
Skip to end of metadata
Go to start of metadata

Overview:

The purpose of this project was to start understanding how to filter and alter real pictures by changing different pixels. In order to do this we used for loops, if statements and a new type of file known as ppm files. Using these commands we were able to put different filters on pictures such as a dim and brighten filters. An example of how I utilized if statements is below:


Looking at the above code for my dimming filter, it is clear to see how I successfully coded this effect. By taking all the values of each color over 100 and subtracting them by 100, I made the image much darker than it originally was. In addition, if there were any values of the color that were below 100, it would automatically send those values to 0. This code successfully dimmed by image. 
Below are a few of the filters that I applied to my image:

From left to right, I used a black and white filter, a brighten filter, a filter that swapped red pixels with blue pixels, and a dimming filter. Most of these codes were very similar. They all used if statements to determine which pixels got filtered and which pixels remained the same color. If statements proved to be extremely helpful during this project. 
My next task was to put all four of these Pixmaps on the same screen. In order to do this, we used a file called warhol to call all four of the Pixmaps at the same time. The most essential part of this code was determining where each pixmap went on the larger screen. Below is a snippet of my code that shows how we were able to call all 4 of the pixmaps:

With the code in place, we were able to successfully call all four of the images:

My last task was to change the green screen color to a different color without affecting any of the pixels that made up my body. Again, I used if statements to tell python which pixels to change. Below is the function for my green screen effect:

The if statement informs python which pixels to change, and the line just below that sets the background color. Here are the final products:

Extensions:
For my first extension I made a more complicated warhol collage. I added 3 more blocks of my 4 filter images, and made one of the blocks two totally different images. Below is what my first extension looks like:

My second extension dealt with making a more complicated background for my green screen effect. I utilized the random function in order to get an interesting looking background. Below is what my random background color looks like:

My last extension was one that was very tricky and required help from my friends in upper level CS classes. I decided to make an attempt at blurring my original image. While it did not blur a considerable amount, it definitely added some blur. Below is my blurred image:


What I learned: This project taught me many extremely useful tools. First, I definitely honed my skill on using if statements. This was really the most import piece to the entire project, as it let us determine which pixels to change and which pixels to keep the same. Another useful tool that we learned during this project was the use of a show.py fie. PPM files are tricky, because we can call them in the terminal but they will not show up. The show.py file allowed us to load the picture in python, then display it using this file. Overall, I learned many useful skills during this project. 

Acknowledgments: Prof. Taylor, Vlad Murad, Chris Shaffrey and Matt Martin

Labels