CSE120 Sp17 Assignment - Color Filters

Goals

Color Filters

Find a color photo that you'd like to use for this assignment. We will write a program that will display only the particular color components of the image (red, green, blue, cyan, magenta, yellow) when the user presses specific keys on the keyboard.

Demo Video: https://vimeo.com/166745625

Step 0: Displaying the Image

image - original Write a Processing program to display your chosen color photo.

Recall the following points:

Step 1: Extract a Color

image - red only Next we want to display only the red pixels when the user presses the 'r' key. Create an if-statement in a keyPressed() function to accomplish this. If the user clicks 'r', then refill pixels[] with only the red component of the pixels, as shown below:

pixels[i] = color( red(pixels[i]), 0, 0 );

This line of code must be inside of a for-loop to have an effect on every pixel in the image. Try it out to make sure it works as expected.

Step 2: Restoring the Image

Once the pixels have been modified/filtered, we'd like to restore them when a new key is pressed. To do this, place calls to image() and loadPixels() at the top of keyPressed(). Note: you will want these calls in both setup() and keyPressed().

Step 3: Add Additional Filters

Make additions to keyPressed() to respond to the following additional key presses:

Notice that when you press any other key, it returns to the original image. Make sure to explain why this is the case in the comments of your program.


Submission