Abstract:

The purpose of this project was to use Zelle's graphics package and manipulate the pixel colors of different images. The key to achieving project goals was to understand how Zelle's graphics package works. Broadly speaking, the following are some points that I needed to know to do this project: 1) how the image is created, placed, and saved 2) how the filter manipulates an image (i.e. pixels) and 3) how conditional statements (if) can be used to make the filters to have more complicated effects on specific pixels. Given the understanding of those points, I was able to create Warhol program. which created four filtered images and put them together in a square. Then, I created blueSceen program, which manipulated the background pixels in my own picture to different color – red.

Solutions:

Controlling image placement:

The function placeImage() is very important in this project because it's going to be used for both Warhol program and blueScreen effect program. It basically takes the rgb values of a source image, src, and copy those values to a destination image, dst. Why do I need to do this? Because this is what this project is about. What I am doing during the entire project is that I create some filters, apply the filters to an image, then place the filtered images to an empty or background image to create this Warhol collage. Two commands must be understood to write this function: getPixel and setPixel. They basically do what I described above. Get the RGB values of the selected pixels and set the pixels to the given color. Another necessary command to understand is the loop commands.

. This is how I select every single pixel in the image. If I want to manipulate every single pixel in an image, I need to use this loop.

Filtering:

I created following filters for the required part of the project: darker, blackAndwhite, and sepia. Below are results, respectively. The first is the original image.

.

The darker filter makes the image look darker by decreasing RGB values by same factor. If RGB value gets closer to zero, it will become darker. If all RGB values are zero, then the entire image would be black. Vice Versa.

The blackAndwhite filter works by averaging the RGB values and assigning the result to value to all three RGB values and pixels in the image.

The sepia filter multiplies the RGB values by the factor of value that would create sepia color (112, 66, 20).

I am not going to talk about swapRedBlue filter because it was created during lab.

Warhol Program:

Now I have to create Warhol program that would put those four filter images in a new blank image that is width*2 by height*2. Think a new blank image as a picture frame.

Here are the steps of how Warhol program works: 1) constructs an image from contents of the given file, i.e. arg[1], which means the user input. 2) make four copies of the image using clone() command. 3) apply the four filter programs to the four copies. 4) then create the picture frame. 5) put or place the four filtered images into the picture frame by using placeImage() function that was created in the first step of the project. 5) finally, save the result to a new file. The end-result would look like below.

.

Blue Screen Effects:

This task is basically about creating a filter that would manipulate specific pixels by using conditional statement.

.

Compare this with the loop command in the earlier part of this write-up. The difference is that the filter would only apply to the pixels which g value is 1.7 times the red value and bigger than the blue value. I added this condition because all I wanted to manipulate were the very green pixels of my background image.