/bayesian-matting

Python implementation of Bayesian Matting from Yung-Yu Chuang, Brian Curless, David H. Salesin, and Richard Szeliski. A Bayesian Approach to Digital Matting. In Proceedings of IEEE Computer Vision and Pattern Recognition (CVPR 2001), Vol. II, 264-271, December 2001

Primary LanguagePython

bayesian-matting

Python implementation of Yung-Yu Chuang, Brian Curless, David H. Salesin, and Richard Szeliski. A Bayesian Approach to Digital Matting. In Proceedings of IEEE Computer Vision and Pattern Recognition (CVPR 2001), Vol. II, 264-271, December 2001

Requirements

  • python 3.5+ (Though it should run on 2.7 with some minor tweaks)
  • scipy
  • numpy
  • numba > 0.30.1 (Not neccesary, but does give a 5x speedup)
  • matplotlib
  • opencv
  • sys
  • pathlib
  • argparse

Running the demo

  • 'python bayesian_matting.py gandalf.png gandalfTrimap.png'
  • sigma (σ) fall off of gaussian weighting to local window
  • N size of window to construct local fg/bg clusters from
  • minN minimum number of known pixels in local window to proceed
  • minN_reduction to reduce N by in event of infinite loop. May reduce accuracy

Results

Original image

Trimap image

Result

More Information

For more information see the orginal project website http://grail.cs.washington.edu/projects/digital-matting/image-matting/ This implementation was mostly adapted from Michael Rubinsteins matlab code here, http://www1.idc.ac.il/toky/CompPhoto-09/Projects/Stud_projects/Miki/index.html http://people.csail.mit.edu/mrub/code/bayesmat.zip

Disclaimer

The code is free for academic/research purpose. Use at your own risk and we are not responsible for any loss resulting from this code. Feel free to submit pull request for bug fixes.

Contact

Marco Forte (fortem@tcd.ie)

Original authors:

Yung-Yu Chuang Brian Curless David Salesin Richard Szeliski