I had been searching for good algorithm for green screen chroma key using ImageMagick, but no satisfactory answer so far.
I would like to explore a simple method of using range selection along the HSV/HSB color space (similar to -fuzz) to select the green color I want and make them transparent. The -fuzz seems to apply only in RGB space, which is not desired.
Can anyone teach me how to select color with seperate range for H, S, V component, for example, 115-125 degree Hue, 40%-60% Saturation and 30-80% Value.
If there is other better chroma-key algorithm, your advice is highly appreciated too.
Thanks in advance.
Imagemagick's FX can be used to generate a alpha channel. The
hue
,saturation
,lightness
, &luma
keywords exists, but you'll need to calculate the colorvalue
by max(r, g, b).Saving the above into a file named
hsl-greenscreen.fx
and execute it against an image with:The FX script will probably need additional tweaking to match expected results. You'll also notice this will take a bit of CPU to complete, but that can be improved on.
Another option would be to apply the same
-fuzz
options, but on each HSV channel. Simply split & clone each channel, apply-fuzz
against a target grey, and compose an image mask.Then assign the mask as the images alpha channel