User Tools

Site Tools


cs276:lab1

CS 276 Lab #1


The purpose of this lab is to measure the performance of the image processing code run in the Processing development environment (and review programming concepts).

I would like you to work in groups of two for this assignment.

  1. 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 grayscale) 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.

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

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

  4. 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 new tab.  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.

cs276/lab1.txt · Last modified: 2016/08/31 20:39 by scarl