I'm building an app that allows people to upload an image of themselves against a white background and the app will create a silhouette of the person.
I'm having a hard time keying out the background. I am using the GPUImage
framework and the GPUImageChromaKeyBlendFilter
works great for colors, but if you get to white/black it is really hard to key out one of those colors. If I set the key to white or black it keys both the same.
Any advice?
In the Final Cut Pro timeline, select the clip with the Luma Keyer effect. Open the Video inspector. The Effects section of the Video inspector shows the parameters available for adjusting the Luma Keyer effect. To reverse the key and remove white instead of black areas of the foreground clip, select Invert.
Apply the luma key effect Select the foreground clip in the timeline, then click the Effects button in the top-right corner of the timeline (or press Command-5). In the Effects browser, select the Luma Keyer effect. Tip: Type “keyer” in the Effects browser search field to quickly find the Luma Keyer effect.
You can generate a matte by applying a luma key to your shot, then designating which brightness level is transparent and which is opaque. Chroma keys let you select a specific color in an image (i.e. the chrominance value), designating anything with that color transparent.
There is a reason why typically blue or green screens are used in movie production for chroma keying, instead of white. Anything can be white or sufficiently close to white in a photo, especially eyes or highlights or just parts of the skin. Also, it is quite hard to find an uniform white wall without shadows, cast by your subject at least. I would recommend building a histogram, finding the most frequently used color among the brightest ones, then search for the biggest area of that color using some threshold. Then do a flood fill from that area until sufficiently different colors are encountered. All of that can be quite easily done in software, unless you want a realtime video stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With