CST 205 Image Portfolio

Rose-colored Glasses

To create a “rose-colored glasses” effect, I iterated through each pixel and maintained the red color value of each pixel while reducing both the green and blue levels. I reduced the green values to 50% of the original value and reduced the blue values to 75% of the original value.

Original photo of me and Phoenix

Photo of me and Phoenix with the rose-colored filter applied

Negative

To produce a negative effect, we find the opposite color value of the existing RGB color value in a picture. To do this, we subtract an RGB color from the maximum color value (white, or rgb(255, 255, 255)). For example, if a pixel is already perfectly white, we subtract 255 – 255 for each value RGB and wind up with rgb(0,0,0) which is black.

Original photo of Christmas chicken.

Negative of Christmas chicken

Better Black and White

To create this better black and white effect, we calculate a luminance value, which applies weights to the pre-existing values of red, green, and blue of each pixel. In grayscale photos, the values of RGB are nearly equivalent.​

Original group photo of SCSI Logic

Group picture converted to grayscale

Mirror: Bottom to Top

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. To mirror an image horizontally, from bottom to top, the pixels from the bottom half of the image are copied to the top half of the image.

Original image of Mui, my whitefaced cockatiel.

Mui mirrored, bottom to top

Shrink

To shrink a photo by some factor (here it is shrunk by a factor of two–creating a photo half the original size), we copy every nth (every 2nd) pixel to a canvas that is of the target size (half the width and height of the original).

Original hacker cockatiel

Photo shrunk by half

Collage

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:

Collage

Remove Red Eye

To remove red eye from a photograph, 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 to match the color of the pupils).

Photo before redeye correction

Photo after redeye correction

Color Artify

To create the cartoony effect of artify, we had to iterate through each pixel to attain a color value and change each RGB color value. The weight by which we changed the red, green, and blue value of a pixel depended on the original color value.

Original photo of bike

“Artified” version of bike

Green Screen

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):

Green screen photo

Volcano background

Shia defeating the volcano

THANKSGIVING CARD

I had the idea to produce a card that gave an effect that each person (or animal) was looking through a cardboard cutout of a Thanksgiving themed scene. In collaboration with my partner, I developed a function similar to the green screen problem, where if the background picture’s pixels were within a reasonable distance from a true white color, to copy the pixels from a face picture on to the target canvas. Once this was completed, we came up with a way to resize an image’s height or width so that it would fit reasonably well in each cut-out hole. Last, we produced a function that wrote a message. We decided it would be a neat affect to produce two copies of the message, printed with a slight offset to produce a shadow effect.

Thanksgiving card

Line drawing

To produce a line drawing effect, we first converted a color photo to grayscale. Then, we were able to iterate through each pixel and compare the luminance of the current pixel to the pixel below and the one to the right of it. If the differences between the current pixel and the one below AND the current pixel and the one to the right were great enough, we changed the current pixel to BLACK. Otherwise, we changed the current pixel to WHITE. I created two solutions, which will be explained and illustrated below.

Original photo of San Diego State University

Line drawing of San Diego State University

In my first solution, rather than using the abs() function to calculate the difference between the luminance values of two pixels, I applied JES’ existing distance() function to compare two Colors of pixels that had already been converted to grayscale. This seemed to have the equivalent result as taking the absolute value of the difference between two luminance values. However, it also occurred to me that it is not necessary to first iterate through all the pixels to create a black and white photo. Instead, you could just calculate the luminance of the current pixel (and the ones below and to the right) and make the comparison. This way you would only have to change the color values once rather than twice. This may be more efficient in the long run, but I did not apply it here.

In my second solution, I learned about using lambda functions from this tutorial so I could get the luminance values of the relevant pixels on each iteration of the inner loop. This allowed me to skip the step of unnecessarily converting the photo to grayscale first. Then I was able to use the abs() function to calculate the difference between the luminance values of two pixels. I found that as long as the difference was greater than 5, I received good results on the photos that I tested. The types of photos I tested were landscapes, portraits, and pictures of inanimate objects that had varying ranges of colors.