Unsupervised Segmentation for Digital Matting

0 downloads 0 Views 2MB Size Report
culi`erement pour les méthodes récentes qui utilisent des mod`eles locaux. ... mier plan et du fond sont représentées par des mod`eles statistiques standards, ...
$

'

Unsupervised Segmentation for Digital Matting

Olivier Juan Renaud Keriven

Research Report 05-04 November 2004

CERTIS, ENPC, 77455 Marne la Vallee, France, http://www.enpc.fr/certis/ &

%

Unsupervised Segmentation for Digital Matting

Segmentation Non-Supervis´ee pour le ‘Digital Matting’

Olivier Juan1 Renaud Keriven1

1

CERTIS, ENPC, 77455 Marne la Vallee, France, http://www.enpc.fr/certis/

Abstract

Digital matting consists in extracting a foreground element from a background image. Besides the image, usual matting methods need to be initialized with two disjoint regions : the set of foreground only pixels and the set of background only pixels. Pixels belonging to none of these two regions are considered as an undetermined blending between the foreground and the background. Here, one has to estimate the opacity (alpha channel) and the original foreground and background colors that have been blended. Initialization is a crucial step for these methods, and usually one has to specify accurate initial regions, leaving undetermined as few pixels as possible. This is especially true for recent methods that use local models. This paper proposes an unsupervised segmentation scheme that initializes any matting method by extracting the foreground and background regions from just a small subset of them. Standard statistical models are used for the foreground and background regions, while a specific one is design for the blended region. The three regions are determined simultaneously using a level set method implementation. Results show that our method works in various conditions, simplifying as much as possible the user’s job. Even when a sufficient - but non perfect - initialization is given to the matting algorithm, it turns out that using our method as a first step significantly improves the final matting result.

R´esum´e

Le ‘Digital Matting’ consiste a` extraire un premier plan d’une image de fond. Les m´ethodes habituelles de ‘Matting’ doivent eˆ tre initialis´ees par deux r´egions disjointes : un ensemble de pixels du premier plan uniquement et un ensemble de pixels du fond uniquement. Des pixels appartenant a` aucune de ces deux r´egions sont consid´er´es comme issus d’un m´elange ind´etermin´e entre le premier plan et le fond. On doit donc estimer l’opacit´e (canal d’alpha) ainsi que les couleurs originales du premier plan et du fond qui ont e´ t´e m´elang´ees. L’initialisation est une e´ tape cruciale pour ces m´ethodes, et habituellement l’utilisateur doit indiquer des r´egions initiales pr´ecises, laissant ind´etermin´e que peu de pixels. Cela vaut particuli`erement pour les m´ethodes r´ecentes qui utilisent des mod`eles locaux. Cet article propose un algorithme de segmentation non supervis´ee qui initialise n’importe quelle m´ethode de ‘Matting’ en extrayant les r´egions du premier plan et du fond simplement a` partir d’un petit sous-ensemble. Les r´egions du premier plan et du fond sont repr´esent´ees par des mod`eles statistiques standards, alors qu’un mod`ele sp´ecifique est introduit pour la r´egion m´elang´ee. Les trois r´egions sont d´etermin´ees simultan´ement en utilisant une formulation par Level Sets. Les r´esultats prouvent que notre m´ethode fonctionne dans diverses conditions, simplifiant autant que possible le travail de l’utilisateur. Mˆeme lorsque une initialisation suffisante - mais non parfait - est donn´ee a` l’algorithme de ‘Matting’, il s’av`ere qu’employer dans un premier temps notre m´ethode am´eliore de mani`ere significative le r´esultat final du ‘Matting’.

Contents 1 Introduction

1

2 Two-Regions segmentation 2.1 Unsupervised Segmentation . . . . . . . . . . . . . . . . . . . . 2.2 Gaussian Mixture Model . . . . . . . . . . . . . . . . . . . . . . 2.3 A First Experiment . . . . . . . . . . . . . . . . . . . . . . . . .

2 2 3 3

3 A PDF for ΩM

5

4 Results 4.1 Synthetic Images . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Bench Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 Natural Images . . . . . . . . . . . . . . . . . . . . . . . . . . .

6 7 7 10

5 Conclusion

11

CERTIS R.R. 05-04

1

1 Introduction Digital matting consists in extracting a foreground element from a background image by estimating an opacity (alpha channel) for each pixel of the foreground element. Matting natural images instead of a images with a known (e.g. blue [14]) background is a relatively recent application of computer vision methods to graphics. A certain number of methods [3, 17, 12] have been proposed since the pioneering work of Ruzon and Tomasi [13]. The commonly used model is the following. An image C is consider as two images CF (foreground) and CB (background) blended through an alpha mask α. For each pixel (i, j), given C(i, j), one has to find two colors CF (i, j) and CB (i, j) and α ∈ [0; 1] such that: C = αCF + (1 − α)CB

(1)

Such a blending has multiple reasons: transparent objects, aliasing, blur or motion blur. This problem is under-constraint and can not be solved without priors. Historically, a solution to this problem was proposed in case of a constant known background, often blue or green [14]. However even with this hard hypothesis, all ambiguities do not vanish. Recently, methods based on a model of the foreground and the background were proposed and greatly improve the matte quality even without a blue screen. Since the first method proposed by Ruzon and Tomasi [13], the methods which give the best results are all based on a local statistical model of the object and the background [3, 17, 12]. The user has to provide a pre-segmentation, the trimap, specifying two regions: the set ΩF of foreground only pixels (where α will always be 1) and the set ΩB of background only pixels (α = 0). Pixel not belonging to one of these regions form an intermediate region ΩM where α, CF and CB are unknown. Like all local methods, matting methods suffer from sensitivity to these initial conditions and one has to generally specify accurate initial regions, leaving undetermined as few pixels as possible. Moreover, when just small subsets of ΩF and ΩB are given, the matting process does not work at all. This paper proposes an unsupervised segmentation scheme that initializes any matting method by extracting the foreground and background regions from just small subsets of them, that can be for instance specified by the user with a brushlike tool. Standard statistical models are used for the foreground and background regions (section 2), while a specific one, described in section 3, is design for the blended region. The three regions are determined simultaneously using a level set method implementation. Results given in section 4 show that our method works in various conditions, simplifying as much as possible the user’s job. Even when a sufficient - but non perfect - initialization is given to the matting algorithm, it turns

Unsupervised Segmentation for Digital Matting

2

out that using our method as a first step significantly improves the final matting result.

2 Two-Regions segmentation 2.1 Unsupervised Segmentation Unsupervised Segmentation of an image has recently received a lot of attention from the Computer Vision community. Many approaches have been proposed, the majority of them are Level Set [11, 10] based (e.g. [2, 5]). We will follow this track and refer the reader to [2] for details. Let Ω1 and Ω2 be two disjoint regions forming a partition of Ω, the image domain. Modeling the pixel colors in each region by some statistical model, the unsupervised segmentation problem can be formulated as the minimization of the energy: E2

Z Z = − log (p1 (C(ω))) dω − log (p2 (C(ω))) dω Ω1

Ω2

+ν length (Γ)

where p1 and p2 are respectively the Probability Density Function (PDF) of the region Ω1 and Ω2 (see further) and Γ is the frontier between Ω1 and Ω2 . If we assume the PDFs fixed and E2 depending only on Γ, it can be shown that the shape gradient (see [4]) leads to the following steepest gradient descent minimization scheme: Γ(p, 0) = Γ0 (p) dΓ(p, t) = [p2 (C(Γ)) − p1 (C(Γ)) + νκ]n dt where Γ0 (p) is some initial guess, Γ(p, t) the contours evolving toward the minimum of E, κ their curvature and n their unit normal. The resulting segmentation is said unsupervised because the PDFs are not fixed but considered unknown and thus re-estimated at each time step using the current position of the contour. In some cases (depending on how the PDFs are estimated), the previous shape gradient is exact, even when taking into account the dependency of the PDFs upon Γ.

CERTIS R.R. 05-04

3

2.2 Gaussian Mixture Model Following previous works, the PDF of a region is modeled by a Gaussian Mixture Model (GMM): N X p(C) = πi Gµi ,Σi (C) i=1

PN

with i=1 πi = 1, where the πi ’s are the proportions of each Gaussian of mean µi and covariance Σi : Gµ,Σ (C) =

|Σ|1/2 −(C−µ)T Σ−1 (C−µ)/2 e (2π)N/2

Estimating the parameters (N, πi , µi , Σi ) is a widely studied problem. Here, we assume that N is given, and we use Expectation-Maximization algorithm (EM) to estimate the other parameters (see [9, 8]). Better algorithms can be used like Split and Merge EM [15] or combining EM to some Minimum Description Length criterion to estimate the number N of Gaussians.

2.3 A First Experiment As we want the image to be segmented in three regions, we use two level sets, following the work in [16]. The energy for this segmentation is similar to the two regions segmentation one: Z Z E3 = − log (pF (C(ω))) dω − log (pM (C(ω))) dω ΩM ZΩ F − log (pB (C(ω))) dω ΩB

+ν (length (ΓF M ) + length (ΓM B )) where ΩF , ΩM and ΩB are forming a partition on the image domain Ω and represent respectively the Foreground, Mixed and Background region, pF , pM and pB the respective Probability Density Functions and ΓF M (resp. ΓM B ) the frontier between ΩF and ΩM (resp. between ΩM and ΩB ). We see from the Figure 1 on the right, that optimizing the contour using standard unsupervised segmentation is not appropriate as the contour penetrate too much in the Mixed region (motion blur wing of the Butterfly). In fact by using GMM for the Mixed region, we have assume all the regions to be independent. However that’s not the case for the Mixed region and another model must be used to describe this one.

4

Unsupervised Segmentation for Digital Matting

Figure 1: Unsupervised three regions segmentation - Upper left: initialization (Foreground in white, Background in gray) - Lower left: final segmentation Right: Zoom on the wing segmentation

CERTIS R.R. 05-04

5

3 A PDF for ΩM As each pixel from the mixed region ΩM results from a blending between a foreground and a background color, the PDF pM depends on pF and pB . In fact, those pixels can be: • A pixel of the foreground (when α = 1 in equation (1)), thus modeled by pF . • A pixel of the background (when α = 0), thus modeled by pB . • A blended pixel (when α ∈]0; 1[), thus modeled by a mixed PDF. When α ∈]0; 1[, we assume for simplicity that both CF and CB come from a single Gaussian of the respective GMM of ΩF and ΩB . In this case, Kitamoto [6, 7] gives a Gaussian approximation of the mixed PDF of two Gaussians blended by α when α follows a Beta Law. Wexler et al. [17] do use a Beta law for α. Yet, they have chosen the parameters for the Beta distribution by estimating them on a reference image. In our case, these parameters must be estimated on the mixed region only and the Beta they propose does not suit to our problem. We simply consider that α follows a uniform law, which will actually give us good results. In that case, if CF comes from Gµi ,Σi , CB from Gµj ,Σj and α from an uniform distribution, the distribution of C is approximated by GµMij ,ΣMij where (see [6, 7]): µi + µ j 2 ¢ 1 1¡ Σi + Σj + (µj − µi ) (µj − µi )T = 3 12

µMij = ΣMij

(2)

For each pair ((µi , Σi ), (µj , Σj )) with i = 1..NF and j = 1..NB , we will consider the NM = NF NB Gaussians GµMij ,ΣMij combined with the previous approximation. Now the the PDF pM of the mixed region ΩM could be modeled by the following GMM p1M (C) =

πF pF (C) + πB pB (C) NF X NB X + πM πMij GµMij ,ΣMij (C) i=1 j=1

P

with πF + πB + πM = 1 and ij πMij = 1. Here πF , πB and πM represent respectively the proportion of Foreground, Background and Mixed pixels in the Mixed region. Yet, as Gaussians from the Foreground and Background are not equally represented in the Mixed region, this

Unsupervised Segmentation for Digital Matting

6

model does not fit ΩM and we have to consider a proportion parameter for each Foreground and Background Gaussian. The PDF of the Mixed region becomes: p2M (C)

NF X

=

π ˆi Gµi ,Σi (C)

i=1

+

NB X

ˆ j Gµ ,Σ (C) π j j

j=1

+

NF X NB X

πMij GµMij ,ΣMij (C)

i=1 j=1

P P P ˆ j + ij πMij = 1. with i π ˆi + j π Although p2M is a good model for ΩM , using it during the minimization process is not suitable. Indeed, according to p2M , Foreground (resp. Background) colors are acceptable with no limit if both ΩF (resp. ΩB ) and ΩM . As a result, the segmentation task has no reason to push pixels of the Mixed region with such colors back to the Foreground (resp. Background) region. The wanted behavior will rather be obtained estimating the parameters of p2M and then using only the following mixed part in the energy: p3M (C)

=K

NB NF X X

πMij GµMij ,ΣMij (C)

(3)

i=1 j=1

where K is a normalizing factor, and where the parameters are those of p2M . ˆ j , πMij ) Moreover, it can be easily shown that running the EM algorithm on (ˆ πi , π 3 and then trunking an normalizing the model to pM gives the same result as running the EM algorithm on (πMij ) only (due to lack of place, we delay this simple proof to a more complete version of this paper). Finally, the PDF of the Mixed Region boils down to: NB NF X X F (4) π ˆMij GµMij ,ΣMij (C) pM (C) = P

i=1 j=1

with ij π ˆMij = 1 and where the (µMij , ΣMij )ij are given by equation (2) and the (ˆ πMij ) are directly estimated using the EM algorithm on ΩM .

4 Results In this section, we present some results of our ‘trimap’ segmentation algorithm using pFM and the energy E3 . We also present alpha mattes obtained by the implementation of [3]. We also propose another matting algorithm taking advantage of the GMMs computed during our segmentation.

CERTIS R.R. 05-04

7

Chuang et al.’s matting algorithm is based on estimating local statistics of the foreground and the background. For each pixel in the Mixed region, Gaussian distributions for the Foreground and the Background are estimated on a neighborhood of the pixel. The problem can be defined as a log-likelihood maximization: argmax L(F, B, α|C) = argmax(L(C|F, B, α) F,B,α

F,B,α

+L(F ) + L(B))

(5)

where L refer to log-likelihoods, L(C|F, B, α) = − kC − αF − (1 − α)Bk2 /σC2 , L(F ) = −(F − F )T Σ−1 F (F − F ) with F and ΣF are the estimated mean and covariance of the Foreground, L(B) is defined similarly for the Background, and σC some control parameter. This problem is solved by alternatively fixing α and (F, B) As a variant, we propose to do the same but without estimating the statistics locally. These statistics can be retrieved from the PDF of the Foreground and the Background (pF and pB ). We do not test all the pairs of Gaussians, but use the information from the Mixed PDF to choose the best pair of Gaussians explaining each blended pixel. By computing: argmax πMij GµMij ,ΣMij (C) ij

for a given pixel C of the Mixed region. We obtain that the pair (Gµi ,Σi , Gµj ,Σj ) respectively from the PDF of the Foreground and of the Background, is the more probable pair to reconstruct C.

4.1 Synthetic Images On synthetic images (Figure 2), we show that our algorithm converge toward a good estimation of the real trimap although the initial segmentation is quite far from the solution. Moreover when adding additive Gaussian noise, the algorithm still converges to a trimap not close to the reel one and the Mixed region does not vanish because noisy data.

4.2 Bench Image We used here a bench image given by Chuang et al. On the first row of the figure 3, we see the initial image and the initial segmentation where the Foreground is displayed in white and the Background in gray. On the second row, on the left we see the user defined trimap used by Chuang et al, on the right the reconstruct trimap from the initial segmentation using our algorithm. On the third row, on

8

Unsupervised Segmentation for Digital Matting

CERTIS R.R. 05-04

9

Figure 3: Teddy Bear bench - First row: initial image & initial segmentation - Second row: High quality user maid trimap by Chuang et al & final trimap obtained by our algorithm - Third row: True Alpha Matte & Alpha Estimation using a rough trimap and Chuang et al algorithm - Fourth row: Alpha Estimation using our final trimap and Chuang et al algorithm & Alpha Estimation using our final trimap and our Alpha Matting algorithm

10

Unsupervised Segmentation for Digital Matting

the left we see the true Alpha Matte and on the right the alpha estimation using Chuang algorithm with a bad initialized trimap. As this technique uses a local estimation of the foreground and background statistics, the quality of the alpha estimation is directly linked to the quality of the initialization. In fact, on the fourth row, on the left, we see the Chuang’s alpha estimation using our generated trimap and the result is clearly better than with a rough initialization. On the right, we see our alpha estimator using our trimap. The quality is obviously improved by using our method however our trimap evolution algorithm penetrate too much in the Mixed Region.

4.3 Natural Images

Figure 4: Real Image Samples - First column: image - Second Column: Initial segmentation - Third Column: final trimap segmentation - Fourth Column: Alpha Estimation using Chuang Algorithm If we look attentively to the real images on figure 4, we can see that the antenna of the butterfly is not correctly segmented by our algorithm. This is due to the

CERTIS R.R. 05-04

11

smoothing term of our energy. Such a term is quite unavoidable when using a level set implementation. Future work will include using Graph-Cuts [1] to improve the segmentation of small objects.

5 Conclusion In this paper, we propose an unsupervised segmentation scheme that initializes any matting method by extracting the foreground and background regions from just a small subset of them. A specific model is design for the blended region. The three regions are determined simultaneously using a level set method implementation. Results show that our method works in various conditions, simplifying as much as possible the user’s job. Even when a sufficient - but non perfect - initialization is given to the matting algorithm, it turns out that using our method as a first step significantly improves the final matting result. Finally, we take advantage of our segmentation to propose a sometimes better matting algorithms. Future work will include using graph-cut to overcome some of the problems of the level set method.

References [1] Y. Boykov, O. Veksler, and R. Zabih. Fast Approximate Energy Minimization via Graph Cuts. IEEE Transactions on Pattern Analysis and Machine Intelligence, 23:1222–1239, 2001. [2] Thomas Brox, Mikael Rousson, Rachid Deriche, and Joachim Weickert. Unsupervised segmentation incorporating colour, texture, and motion. In 10th International Computer Analysis of Images and Patterns, number 2756 in Lecture Notes on Computer Science., pages 353–360. Springer Verlag, August 2003. [3] Yung-Yu Chuang, Brian Curless, David H. Salesin, and Richard Szeliski. A bayesian approach to digital matting. In Proceedings of IEEE CVPR 2001, volume 2, pages 264–271. IEEE Computer Society, December 2001. [4] M.C. Delfour and J.-P. Zolsio. Shapes and geometries. Advances in Design and Control. Siam, 2001. [5] Timor Kadir and Michael Brady. Unsupervised non-parametric region segmentation using level sets. In Proceedings of ICCV 2003, October 2003. [6] Asanobu KITAMOTO. The moments of the mixel distribution and its application to statistical image classification. In A. Amin, F.J. Ferri, J.M. Inesta,

12

Unsupervised Segmentation for Digital Matting and P. Pudil, editors, Advances in Pattern Recognition (SPR’00), Lecture Notes in Computer Science 1876, pages 521–531. Springer, 8 2000. (in English).

[7] Asanobu KITAMOTO and Mikio TAKAGI. Area proportion distribution – relationship with the internal structure of mixels and its application to image classification. Systems and Computers in Japan, 31(5):57–76, 5 2000. (in English). [8] G.J. McLachlan and P. David. Finite Mixture Models. Wiley, New York, 2000. [9] G.J. McLachlan and T. Krishnan. The EM algorithm and extensions. Wiley, New York, 1997. [10] S. Osher and N. Paragios, editors. Geometric Level Set Methods in Imaging, Vision and Graphics. Springer Verlag, 2003. [11] S. Osher and J. Sethian. Fronts propagating with curvature dependent speed: algorithms based on the Hamilton–Jacobi formulation. Journal of Computational Physics, 79:12–49, 1988. [12] Patrick Perez, Michel Gangnet, and Andrew Blake. Poisson image editing. ACM Trans. Graph., 22(3):313–318, 2003. [13] M. Ruzon and C. Tomasi. Alpha estimation in natural images. pages 18–25. [14] Alvy Ray Smith and James F. Blinn. Blue screen matting. In Proceedings of the 23rd annual conference on Computer graphics and interactive techniques, pages 259–268. ACM Press, 1996. [15] Naonori Ueda, Ryohei Nakano, Zoubin Ghahramani, and Geoffrey E. Hinton. Smem algorithm for mixture models. Neural Computation, 12(9):2109– 2128, 2000. [16] Luminita Vese and Tony Chan. A multiphase level set framework for image segmentation using the mumford and shah model. International Journal of Computer Vision, 50:271–293, 2002. [17] Y. Wexler, A. Fitzgibbon, and A. Zisserman. Bayesian estimation of layers from multiple images, 2002.