Here we'll look at more advanced Bluescreen techniques.
All About The Color
Color - our if-logic to replace or blend pixels only uses color.
Bluescreen Multi-Pass - You Try It
Make multiple changes: change red and change blue
Provided code: detects red, copies in leaves.jpg ("back" image)
You Try It:
-Add a second if-statement after the first (copy/paste 1st if)
-Change to detect blue pixels, copy in yosemite.jpg pixels ("back2" image)
-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 pairs {..}: 1x for-loop, 2x if-statements
image-bluescreen2-1
Solution code:
// Your code here
if (pixel.getBlue() > avg * 1.2) { // if-blue
pixel2 = back2.getPixel(pixel.getX(), pixel.getY());
pixel.setRed(pixel2.getRed());
pixel.setGreen(pixel2.getGreen());
pixel.setBlue(pixel2.getBlue());
}
Experiments With The Two Ifs
Use cut/paste to run with one or the other or both ifs
Then change leaves.jpg, to stanford.jpg
Run without and then with the if-blue code
Why does it look like that?
Swap the order, so if-blue is first, followed by if-red
Now what does it look like?
Conclusion: if-blue will trigger on an original or new pixel
The logic just works on whatever data we feed it
Answer:
When stanford is put in by if-red, the sky result is just
as blue as the other sky.
All the blue pixels are replaced by the if-blue which follows.
This only happens if if-blue goes second.
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, too much red)
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.