Close Show/hide page

Webcam Green Screen Effect w/ Pixel Bender

Thumbnail - Click me

A green-screen/chroma key effect utilizing Pixel Bender. With this version, the live video is compared against a reference image rather than a static color. Additionally, the alpha of the output is graduated based on the color difference between the base image and the incoming video (rather than just being either ‘on’ or ‘off’). Both of these differences may or may not be good for practical use, but can create interesting imagery.

Use the sliders to adjust the cutoff/falloff curve for the alpha. Click “Reset base image” to set the base image with which to compare any further changes in the video against. You can also choose your own background image (click “Browse…” at the bottom). Works best against a plain background and presumably best of all with proper lighting against a green background…

When I wrote the image processing routine in pure Actionscript, it ran like a slideshow. The Pixel Bender version on a multi-core system runs about 30x faster.

Pixel Bender kernel: GreenScreenEffect.pbk

Licensed under a Creative Commons Attribution 3.0 License.

46 Responses to “Webcam Green Screen Effect w/ Pixel Bender”

  1. Patrick says:

    Oh, no there’s an alien in Manhattan!

  2. Luke says:

    Hey could this be adapted for clear cutting of images? I’ve been on the look out for a while for a flash or PHP module that clients could use to cut out the white around product images and save them as PNGs. Unfortunately all the scripts I’ve seen leave nasty jagged marks around images, or are just too crude (all FFFFF pixels only, etc). Pixel Bender generated .swfs still only require Flash 10 right? I haven’t actually seen much on PB since Adobe made a big deal of it when launching the last Flash version…..

  3. Lee says:

    Luke, sorry for the late reply, but the answer is, I believe, yes. The user would need to play around with lighting conditions and the background for optimal results, but the edges can look quite nice, and un-jaggy.

  4. George Profenza says:


    I cannot click the accept button. I click and nothing happens, as if the swf doesn’t have focus and there is something blocking it.

    I’m using Firefox 3.0.8 on Mac OSX 10.4.11. Same thing happens in Safari 3.1.

    The post looks interesting, shame about the example swf.

  5. z23 says:

    Hi Lee. Nice!
    Played around with it and wanted to invert the alpha, so I changed line 73 to dst.a = 1.0 – val; but in return i got a second video on the stage, just black (assuming this is the alpha then there must besomething wrong with it in general) and the position is exact the opposite. The rgb video is placed in the upper left corner where it belongs but the black box is in the lower right. I just wonder how this substraction can cause such weird stuff.

  6. Marcus says:

    Hi Lee,

    Nice demo!
    It looks like the link is broken, have you taken the code down for some reason?

  7. Marcus says:

    Ok I was playing around with the URL and I found the file at this link :

    Thanks a lot for sharing this!


  8. admin says:

    Thanks for pointing that out Marcus. I’ve fixed the broken link.

  9. Jack says:

    Thanks for sharing this kernel, but could you please also post the source of the flash, or at least some description of how to use the kernel in a flash file? I find it rather confusing to implement as all the info I can find online talks about using blenders and shaders, etc that have only one input, whereas this kernel uses two inputs… I’m a bit lost/confused :(

  10. Like Luke was asking, this still can be used as a quick-n-dirty way to extract the background on images like product photos. I’ve used it many times in before. Except the new PS CS4/CS5′s tools are so much better and faster once you get the hang of them.

    Too bad there is still no good server based solution with GD or Imagemagick.

  11. I simply want to say I am new to blogs and really loved you’re blog site. More than likely I’m planning to bookmark your site . You definitely come with perfect posts. Appreciate it for sharing your webpage.

  12. full article says:

    I just couldn’t depart your site prior to suggesting that I extremely enjoyed the usual information a person provide in your visitors? Is gonna be back continuously to inspect new posts

  13. Hi there, I found your web site via Google while searching for a related topic, your web site came up, it looks great. I have bookmarked it in my google bookmarks.

  14. Hi, Neat post. There’s a problem with your website in internet explorer, would test this… IE still is the market leader and a large portion of people will miss your magnificent writing due to this problem.

  15. check post says:

    I just want to mention I am just newbie to blogging and site-building and really savored you’re web site. Very likely I’m want to bookmark your website . You certainly have great well written articles. Regards for revealing your web page.

  16. I just want to mention I’m new to blogs and honestly loved you’re blog site. More than likely I’m want to bookmark your site . You certainly come with awesome article content. Thanks a bunch for revealing your blog.

  17. This is one awesome blog article.Really thank you! Keep writing.

  18. Thanks so much for the blog article.Really thank you!

  19. good info says:

    I simply want to tell you that I’m new to blogs and truly savored you’re website. Most likely I’m going to bookmark your blog post . You amazingly come with fantastic stories. Cheers for sharing your website.

  20. I simply want to mention I am new to blogs and certainly liked this blog site. Likely I’m want to bookmark your blog . You absolutely come with perfect well written articles. Thanks a bunch for sharing your web page.

  21. I simply want to tell you that I am all new to blogs and truly loved you’re web-site. Almost certainly I’m going to bookmark your website . You amazingly come with tremendous well written articles. Kudos for revealing your website.

  22. A big thank you for your post. Want more.

  23. Thanks again for the post.Much thanks again. Really Cool.

  24. Hey there! I’m at work surfing around your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the fantastic work!

  25. Depuis sa création en 2004, Permisecole a formé plus de 350 000 candidats, avec ses tests et ses cours utilisés en auto-école. Nos moniteurs sont titulaires du BAFM (Brevet d’Aptitude à la Formation de Moniteurs) afin de garantir la conformité de nos programmes d’apprentissage aux épreuves officielles du permis de conduire.

  26. says:

    Thanks for the post.Really thank you! Much obliged.

  27. Your blog is fascinating. I’ve one questions: can I take rss from Your site BLOGTITLE

  28. sukienki says:

    Hello! Someone in my Facebook group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers! Excellent blog and outstanding style and design.|

  29. Superb blog! Do you have any suggestions for aspiring writers? I’m hoping to start my own website soon but I’m a little lost on everything. Would you recommend starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m totally overwhelmed .. Any suggestions? Thanks!

  30. Regards for helping out, great info. “Those who restrain desire, do so because theirs is weak enough to be restrained.” by William Blake.

  31. says:

    “Wow, great article.Much thanks again. Want more.”

  32. Hola! I’ve been following your site for a while now and finally got the courage to go ahead and give you a shout out from Humble Texas! Just wanted to tell you keep up the excellent work!

  33. houseforsale says:

    Hey there! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no data backup. Do you have any methods to prevent hackers?

  34. Howdy! I understand this is somewhat off-topic however I needed to ask. Does managing a well-established website like yours require a large amount of work? I am completely new to writing a blog but I do write in my journal everyday. I’d like to start a blog so I can easily share my experience and feelings online. Please let me know if you have any kind of recommendations or tips for brand new aspiring blog owners. Thankyou!

  35. copify says:

    These days I don’t have the time to compile and categorize and consider as much as I’d like to. But I still get to hear a lot of good music, even if I have less time to seek it out.

  36. Right now it appears like Drupal is the top blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog?

  37. This is the brainchild of some of the brightest minds in the economics, media and business sector whose sole purpose is to keep you abreast with the latest trends that affect the monetary market in cyberspace as well as in all corners of the globe. Through this website, you will gain valuable insight into why the financial market fluctuates and how you can prepare for ways to meet your desired goals in going about the complex ways of making your money grow

  38. Hey outstanding website! Does running a blog like this take a large amount of work? I have no understanding of programming however I had been hoping to start my own blog in the near future. Anyway, if you have any suggestions or tips for new blog owners please share. I understand this is off topic however I simply had to ask. Thank you!

  39. I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet savvy so I’m not 100% positive. Any recommendations or advice would be greatly appreciated. Appreciate it

  40. Hung Maruffo says:

    I’ m amazed at how profuse the sea life looked in this clip, living being the Japanese hammer and execute in danger of extinction species comparable fin and dejected whales, blue? fin tuna, sharks, whales, dolphins, Dall’s Porpoises, (which Japanese overtake as whale meat), rare sea horses, not to mention Bengal tigers, giant salamanders, ect. Condition they’re not viciously slaughtering these powerless animals, they’re selling them by the black sell used for zoos and such…

  41. Wow! After all I got a web site from where I know how to in fact obtain valuable information regarding my study and knowledge.|

  42. boxing gyms says:

    Hey! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My site looks weird when viewing from my apple iphone. I’m trying to find a template or plugin that might be able to correct this issue. If you have any suggestions, please share. Appreciate it!

  43. Someone essentially help to make critically posts I would state. That is the first time I frequented your website page and so far? I surprised with the research you made to create this actual submit amazing. Wonderful task!

  44. Hey would you mind letting me know which web host you’re working with? I’ve loaded your blog in 3 completely different web browsers and I must say this blog loads a lot faster then most. Can you suggest a good web hosting provider at a honest price? Thank you, I appreciate it!

  45. marine hotel says:

    Hi there, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam comments? If so how do you prevent it, any plugin or anything you can recommend? I get so much lately it’s driving me crazy so any support is very much appreciated.

Leave a Reply