CS 276 Lab Assignment
CS 276 Lab #2
The purpose of this lab is to get used to working with the basic
machinery of image processing algorithms.
- Grab the code Convert Image to
Grayscale from the class
wiki and test it out as in #1 using the same image as in Lab 1.
- Wrap the function call to grayscale
with timing calls as in #2 and output
the time it takes for this function to process the array, as well as the
average processing time per pixel.
- Demonstrate your sketches and the timings to the instructor.
You'll want to save these in your sketchbook folder or post to your
wiki page to refer to later (you'll use the same technique in a homework
- Write a new sketch called Thresholding.
The sketch should be structured like the previous two, but its core
functionality is to modify the image using the thresholding
algorithm. Write a function threshold
which takes two parameters: a PImage
and an integer (which should be between 0 and 255). The function
implements the following algorithm for every pixel in the array:
compute the current pixel's grayscale value
Test the new sketch by running it with threshold values of 128, 50, and
if the grayscale value > the threshold value t
change the current pixel to white
change the current pixel to black
This sketch would be even cooler if we could modify the threshold
values in real-time, say by using the mouse. Again,
something to think
about for later.
- Demonstrate your Thresholding sketch to the instructor. Also,
save this sketch to your Linux account (or wiki) as before because you'll be modifying it