function:RenderSidePart pageleftbodycaption pageleftbody sidenote Main.PictureLabBonus-SideNote Main.SideNote Site.SideNote

# Chromakey

Write a chromakey method that replaces the current pixel color with the color from another picture at the same row and column when the current pixel color is close to a specified color. In many movies, the actors are filmed in front of a green screen and then the green is replaced with a different background using a similar technique.

The picture is of Dr. Mark Guzdial of Georgia Tech. Dr. Guzdial is the creator of the Media Computation approach to teaching computing concepts, which has students write programs that manipulate media: pictures, sounds, text, and movies. These labs are based on his work.

# Method to add to your PictureTester class

/** Method to test chromakey */
public static void testChromakey()
{
Picture mark = new Picture("blue-mark.jpg");
Picture moon = new Picture("moon-surface.jpg");
mark.chromakey(moon);
mark.explore();
}


# Method to complete in the Picture class

Use the getColor() and setColor() methods to examine and replace the red, green, and blue values all at once. If the toPixel pixel is more blue then red, it should be replaced with the fromPixel value.

/** Method to replace the blue background with
* the pixels in the newBack picture
* @param newBack the picture to copy from
*/
public void chromakey(Picture newBack)
{
Pixel fromPixel = null;
Pixel toPixel = null;
Pixel[][] toPixels = this.getPixels2D();
Pixel[][] fromPixels = newBack.getPixels2D();

}