This project has moved and is read-only. For the latest updates, please go here.

Chroma Key (Background removal)

Oct 4, 2013 at 2:38 PM
Please can you help me with some code on how to remove green/blue screen backgrounds from an image and make them transparent so that the subject of the image can then be laid over a new background.

I have tried using the Opaque and TransparentChroma methods but without any luck - not sure I am using them correctly. I am also expecting to add a -fuzz parameter somewhere to help with the amount of smoothing/variation to apply to the replacement colour.

Any help would be appreciated.

Thanks
Matt
Oct 4, 2013 at 8:19 PM
Oct 4, 2013 at 10:10 PM
That works great if the background is a single solid colour. But for a real life green screen photo, the green is different shades of green due to natural factors like light and shadow etc. Is there a way to add a 'fuzz' factor to the color replacement so that it works like the threshold on a magic wand type tool in a paint program?
Thanks
Oct 4, 2013 at 10:18 PM
You can set the fuzz factor with the 'ColorFuzz' property.
Oct 4, 2013 at 10:22 PM
Ah - just what I was needed. Thanks!
Oct 27, 2013 at 3:16 PM
Hi Matt.
I also require the ability to remove back grounds. My challenge is to remove the background from a driver licence type photo where it's just a head and shoulders photo and the background would be fairly complex. More complex/busy than just having shades of green. Is this even possible? Did you get a working solution?

Mark
Oct 27, 2013 at 4:33 PM
Maybe you could ask your question here first: http://www.imagemagick.org/discourse-server/. There are a lot of experts on that message board. When you know how it is done on the command line you can come back here if you need help to get it convert it to code.