-
Notifications
You must be signed in to change notification settings - Fork 15
Home
Bayesian matting is a matting technique that uses an iterative Bayesian probability approach to approximate the background/foreground color and the opacity at a given pixel.
This is done by calculating the conditional probability P(b,f,a|C) at each pixel. The algorithm figures out values of (b,f,a) such that the conditional probability is maximum - that is, a triplet that is highly likely for the given color C.
- b -> background color
- f -> foreground color
- a -> alpha
- C -> color at the current pixel
Here's an example. Given an original photo (the first image) and an initial trimap (the second image), the code should calculate the alphamap (the third image, notice the soft edges on the hair). Using this alpha map, you can composite your original image onto any background.
Once I have the code, I'll put up a tutorial for this technique on http://www.aishack.in/
The research paper "A Bayesian Approach to Digital Matting" was published by the University of Washington and Microsoft Research. You can get the paper here: http://grail.cs.washington.edu/projects/digital-matting/image-matting/
-- still a work in progress --