CS 276 Lab #1
purpose of this lab is to measure the performance of the image
code run in
the Processing development environment (and review programming
I would like you to work in groups of two for this assignment.
- Grab the code for Invert
Image and Convert Image to
Grayscale from the class wiki.
Add calls to System.currentTimeMillis
around the function that
processes the pixel array in each sketch (negative
and use these to measure the time it takes to run the function.
Comment out the println calls from inside
the functions, which just slow things down. Output and record
the time each function takes.
- Both sketches process the array as if it were
2-dimensional, using nested loops and get/set
methods. Make a
copy of each sketch (change the names!) and modify them to access the
array directly, instead of using get/set.
Time these and compare to the original
versions. Is this version appreciably faster?
- Make yet another
copy of each sketch and modify them to process the
array using just a single loop (in Negativize, an example that needs
improvement is provided
in comments). Time these and compare to the previous
versions. Is any version appreciably faster than the
others? Demonstrate the code and results to the instructor.
- Switch driver/observer for the rest of the lab. Create a
new sketch called "Lab1". Write code to load three different
images (go find new ones) and apply one of the effects Charcoal,
Posterize,and Sepia to each image. Grab the code for each effect
from the wiki and copy each into a
Make any adjustments necessary to get these functions to work together
(though note that if the functions were written properly, this should
not be a problem). 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.