Final Project: Image Matting
ha4
May 18, 2011

Project Overview
This project was
inspired by the survey report “Image and Video Matting: A Survey” by J. Wang and M. Cohen. As mentioned in this report, there are numerous
techniques to solve matting problem. For the final project, I implemented the
CVPR 2006 paper “Closed-form
Matting” by A. Levin et al.
Development Environment
·
MS Visual Studio 2008 C++ 32bit
·
Library: OpenCV 2.2.0
·
OS: MS Windows 7 64bit
Closed-form Matting Algorithm
1.
The Matting Equations

Matting is an
under-constrained problem as shown below.
------------------------------------- (1)
·
- The Color of the i-th pixel
·
- The Background Color of the
i-th pixel
·
- The Foreground Color of the
i-th pixel
·
- Foreground Opacity of the i0th pixel
For a 3 channel color
image, 7 unknowns but 3 constraints per pixel!
2.
Other Approaches

3.
Closed-form Matting
of “Grayscale” images
Assume that both F
and B are “approximately constant” over a small window around each
pixel. By this assumption equation (1) can be rewritten as
≈ a
+ b , ∀i ∈ w------------------------------
(2)
·
a = 1 / F - B
·
b = -B / F - B
·
w – small image window
4.
Cost function
Finding a, a, b minimizing this
const function,
--------(3)
·
wj –a small
window around pixel j
·
eps – a
regularization term
J is quadratic in a, a and b with
3N unknowns for an image with N pixels
5.
Laplacian

Project Results using Levin’s Algorithm






Future Works
Because the OpenCV’s sparse linear solver function “cv::solve” doesn’t accept the sparse matrix of OpenCV(“cv
::SparseMat”), I should make a
dense matrix(“cv::Mat”) with many zeros instead of a sparse
matrix to use the solver function. This operation not only takes lots of time,
but also doesn’t support image size of bigger than 10,000 pixels, because cv::Mat’s size is limited to
10,000 by 10,000.