Skip to content
liquidmetal edited this page Mar 16, 2012 · 10 revisions

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

Example

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.

The original photo The trimap The alphamap The resulting image Composited on another image

Tutorial

Once I have the code, I'll put up a tutorial for this technique on http://www.aishack.in/

Original paper

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

Clone this wiki locally