15.1. Using Decisions with Images¶
Learning Objectives:
Show examples of using conditionals to modify images.
Use conditionals to combine two pictures.
Use
if
andelse
with images.Use multiple
if
statements with images.

We can create image effects by conditionally executing code. In the code below we will try to change the color of the women’s shirt. We will clear the red value (set it to 0) for any pixel that has a red value greater than 200 and a green value of less than 100 and a blue value of less than 100.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
What happens if we only test if red is greater than 200? Change the code above to try it.
Can you find values that work well to only change the shirt color and not anything else?
Remember that white light is a combination of red, green, and blue light with each value at 255 for totally white light. Try to change just the white background to green.