Optional Project - Bluescreen

This is an optional, for-fun project once you are done with HW7, and we will have a class art-show and contest with some small prizes. Following the CS106A tradition, we will give a small extra credit for people who make a bluescreen, however this will be done after the curve computation, so will not change anybody else's grade. You can turn in 1 or 2 bluescreen images. Bluescreens should be turned in by the end of the day before Thanksgiving, Wed Nov 27.

Bluescreen Contest Categories

We will have an in class art-show and contest using these images. Naturally there will be prizes of some sort.

The contest categories for the images are:

The foreground image for the bluescreen must be one that you yourself take; not something you grabbed off the internet. Often you yourself will appear in your foreground image. The Background image can be from anywhere, and keep in mind that the entries will be shown to the whole class.

Bluescreen Code

See the bluescreen.zip project which has a runnable version of the monkey example. You can use this code as a starting point. Run the front strategy with

$ python3 bluescreen.py monkey-500.jpg moon-600.jpg 

See the back strategy with

$ python3 bluescreen.py monkey-500.jpg 200 stanford-600.jpg 

How to create your own bluescreen:

1. Take Several Foreground Images

First create several "foreground" pictures with people or whatever in front of a colored background, and save those images on your computer. We will have a literal blue-screens in class for a few days. You can make your own pictures with, say, a blue towel as background. Take a few different foreground images so you can experiment. For example, take one image with people in the center and another with them off to the side to fit in with interesting parts of the background. You can also try dressing the people in the foreground with blue clothes, so the background will show through those areas. You don't have to use blue, green is also popular. Note that the common cheap blue tarps don't work very well as a background, because they tend to have shiny white areas which lack hue.

Image Size

Digital cameras create very large images like 4000 by 3000 pixels, 12 megapixels, and such large images will take too long to process and have far more pixels than the displays we have. Keep your original images, and create smaller versions for processing, say reduced to a width of 600 or 800 pixels with a filename like "myimage-600.jpg".

On the Mac, the built-in Preview application can crop and resize and export images, and on Windows I assume there's something similar. In Preview: open your original, use the Duplicate menu command first to save your original, then crop and resize and save.

2. Fix It In Post (optional)

"Fix It In Post" is a sort of Hollywood joke, referring to fixing some on-camera mistake later on in the computer post-production phase. This is totally optional, but you can do the same sort thing with your bluescreen image. For example, if part of the blue background is not quite big enough, you can edit the image in a paint program, and draw a blue rectangle over the area to just make it be blue the way you want. Since the blue gets removed by the bluescreen algorithm, it never appears in the final image. You are just creating a sort of hole for the background image to show through. On the Mac, the built-in Preview image app has a very limited ability to put colored rectangles and ovals on things, and on Windows the Paint program is similar.

3. Monkey Bluescreen "front" Algorithm

The simplest bluescreen form is the one shown with the monkey/moon example.

Algorithm: Loop over the main front image (e.g. monkey in front of blue). Detect blue pixels, copy over pixels from the background on top of the blue pixels. The background needs to be as big as the front image, so we do not get out-of-bounds errors on the background. The changed front image is the final output

4. Alternate: Bluescreen "back" Algorithm

Loop over the front image. Detect non-blue (i.e. monkey) pixels. Copy these monkey pixels over to the back image, possibly shifted by some shift_x (and/or shift_y) amount to move the monkey to a specific spot on the background. When done, the changed background image is the final output.

5. Saving Your Output

Save your favorite bluescreen output as a .png or .jpg file for upload. Please use your name in the file name, like "jane-smith1.png" to help use keep the entries organized. You can submit in 1 or 2 bluescreen images.