User Tools

Site Tools


For Feb. 23rd:

1. Write setup code to load three different images (not too large). At least one of these should be reasonably colorful, but don't go overboard. The size of the drawing window should be large enough to display all three side by side.

Copy the functions for effects Charcoal, Posterize, and Sepia from the wiki. Copy each function into a new tab in Processing. Make any adjustments necessary to get these functions to work together.

In draw, apply one effect to each image and display the results side-by-side (or vertically if that makes more sense).

After you can display each image with its effect applied in one drawing window, see if you can make Posterize noticeably faster by changing the way it accesses the pixels array, like we did with greyscale.

2. Write a new sketch called Thresholding.

The sketch should be structured in the same general way as 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. The easiest way to do this is to take the y-coordinate of the mouse (mouseY) and map it from the height of the window to the possible range of threshold values (0..255).

3. Try this lab. The idea here is to make a big window and display an image in just the upper left quarter (quadrant) of the window, then make three changes to it and display those in the other 3 quadrants. So you'll have 4 images in one window. It may be necessary to shrink each image down so they all fit.

cs276/thresholding.txt · Last modified: 2016/02/16 11:35 by scarl