Coding Green Screen Process

How can i code the Entire Concept of Green Screen Process using python?

Why would you want to do this with python. Compositing Nodes are a much easier way to go about it. http://www.blendedplanet.com/?Freebie_Tutorials:The_Ultimate_Keyer

Hi dude,
We want to make it an automate process. Instead of doing it manually for each and every
samples.
Our senario,
User will upload an avi file (with green screen background) and background image. we want to merge the avi and background image as a background process and convert it into wmv. It will be published in website later on.
similarly Green Screen Wizard…

Hi There!

What you want to do is to threshold the image. Thresholding allows you to select certain regions in a picture and remove others like the background.

First, in the algorithm you need to loop through each frame, and for each frame produce an intensity histogram for each RGB channel. The histogram is just a plot of intensity (0-255) against number of pixels with that intensity. from that you can identify the regions of background and foreground image that have peaks in the histogram. You’d expect a peak at the high value range for the Green channel, but low value range peaks for Red and blue (seen as the background is a green screen).

for anything thats background you want to make that region have an alpha value, such that when you draw it (the frame) over the user submitted background, the orignal green background from the frame is see through.

All that said, it’s a fairly simple algorithm, but remember that your going to have to loop every pixel in every frame (for the threshold values to be discovered from the histogram) to do this really well… which is time consuming. You could skip the histogram stage and use guessed values for the threshold (R: 200-255, G:0-15, B:0-15) but thats going to give you a little bit of remaining green on some frames.

I’m guessing here that you’re thinking of doing this in python because you think it’s easy and you’re not that well aquainted with coding. Well it is easy, but I wouldn’t code it in Python in Blender… It’ll be way too slow for what you need it for. Maybe try Realbasic or something like that (not exactly fast either, but you’ll learn a lot from it) - I know i could code something like this in about 10 minutes (literally - I’ve done this before)

If you want help, PM me… I’m more than happy to provide you the outline of the code…

Whipster

1 Like

You are forgetting about user input. The uploaded file is user input. Where there is user input, there is a greater chance of error.

Why not use image magik? I think it can do that kind of stuff already. It runs at the PHP level.

Hi Atom,
Proper input will be given by the user, In that case
Is it really possible to code it?

Image Magik does have a PHP interface, so that could be an option (I don’t know if it supports chroma keying though).

If you really wanted to do it in python, I’d avoid using Blender as Atom said. You could, but there’s probably easier ways to do what you’re thinking. You should get something like the Python Image Library (PIL) or there is an Image Magik extension for python if you find you like it.

http://www.imagemagick.org/Usage/draw/#matte

Why is it that I’m being ignored?? I just told you that it’s a piece of piss…and outlined all the bits of the algorithm - I even said I’d be prepared to write most of it for you…

ah well no skin off my nose… do it yourself.

Hello All,
Thanx for your suggestions.
Hi Whipster,
If you have the outline, Pls provide it to me.
Also I would i like to look into perl,image magick,gimp and gd.


Just go through the above link.

Hey Whipster can you help me with coding something. Im a student in the Stanford CS106 online course. Our class is up to manipulating images. Just got there, we use PYCHARM. I want to code: i have a pic of two children, one of which is wearing a white shirt. i have a second photo slightly similar of the 2 children. i want to insert the 2nd photo on to the childs white shirt from the first photo. i have been minipulating a stop sign from class using INTENSITY_THRESHOLD 1.6, for each loop with an average variable (pixel.red+pixel.green+pixel.blue// 3 etc… so i kinda know the beginner image manipulation. can you help?