Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Luma Key (create alpha mask from image) for iOS

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?

like image 394
Buyin Brian Avatar asked Aug 22 '12 20:08

Buyin Brian


People also ask

How to use luma Keyer Final Cut?

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.

How do you use luma Key?

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.

What is Chroma Key and luma Key?

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.


1 Answers

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.

like image 100
noop Avatar answered Sep 24 '22 16:09

noop