Mobile app version of vmapp.org
Login or Join
Nimeshi706

: Imagemagick Chroma Key removal 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:

@Nimeshi706

Posted in: #Imagemagick

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:



Mask:



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:



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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi706

1 Comments

Sorted by latest first Latest Oldest Best

 

@Holmes874

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:


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.
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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme