14.4. Posterizing

The process of changing an image so it only uses a small number of colors is known as posterizing (old posters had to be printed with a small number of colors - the technology didn’t let one make complex blends).

This time, we need to make a function that will force a color value between 0 and 255 to become one of a few specific options.

Write code to return 0 if colorValue is less than 50, 125 if it is 50-124, and 255 otherwise.

Now that you have that function, add it to this program to see it in action:

Rewrite the code for posterizing an image using if and else rather than multiple if’s. Test that it still works correctly.

You have attempted of activities on this page