User Tools

Site Tools


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.


  1. Grab the code Convert Image to Grayscale from the class wiki and test it out as in #1 using the exact same image.

  2. 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.

  3. 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 assignment).

  4. 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
    if the grayscale value > the threshold value t
    change the current pixel to white
    change the current pixel to black
    Test the new sketch by running it with threshold values of 128, 50, and 212.

    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.

  5. 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 later.

cs276/spc.lab2.txt · Last modified: 2019/09/10 21:36 by scarl