Homework 2c - Bluescreen

For this last bit of HW2, you will use code and your creativity to create a bluescreen image. We will have a class art-show and some small prizes for all this artistic output.

Bluescreen Contest Categories

We will have an in class art-show and contest using these images.

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 please keep in mind that a selection of the entries will be shown to the whole class.

Bluescreen Code

See file bluescreen.py (in the image-grid folder) which has code set up like the lecture monkey example. The crucial if-test is missing, replaced by a False, so you need to put that line in and adjust it for your data. You can adjust this code in any way to get the effect you want. Run the front strategy with this command line with the front and back images:

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

(The front-strategy and back-strategy are described below.)

The code also includes a function for the "back" strategy with with the following command line which you can try if you like. In the command line below, the "200" is a shift_x and "50" is a shift_y - these move the monkey over 200 and down 50 on the back image, so this is handy to position things on the background carefully.

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

Art Show

For the grading of this project, you can get full marks from an image that demonstrates creating a real image and processing it with the bluescreen algorithm, and we will not be picky about the level of artistry or creativity. However, if you want to go for the gold on the art show, let your creativity fly!

How to create your own bluescreen:

1. Take Several Foreground Images

First create several "foreground" pictures with people or whatever in front of a blue or green colored background, and save those images on your computer. You can use, say, a blue towel as background. We are not grading on the artistic details of your photography here; we just want an image and some code that work together. For the contest however, the sky is the limit.

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, and in any case, you will need to adjust the code to work with your background color.

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.

You can fix up your image this way, but we want the actual bluescreen composition to be done by your code in bluescreen.py.

There are two strategies shown in the bluescreen.py file; either of these is fine for your output.

3. Bluescreen "front" Algorithm

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

Front 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 accessing non-existent pixels on the background. If you get that error, resize the back to be bigger in an image editor and try again. 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/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

The bluescreen output image files should be the product of your input files and your edits to the bluescreen.py code. You will submit your output image files and your bluescreen.py code. 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 must submit 1 bluescreen image, and you can submit a second if you like.

Ethics Exercise

See the ethics-truth.txt file in the homework folder - write your paragraph below the instructions in that file and submit it as part of HW2.3. The short ethics video is linked off the course page - it is not in the regular list of videos on Canvas.

All Done

Turn In

When you have your bluescreen output looking good and your ethics paragraph, please turn in the following on Paperless as HW2.3.