= Assignment 6 - Image Matting and Composition = === Due Date: Thursday March 1st, 11:59PM === ~+Questions? Check out the [wiki:self:Assignment6Discussion Assignment 6 FAQ and discussion page].+~ In this assignment you will write code to separate a foreground object from a constant color background in an image and then place this foreground object in another scene of your choosing. In computer graphics terminology, you will extract (or lift) a matte from an image to isolate a foreground object, and then composite the foreground object with a new background using the matte. With such technology you can whisk your beloved TA off to far away lands and exotic beaches where he no longer has to grade homework assignments. http://graphics.stanford.edu/courses/cs148-07/assignments/assignment6/greenscreen.jpg http://graphics.stanford.edu/courses/cs148-07/assignments/assignment6/imagematte.jpg http://graphics.stanford.edu/courses/cs148-07/assignments/assignment6/newyork.jpg http://graphics.stanford.edu/courses/cs148-07/assignments/assignment6/france.jpg === Download and build the starter code === 1. Begin by downloading the Assignment 6 starter code and latest version of the libST source [http://graphics.stanford.edu/courses/cs148-07/assignments/assignment6/assignment6.zip here]. {{{Libst}}} has not changed in this assignment, but we are bundling it in with the assignment zip file just like in all the previous assignments. 2. Build the code. In this project, you will be modifying {{{assignment6/matting.cpp}}}. In the {{{assignment6/}}} subdirectory we have placed a couple of image files. The files {{{doodle.jpg}}}, {{{elephant.jpg}}}, and {{{kayvon.jpg}}} are sample images of foreground objects in front of a green screen. We have also provided a number of backgrounds to test compositing the extracted foreground objects into. In this assignment you will also be given the opportunity to take your own pictures against a green screen. === The problem === Given an image of an object in front of a green screen, you need to estimate the color and transparency of the foreground object at each pixel. As discussed in class, an image where the intensity of each pixel defined the opacity of a foreground object is called a '''matte'''. In this assignment you will extract (or lift, in film terminology) a matte from a photograph. === The technique === Unfortunately, given only a single image of the foreground object, it is impossible to analytically determine both the color and transparency of the foreground object even if the background color is known. For example, a brown pixel in the image might be the result of an opaque brown foreground surface, or it may be the result of a semi-transparent red surface in front of the green screen. The following is a summary of the mathematics of the problem. Recall that the equation for a color that is the combination of a foreground and background colors is: === Matte extraction === === Compositing ===