Week 2 of CST 205: Manipulating Pixels

Lab Reflection

This week we used loops and control statements to manipulate images.

Lab 4

In this independent lab, we created a variety of mirroring functions by iterating through the pixels of part of an image and copying the colors of those pixels to another part of an image. Here are some examples:

Original image of Mui, my whitefaced cockatiel.

Vertical mirror, left to right

Vertical mirror, right to left

Horizontal mirror, top to bottom

Horizontal mirror, bottom to top

Quadruple mirroring, using right to left and top to bottom mirroring

Lab 5

This was another independent lab. In this lab, we learned how to create a blank Picture object and to copy pixels from other pictures on to it. This enabled us to copy multiple pictures on to a large empty canvas, creating a collage. My approach was to iterate through a list of pictures and to apply random effects to each picture before it got copied on to the blank canvas. I also added my name to the bottom using the addTextWithStyle JES function. Here is one of the results:

LAB 6

In this pair programming lab, my teammates and I developed functions to manipulate pictures based on the color values of pixels. In the warmup problem, we had to implement red eye correction. Essentially, we had to detect pixels that were within some range of red (using a distance function) and to change those pixels’ color values to something that looked more natural (we chose black). Below is the before and after:

Photo before redeye correction

Photo after redeye correction

 

We then developed a function that created a sepia effect. This was done by first converting the photo to grayscale (when each value of red, green, and blue are essentially equivalent or close to being equivalent). Then, based on each pixel’s red amplitude, we modified the amount of red and blue. This created the sepia effect:

Original photo of salmon roe rice bowl

Sepia effect

 

We also created a function that created a fun posterizing, cartoony effect. This was a lot like the sepia function, in that the amount by which we changed the color of a pixel depended on the original color value. However in this case, we modified each color (red, green, and blue) based on the previous values of red, green, and blue. Here is the effect:

Original photo of bike

“Artified” version of bike

Last, we developed a chroma key function to add a background on to a green screen photo. Essentially, we had to detect the degree to which each pixel’s color matched the green color we expect the green screen to be. If it matched within a reasonable range, we copied the colors of the background photo (the volcano picture in the example) on to the green pixels of the green screen photo (the photo of Shia LeBeouf in this example):

Shia LaBeouf in front of a green screen

Volcano

Shia defeating the volcano

 

Leave a Reply

Your email address will not be published. Required fields are marked *