< Back

Lab 23: Images

For all of our activities, make sure your practice with the new blocks today. Some of the activities you can complete without using the new blocks. They do save some time and headaches. Open up the Practice Area, and take a crack at the following activities.


Activity 1: Posterize

Posterization is the process by which an image is converted into a set of much fewer colors. This makes the image cheaper to print, as the number if different colors necessary is significantly reduced. While you might not recognize the process by name, you have most likely seen a very popular image that has been posterized.

Create a blockly program which allows the user to load an image. Your image should then go through and decide whether a given pixel should be in black or white. To make this decision, you will average the 3 color values of a given pixel. If the value of the average value is less than some threshold (128 is what is used in the example below), the pixel should be drawn in black. Otherwise the pixel should be white.

Before

After

Bonus: Alter your program so it uses 4 different colors with 4 different thresholds.