As one last example of selectively modifying the colors in an image, we are going to
posterize an image.
Posterizing is the process of changing an image so it only uses a small number of colors. (Old posters had to be printed with a small number of colors - the technology didn’t allow for complex blending of colors).
This time, instead of making a function to answer a question like “Is this green?”, we need to make a function that will force a color value to become one of a few specific options.
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 ifs. Test that it still works correctly.