Make multiple changes to the image: change red and change blue
Provided code detects red, put in leaves.jpg (back)
Challenge
Add a second if-statement after the first (copy/paste)
Detect blue pixels, put in yosemite.jpg (back2)
The second if follows the first inside the loop
They are not inside one another, they are siblings
They are at the same indent level
Three {..}: 1x for-loop, 2x if-statements
image-bluescreen2-2
Solution code:
// Your code here
if (pixel.getBlue() > avg * 1.2) { // select blue (back2)
pixel2 = back2.getPixel(pixel.getX(), pixel.getY());
pixel.setRed(pixel2.getRed());
pixel.setGreen(pixel2.getGreen());
pixel.setBlue(pixel2.getBlue());
}
Post-Processing Paint
Here we have banana.jpg
Suppose we want to show the banana having a dream about paris
But we don't want to replace all the red brick
This image is not well suited to bluescreen (banana vs. brick)
We can "fix it in post" (Hollywood expression)
Meaning manipulate the image in a paint program
I created banana2.jpg as a copy to edit
Crop the image to position the banana and the eiffel tower
Put in blue circles artistically (demo)
Now the code can just look for blue
Can also use this to "fix" little areas discretely in the original image that are giving your bluescreen selection logic problems (like when you have little speckles you can't get rid of)
On the Mac, Preview has a primitive edit mode. 1. make a copy of your original file first, so you don't mess up the original. Open the copy in Preview. 2 Click the pencil to enter edit mode. 3 Click the circle to draw circles. 4 Click the colors, selecting blue and also a fill-color of blue. Draw/arrange blue circles or whatever. Windows has a similar simple paint program.