#title: greenScreen.py
#author: Ariel (arielb@bu.edu)
#Description: A program to create a green screen effect by transposing one picture over another.
def greenscreen():
message1= "Pick a foreground picture..."
showInformation(message1)
#pick a foreground (fg) picture file (with green background)
fg=pickAFile()
message2= "Now pick a background picture..."
showInformation(message2)
#pick a background (bg) picture file
bg=pickAFile()
#make a picture out of the fg
makePicture(fg)
picfg=makePicture(fg)
#make a picture out of the bg
makePicture(bg)
picbg=makePicture(bg)
#show the before pictures
show(picfg)
show(picbg)
#for each pixel in the fg image:
for pixel in getPixels(picfg):
# get the red value
valueR= getRed(pixel)
# get the green value
valueG= getGreen(pixel)
# get the blue value
valueB= getBlue(pixel)
# if the red plus blue is less than green
if valueR + valueB < valueG:
# get the pixel color from the bg image at the same location
Xfg= getX(pixel)
Yfg= getY(pixel)
pixelfg= getPixel(picfg, Xfg, Yfg)
pixelbg= getPixel(picbg, Xfg, Yfg)
newPixel= getColor(pixelbg)
# set the fg pixel color to be the color obtained from the bg image
setColor(pixelfg, newPixel)
#show the resulting picture (repaint)
repaint(picfg)