OpenCV
5.0.0-pre
Open Source Computer Vision
|
This project was part of Google Summer of Code 2019.
Student: Muskaan Kularia
Mentor: Sunita Nayak
Alphamatting is the problem of extracting the foreground with soft boundaries from a background image. The extracted foreground can be used for further operations like changing the background in an image.
Given an input image and its corresponding trimap, we try to extract the foreground from the background. Following is an example:
Input Image:
Input image should be preferably a RGB image.
Input Trimap:
The trimap image is a greyscale image that contains information about the foreground(white pixels), background(black pixels) and unknown(grey) pixels.
Output alpha Matte:
The computed alpha matte is saved as a greyscale image where the pixel values indicate the opacity of the extracted foreground object. These opacity values can be used to blend the foreground object into a diffferent backgound, as shown below:
Following are some more results.
The first column is input RGB image, the second column is input trimap, third column is the extracted alpha matte and the last two columns show the foreground object blended on new backgrounds.
This project is implementation of [7] . It also required implementation of parts of other papers [2,3,4].
This module uses the Eigen package.
Build the sample code of the alphamat module using the following two cmake commands run inside the build folder:
Please refer to OpenCV building tutorials for further details, if needed.
The built target can be tested as follows:
[1] Yagiz Aksoy, Tunc Ozan Aydin, Marc Pollefeys, Designing Effective Inter-Pixel Information Flow for Natural Image Matting, CVPR, 2017.
[2] Roweis, Sam T., and Lawrence K. Saul. Nonlinear dimensionality reduction by locally linear embedding, Science 290.5500 (2000): 2323-2326.
[3] Anat Levin, Dani Lischinski, Yair Weiss, A Closed Form Solution to Natural Image Matting, IEEE TPAMI, 2008.
[4] Qifeng Chen, Dingzeyu Li, Chi-Keung Tang, KNN Matting, IEEE TPAMI, 2013.
[5] Yagiz Aksoy, Affinity Based Matting Toolbox.