Changing Step 5: Increasing and decreasing color values¶
Below is a selection of images that you can use in the programs in this section.
First example: Let’s change STEP 5, so that we decrease the red by 50%.
Try the program above on some of the other images by changing the name of the image file on line 5. What effect does it always have? Is this what you expected when we decrease the red?
We can increase the red in a similar way. Let’s change STEP 5, so that we increase the red by 150%.
Try the program above on some of the other images by changing the name of the image file on line 5. What effect does it always have? Is this what you expected when you increase the red? What happens if you increase two colors at the same time?
csp-11-4-1: Another way to get a similar effect to increasing the red, is to decrease the green and blue. Figure out how to do that in the program above and then use that information to drag the code blocks below from the left to the right in the correct order with the correct indention.from image import * --- img = Image("beach.jpg") --- pixels = img.getPixels() for p in pixels: --- g = p.getGreen() b = p.getBlue() --- p.setGreen(g * 0.75) p.setBlue(b * 0.75) --- img.updatePixel(p) --- win = ImageWin(img.getWidth(),img.getHeight()) img.draw(win)
Decrease the red by .5 and increase the blue and green by .5 in puppy.jpg.
Discuss topics in this section with classmates.