PyMatting: A Python Library for Alpha Matting
full text: | |
author/s: | Stefan Conrad, Thomas Germer, Stefan Harmeling, Tobias Uelwer |
type: | Article |
journal: | Journal of Open Source Software |
number: | 54 |
volume: | 5 |
pages: | 2481 |
month: | July |
year: | 2020 |
language: | English |
A fundamental problem of many image processing tasks is the extraction of specific objects
from an image in order to place them in a scene of a movie or compose them onto
another background. Alpha matting describes the problem of separating the objects
in the foreground from the background of an image given only a rough sketch.
Besides everyday image editing, alpha matting has been applied to medical image analysis and microscopy image restoration.
For an image I with foreground pixels F and background pixels B,
alpha matting asks to determine opacities α, such that the equality
Iᵢ = α Fᵢ + (1 - α) Bᵢ
holds for every pixel i. This problem is ill-posed since,
for each pixel, we have three equations (one for each color channel) with
seven unknown variables. The implemented methods rely on a trimap, which is a
rough classification of the input image into foreground, background and unknown
pixels, to further constrain the problem. Subsequently, the foreground F can be
extracted from the input image I and the previously computed alpha matte α
using a foreground estimation method.
We introduce the PyMatting toolbox for Python which implements various approaches to solve
the alpha matting problem. Our library is also able to extract the foreground of an image given the alpha matte.
The target audience are researchers of image processing and computer vision.
The implementation aims to be computationally efficient and easy to use.