Example of alpha matting
Shared Sampling for Real-Time Alpha Matting
Eduardo S. L. Gastal
and Manuel M. Oliveira

Instituto de Informática, UFRGS


Computer Graphics Forum.
Volume 29 (2010), Number 2, Proceedings of Eurographics 2010, pp. 575-584.


Abstract Downloads Results Benchmark FAQ Reference Acknowledgements


Image matting aims at extracting foreground elements from an image by means of color and opacity (alpha) estimation. While a lot of progress has been made in recent years on improving the accuracy of matting techniques, one common problem persisted: the low speed of matte computation. We present the first real-time matting technique for natural images and videos. Our technique is based on the observation that, for small neighborhoods, pixels tend to share similar attributes. Therefore, independently treating each pixel in the unknown regions of a trimap results in a lot of redundant work. We show how this computation can be significantly and safely reduced by means of a careful selection of pairs of background and foreground samples. Our technique achieves speedups of up to two orders of magnitude compared to previous ones, while producing high-quality alpha mattes. The quality of our results has been verified through an independent benchmark. The speed of our technique enables, for the first time, real-time alpha matting of videos, and has the potential to enable a new class of exciting applications.



Shared Matting demo for Linux 64-bit (2.7 MB)
Version 1.0, December 2010.

NOTE: Download here a precompiled binary for libboost_program_options.so.1.40.0.


Full paper (1.6 MB, 10 pages)

Eurographics Association Copyright Notice: Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than Eurographics must be honored


Below you can find intermediary results generated by our sample gathering and sample refinement steps. Each tgz archive contains the following images: expanded trimap, foreground color, background color, alpha value (including low-frequency alpha), confidence value and variance value. The original input images and trimaps are available from the alphamatting.com evaluation website.

doll donkey elephant net pineapple
plant plasticbag troll GT04




GT01 GT04 GT07 GT09 GT18 GT21 GT22


Comparison of our technique (Shared Matting) against the state-of-the-art is available at the alphamatting.com evaluation website. The runtimes of our real-time matting technique for the images in this benchmark, using the most conservative trimaps, are as follows:

Image # of pixels % Unknown Time (sec)
elephant 536,800 16% 0.029
donkey 455,200 17% 0.028
pineapple 481,600 20% 0.032
doll 451,200 25% 0.034
plasticbag 529,600 28% 0.040
plant 425,600 35% 0.038
troll 512,000 40% 0.045
net 496,000 51% 0.056


How does one processes pixels which do not find any foreground and/or background samples during the sample gathering?

Mark this pixel as "bad" and let it find a foreground/background sample pair by analyzing its neighboring pixels in the sample refinement step.



Eduardo S. L. Gastal and Manuel M. Oliveira. "Shared Sampling for Real-Time Alpha Matting". Computer Graphics Forum. Volume 29 (2010), Number 2, Proceedings of Eurographics 2010, pp. 575-584.


  author  = {Eduardo S. L. Gastal and Manuel M. Oliveira},
  title   = {Shared Sampling for Real-Time Alpha Matting},
  journal = {Computer Graphics Forum},
  volume  = {29},
  number  = {2},
  month   = {May},
  year    = {2010},
  pages   = {575-584},
  note    = {Proceedings of Eurographics}


Alpha Matting, Compositing, Image processing, Video processing.


CNPq-Brazil fellowships # 200284/2009-6, and 305613/2007-3, and a PIBIC/CNPq/UFRGS fellowship.

Last updated: January 2017.