Help with Green Screen Program

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

Help with Green Screen Program

Post by Tugnus on Tue Jun 28, 2011 6:31 pm
([msg=59144]see Help with Green Screen Program[/msg])

So I'm pretty lost in Python. My teacher doesn't explain the commands for Python so I'm really confused on how to write this. I have to write a green screen type program that takes a picture with a green background and replaces it with another picture by looking at the color levels of each pixel and if the green color is a certain amount larger than blue/red then it will replace it with the other pictures pixel.

The pseudo code I have is:

#show the before pictures
#for each pixel in the foreground image:
# we first get the red, green and blue of this pixel
# if the red plus blue is greater than green (*)
# get the pixel from the background image at foreground pixel's location (**)
# set the background pixel's color to be the color obtained from the fg
#show the resulting picture (repaint)
#write the new picture to a file

You can use the writePictureTo(picture, path) function to save the image.

I know the basics to the program with the getRed()/blue/green and setRed(), but I don't know what to do about finding certain pixels in the foreground.

We are using JES version of python in class as well.

Any help would be greatly appreciated.
Tugnus
New User
New User
 
Posts: 1
Joined: Tue Jun 28, 2011 6:28 pm
Blog: View Blog (0)


Re: Help with Green Screen Program

Post by cen on Sat Jul 02, 2011 7:48 am
([msg=59311]see Re: Help with Green Screen Program[/msg])

User avatar
cen
Experienced User
Experienced User
 
Posts: 77
Joined: Mon Jun 30, 2008 1:06 pm
Blog: View Blog (0)


Re: Help with Green Screen Program

Post by tgoe on Mon Jul 04, 2011 10:54 am
([msg=59406]see Re: Help with Green Screen Program[/msg])

Never heard of JES Python so I looked it up. The answer to your question is right in the introduction manual :)
User avatar
tgoe
Contributor
Contributor
 
Posts: 658
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)



Return to Interpreted Languages

Who is online

Users browsing this forum: No registered users and 0 guests