Page 1 of 1

chroma key from two pictures: help needed

Posted: 2011-02-13T07:58:14-07:00
by nitrofurano
Do someone know how can we do chroma key on imagemagick?
This would be like generate a third picture, from two source pictures (one as background, and another for the above 'layer' using blue or green as transparent colour )
http://en.wikipedia.org/wiki/Chroma_key explains a bit better what it is, for people don't know what is it about
My idea were using this with a picture sequence generated from ffmpeg, from a script
Any feedback of a command-line for this is very welcome, or developers please consider adding this feature if missing
Thanks!

Re: chroma key from two pictures: help needed

Posted: 2011-02-13T13:15:00-07:00
by fmw42
If you can provide two simple images that you want to merge, we can likely help.

Assuming one image has a lot of blue in it, then something like

convert backgroundimage \( foregroundblueimage -fuzz XX% -transparent blue \) -compose over -composite resultimage

where XX is some number between 0 and 100 that controls how close any color is to blue that will be made transparent (0 means exactly the color blue).

See
http://www.imagemagick.org/Usage/color_basics/#replace
http://www.imagemagick.org/Usage/compose/#compose

Re: chroma key from two pictures: help needed

Posted: 2011-02-13T16:36:28-07:00
by anthony
Hmmm idea. As the color trying to be turned into a mask is a specific color, rather than a dedicated channel, perhaps we can use a Hue color space to generate the mask needed.

That is convert both the reference color and actual image to HSL color space and then convert the reference color to transparency. The Hue channel image can then be used to generate the mask.

That should allow us to 'notch' that specific color a little more definitely, rather than trying to do so in RGB space as we have attempted to do in the past.