1

I am using Imagemagick to create an automatic chroma key removal program. I have been successful in creating a mask for the image using the following commands:

magick convert woman.original1.jpg  -colorspace HSL -channel Hue,Saturation -separate +channel ( -clone 0 -background none -fuzz 7% -transparent #575757 )  ( -clone 1 -background none -fuzz 0% -transparent #4a4a4a ) -delete 0,1  -alpha extract  -compose multiply -composite  mask.png

Using this code, I have been able to create the following result:

Original:

enter image description here

Mask:

enter image description here

However, as you can possibly notice, the mask misses out part of the hair, which as can be observed in the original image, is slightly tinted green. When I extract the hue channel, the following image is generated:

enter image description here

As you can see, the hue channel also shows that the hair takes on a green hue.

How do I preserve the hair while removing the green chroma key?

1 Answer 1

1

Looking closer your image, which is unfortunately quite low res, reveals that your background has plenty of noise or real detail which has green hue and the same contrast as the lost hair => no treshold is ok. The background detail also has the same size variety than the lost hair => no treshold nor spatial frequency separation will work.

Assuming that the hi-res version doesn't reveal more difference, your options are:

  1. For future shots improve the light, it must knock out the green from the background everywhere on the target without killing the greenness of the background (bring the background further, increase the white light on the target, be sure that the background has uniform light, the distance helps to keep it blurry and suppress background details, its good light prevents noise), take very rapidly (=automatically) another shot with possibly artistically impossible lights which gives good mask and use it with the acceptable lighted photo. Use the lowest possible JPG compression, preferably none because JPG artefacts are as bad as noise. Shooting as RAW is the best.

  2. A theoretical approach, needs some advanced math software: Pattern matching software can calculate which hair is the most probable reason for the existing image . No idea, if that software is available for something else than forensic investigations, high level security systems and military intelligence.

What to do now: Your hi-res image CAN reveal more. Insert a link to one. Then some of us with some real knowledge beyond my guesses can find something useful.

You can turn the leaked green on the hair to any color if you have otherwise acceptable mask, possibly manually tuned one.

I have done numerous lost hair redrawings when I have got photos with order "remove the background and be sure that the hair also looks good!" That is not at all fun, but it has been the way out. Note: good looks is not the same as exact replicate.

1
  • Thank you! I will try to modify this and keep you updated. Commented Feb 23, 2018 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.