# Patent

## Title
Methods and systems for image matting and foreground estimation based on hierarchical graphs

## Abstract

In accordance with an embodiment, a method for image matting based on a hierarchical graph model, comprises receiving an input image including a plurality of image elements; generating a plurality of matting cells based on the input image, each cell including a group of image elements; calculating affinity values for the plurality of matting cells based on the input image; forming a graph based on the plurality of matting cells and the affinity values, the graph including a plurality of nodes representing the matting cells and a plurality of edges associated with the affinity values of the matting cells; and generating a plurality of matting components for the input image based on the graph.

## Background
FIELD OF THE DISCLOSURE
This disclosure is related to image matting in general and, more particularly, image matting and foreground estimation based on hierarchical graphs.
BACKGROUND
Image matting is a process of extracting foreground objects from an image, along with a parameter called an alpha matte. This process leads to useful applications, such as image and video editing, image layer decomposition, and scene analysis. In image matting, a pixel value Ii at a pixel i may be modeled as a linear combination of a foreground color value Fi and a background color value Bi. That is,

Ii=αiFi+(1−αi)Bi,  (1)

where αi represents the alpha matte value corresponding to opacity of the foreground color.

Conventional image matting techniques can be generally classified into two categories: supervised matting and unsupervised matting. In supervised matting, a user's guidance is provided to label a few pixels to be either “foreground” or “background.” Based on these labeled pixels, a supervised matting method estimates the alpha matte values for remaining unlabeled pixels. In contrast, unsupervised matting aims to automatically estimate the alpha matte from the input image without any user guidance.
Conventional image matting techniques have several drawbacks. First, conventional unsupervised matting techniques are computationally intensive. Although image processing schemes have been proposed to reduce the required computations, these existing schemes may result in degraded image quality.
Second, results produced by conventional image matting techniques may not always be consistent. Lack of global information during the matting process makes it difficult to produce consistent results in dealing with images with cluttered scenes.
Third, conventional unsupervised matting techniques focus on binary partitioning of image content. Since an image may contain more than one foreground object, results generated by these conventional unsupervised matting techniques may not be very practical.
SUMMARY
In accordance with an embodiment, a method for image matting based on a hierarchical graph model, comprises receiving an input image including a plurality of image elements; generating a plurality of matting cells based on the input image, each cell including a group of image elements; calculating affinity values for the plurality of matting cells based on the input image; forming a graph based on the plurality of matting cells and the affinity values, the graph including a plurality of nodes representing the matting cells and a plurality of edges associated with the affinity values of the matting cells; and generating a plurality of matting components for the input image based on the graph.
In accordance with another embodiment, a method for image matting based on hierarchical graphs, comprises receiving an input image including a plurality of image elements; forming a first graph based on the input image, the first graph including a plurality of first nodes representing the image elements and a plurality of first edges representing affinity relationships among the image elements; forming a second graph by grouping the image elements into a plurality of cells, the second graph including a plurality of second nodes representing the cells and a plurality of second edges representing affinity relationships among the cells; forming a third graph by decomposing the second graph into a plurality of matting components, the third graph including a plurality of third nodes representing the matting components and a plurality of edges representing affinity relationships among the matting components; and determining probabilities of the matting components belonging to a foreground region of the input image based on the third graph.
In accordance with another embodiment, a non-transitory computer-readable medium stores instructions, which, when executed by a processor, cause the processor to perform a method for image matting based on hierarchical graphs. The method comprises receiving an input image including a plurality of image elements; generating a plurality of matting cells based on the input image, each cell including a group of image elements; calculating affinity values for the plurality of matting cells based on the input image; forming a graph based on the plurality of matting cells and the affinity values, the graph including a plurality of nodes representing the matting cells and a plurality of edges representing affinity information of the matting cells; and generating a plurality of matting components for the input image based on the graph.
Additional features and advantages will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the disclosed embodiments. The features and advantages will be realized and attained by means of the elements and combinations particularly pointed out in the appended claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate several embodiments and together with the description, serve to explain the principles of the disclosure.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1A is a block diagram of an exemplary system for image matting based on hierarchical graphs, according to an embodiment;
FIG. 1B is a schematic diagram of a computer system for implementing the system of FIG. 1A, according to an embodiment;
FIG. 2 illustrates an exemplary contraction process based on a pixel-level graph, according to an embodiment;
FIG. 3 illustrates results of the contraction process when applied to an exemplary input image, according to an embodiment;
FIG. 4 illustrates a pixel-to-cell mapping process based on a feature space, according to an embodiment;
FIGS. 5(a)-5(d) illustrate exemplary embodiments of fixed-resolution schemes and a multi-resolution scheme for cell-level graph modeling;
FIG. 6 illustrates cell-level processing based on multi-resolution image patches, according to an embodiment;
FIG. 7 illustrates a cell-to-component mapping, according to an embodiment;
FIG. 8 illustrates exemplary embodiments of an input image, a matting segment, and a matting component;
FIG. 9 illustrates an exemplary embodiment of a component-level graph;
FIG. 10 illustrates a component-to-layer mapping, according to an embodiment;
FIG. 11A illustrates matting results based on a direct mapping from cells to layers, according to an embodiment;
FIG. 11B illustrates matting results based on a multi-resolution mapping from cells to components and then to layers, according to an embodiment;
FIG. 12 illustrates exemplary embodiments of matting layers and a possibility map for a foreground region of an input image;
FIG. 13 illustrates a process for image matting and foreground estimation based on hierarchical graphs, according to an embodiment; and
FIG. 14 illustrates a process for image matting and foreground estimation based on hierarchical graphs, according to another embodiment.



DESCRIPTION OF THE EMBODIMENTS
Reference will now be made in detail to the exemplary embodiments of the disclosure, examples of which are illustrated in the accompanying drawings. Wherever possible, the same reference numbers will be used throughout the drawings to refer to the same or like parts.
According to some embodiments of the disclosure, a hierarchical framework is disclosed to perform image matting, including supervised and unsupervised matting. Based on a bottom-up mechanism, the hierarchical framework gradually condenses image data from pixels to cells, from cells to components, and finally from components to matting layers. More specifically, at a first level (i.e., the pixel level) of the hierarchical framework, image pixels are first condensed to cells through a pixel-to-cell mapping. This mapping is based on an assumption that neighboring data in a feature space tend to share similar matting values. This condensation process can greatly reduce required computations for spectral analysis without generating noticeable quality degradation.
At a second level (i.e., the cell level), the cell-based structure provides learning of multi-scale affinity based on a cell-level graph. The multi-scale affinity learning may effectively improve the performance of spectral analysis when dealing with images of cluttered scenes. From the cell-level graph, matting components are automatically extracted by solving a graph partitioning problem.
At a third level (i.e., the component level), a component-level graph is generated for the estimation of multiple matting layers. According to a further embodiment, a foreground probability distribution model is applied to stochastically generate a list of possible foreground mattes and estimate the foreground possibility for the matting layers.
FIG. 1A depicts a system 100 for image matting based on hierarchical graphs, according to an embodiment of the disclosure. System 100 includes a pixel processing module 102, a cell processing module 104, a component processing module 106, a layer processing module 108, and a foreground estimation module 110. Modules 102-110 may be arranged in series so that pixel processing module 102 receives input data 112 and foreground estimation module 110 produces output data 114. Cell processing module 104, component processing module 106, and layer processing module 108 carry out intermediate processing steps according to the order shown in FIG. 1A. One or more of modules 102-110 may be omitted from system 100. For example, layer processing module 108 may be omitted, so that foreground estimation module 110 generates output data based on data provided by component processing module 106.
In one embodiment, modules 102-110 shown in FIG. 1A may be implemented by a computer system 120 shown in FIG. 1B including a processor 122 and a non-transitory computer-readable medium 124. Processor 122 can be a central processing unit (CPU), such as an INTEL processor, an AMD processor, or other processor known in the art. Computer-readable medium 124 can include a hard drive, a flash drive, a CD, a DVD, a RAM, a ROM, or the like, which is configured to store instructions and data relevant to the image matting technique disclosed herein. The instructions can be written in C, C++, BASIC, FORTRAN, JAVA, or other programming languages known in the art. Processor 122 receives the instructions and data from computer-readable medium 124 and carries out the functions of modules 102-110 as described here.
In another embodiment, modules 102-110 may be implemented on a programmable integrated circuit, such as a programmable logic array, a field-programmable gate array, an application-specific integrated circuit, and the like.
System 100 may further include user input/output (I/O) devices 126 and 128, such as a display device 128, a keyboard 126, a mouse, a touchpad, a touch screen, and the like. For example, system 100 receives user input through keyboard 126 and applies the image matting techniques to the input data according to the user input. System 100 then presents the output data to a user through display device 128.
Input data 112 may include image data or video data provided by a user or an external system or received from a storage medium such as a hard drive, a flash drive, a CD, a DVD, a RAM, a ROM, etc. Input data 112 may represent images or video frames of any natural scenes captured by an imaging system, such as a camera or a camcorder. Input data 112 may also represent images or video frames of synthetic or artificial scenes that are generated by a computer. The scenes represented by input data 112 include one or more foreground objects that are relatively close to the imaging system that captures the images or video frames. The scenes also include one or more background objects that are relatively further away from the imaging system that captures the images or video frames.
The images or video frames in input data 112 may be represented by image elements, such as pixels, arranged in one or more regular arrays including rows and columns. Each image element includes one or more values defined according to a color space, such as the RGB color space, the CMYK color space, or other color spaces known in the art. In one embodiment, each image element is associated with either one of the foreground objects or one of the background objects, such that the image element represents part of the foreground object or the background object. In another embodiment, each image element may be associated with a combination of one of the foreground objects and one of the background objects, such that the image elements falls on an image boundary between the foreground objects and the background objects.
Output data 114 may identify the image elements in the input data that are associated with the foreground objects and/or the background objects. In one embodiment, output data 114 includes a mask having a plurality of elements. Each element of the mask is associated with an image element of input data 112 and includes a value, such as an alpha matte value, which correspond to the opacity of one of foreground objects. For example, an element of the mask having a value of zero may identify a completely transparent foreground object or lack of foreground objects, such that the associated image element is associated with a background object. An element of the mask having a value of one may correspond to a completely opaque foreground object, such that the associated image element is associated with the foreground object. An element of the mask having a fractional value may correspond to a combination of a foreground object and a background object. This occurs when the foreground object is partially transparent or the image element falls on the image boundary between the foreground object and the background object. The fractional value represents a contribution by the foreground object to the associated image element.
According to the embodiments of this disclosure, system 100 applies image matting process to input data 112 based on a hierarchical graph model. The hierarchical graph model includes a plurality of levels, such as the pixel level, the cell level, and the component level. Accordingly, the disclosed process includes a plurality of stages executed by respective modules 102-110. These stages include, for example, a pixel-level processing stage, a cell-level processing stage, and a component-level processing stage. Data produced by component processing module 106 may be further processed by layer processing module 108 and foreground estimation module 110 to generate output data 114. As the process proceeds through the stages, the number of elements in the processed data is gradually reduced, thereby providing an efficient and accurate estimate of the foregrounds and the alpha mattes of input data 112. Details of modules 102-110 are further described hereinafter with reference to FIGS. 2-10.
Contraction Process
According to an embodiment, the pixel-level processing stage forms the first stage of the image matting process based on the hierarchical graph model. The pixel-level processing stage is carried out by pixel-processing module 102. Module 102 is configured to condense image elements, such as pixels, in input data 112 into compact cells in order to reduce the required computations in subsequent stages. The term “condense” as used herein refers to a process of spatially gathering similar image pixels together.
To condense pixels, module 102 applies a local contraction process based on a minimization of a graph-based energy function. Details of the local contraction process are explained as follows.
In the local contraction process, input data 112, such as an input image, is first represented as a graph, where vertices of the graph represent the pixel-wise intensity data and each edge between a pair of vertices represents an affinity between the corresponding pixel pair. Here, the affinity value Aq(i,j) between two pixels i and j is defined as:




  
    
      
        
          
            A
            q
          
          ⁡
          
            (
            
              i
              ,
              j
            
            )
          
        
        =
        
          
            1
            
              
              
                ω
                q
              
              
            
          
          ⁢
          
            
              (
              
                1
                +
                
                  
                    
                      (
                      
                        
                          I
                          i
                        
                        -
                        
                          μ
                          q
                        
                      
                      )
                    
                    T
                  
                  ⁢
                  
                    
                      (
                      
                        
                          ∑
                          q
                        
                        ⁢
                        
                          
                            +
                            
                              ɛ
                              
                                
                                
                                  ω
                                  q
                                
                                
                              
                            
                          
                          ⁢
                          U
                        
                      
                      )
                    
                    
                      -
                      1
                    
                  
                  ⁢
                  
                    (
                    
                      
                        I
                        j
                      
                      -
                      
                        μ
                        q
                      
                    
                    )
                  
                
              
              )
            
            .
          
        
      
    
    
      
        (
        2
        )
      
    
  




In equation (2) above, Ii and Ij represent color values of an input image I at pixels i and j, μq represents a 3×1 mean color vector in a window ωq of pixels, Σq represents a 3×3 covariance matrix, |ωq| represents the number of pixels in the local window ωq, U represents a 3×3 identity matrix, and ε represents a regularization term to avoid over-fitting in smooth regions. For example, in a smooth region, entries in Σq have relatively small values so that a small deviation caused by noise may induce a large variation of the affinity value. By properly adding a small value of ε, fluctuations of the affinity value in smooth regions can be effectively suppressed. According to equation (2), if two pixels have similar color appearance, the affinity value between them is relatively large. The local window ωq is used to scan through the whole image to produce several affinity values for every edge in the input image. By averaging these affinity values for each edge, a pixel-level graph model is generated.
According to an embodiment, an x-y coordinate system is defined for the input image I, wherein the x-axis is along a first dimension of the pixel array and the y-axis is along a second dimension of the pixel array. The x-coordinate and the y-coordinate of each image pixel are normalized to the range of [0, 1]. In addition, it is assumed that (x, y) represent the normalized coordinates, that is, the original spatial coordinates of the ith pixel in the input image, and ({tilde over (x)}, {tilde over (y)}) represent the contracted coordinates, that is, the spatial coordinates of the ith pixel after the local contraction process. Moreover, the following vectors are defined based on the pixel coordinates:

x=[x1 x2 . . . xN]T, y=[y1 y2 . . . yN]T, {tilde over (x)}=[{tilde over (x)}1 {tilde over (x)}2 . . . {tilde over (x)}N]T, and {tilde over (y)}=[{tilde over (y)}1 {tilde over (y)}2 . . . {tilde over (y)}N]T,

where N represents the total number of pixels in the input image. Accordingly, the local contraction process may be represented as derivations of optimal vectors, {tilde over (x)} and {tilde over (y)}, which minimize the following energy functions Ex({tilde over (x)}) and Ey({tilde over (y)}):





  
    
      
        
          
            
              E
              x
            
            ⁡
            
              (
              
                x
                ~
              
              )
            
          
          =
          
            
              
                ∑
                
                  ω
                  q
                
              
              ⁢
              
                
                  ∑
                  
                    i
                    ,
                    
                      j
                      ∈
                      
                        ω
                        q
                      
                    
                  
                
                ⁢
                
                  
                    
                      A
                      q
                    
                    ⁡
                    
                      (
                      
                        i
                        ,
                        j
                      
                      )
                    
                  
                  ⁢
                  
                    
                      (
                      
                        
                          
                            x
                            ~
                          
                          i
                        
                        -
                        
                          
                            x
                            ~
                          
                          j
                        
                      
                      )
                    
                    2
                  
                
              
            
            +
            
              
                λ
                x
              
              ⁢
              
                
                  ∑
                  
                    k
                    =
                    1
                  
                  N
                
                ⁢
                
                  
                    (
                    
                      
                        
                          x
                          ~
                        
                        k
                      
                      -
                      
                        x
                        k
                      
                    
                    )
                  
                  2
                
              
            
          
        
        ,
        
          

        
        ⁢
        and
      
    
    
      
        (
        3
        )
      
    
  
  
    
      
        
          
            E
            y
          
          ⁡
          
            (
            
              y
              ~
            
            )
          
        
        =
        
          
            
              ∑
              
                ω
                q
              
            
            ⁢
            
              
                ∑
                
                  i
                  ,
                  
                    j
                    ∈
                    
                      ω
                      q
                    
                  
                
              
              ⁢
              
                
                  
                    A
                    q
                  
                  ⁡
                  
                    (
                    
                      i
                      ,
                      j
                    
                    )
                  
                
                ⁢
                
                  
                    (
                    
                      
                        
                          y
                          ~
                        
                        i
                      
                      -
                      
                        
                          y
                          ~
                        
                        j
                      
                    
                    )
                  
                  2
                
              
            
          
          +
          
            
              λ
              y
            
            ⁢
            
              
                ∑
                
                  k
                  =
                  1
                
                N
              
              ⁢
              
                
                  
                    (
                    
                      
                        
                          y
                          ~
                        
                        k
                      
                      -
                      
                        y
                        k
                      
                    
                    )
                  
                  2
                
                .
              
            
          
        
      
    
    
      
        (
        4
        )
      
    
  




In each of functions (3) and (4), the first term on the right hand side corresponds to the pair-wise cohesion forces that tend to pull pixels spatially closer, while the second term on the right hand side corresponds to the deviation cost that seeks to preserve the original image structure. Parameters λx and λy are used to control the strength of contraction.
In order to find the optimal vectors {tilde over (x)} and {tilde over (y)}, equations (3) and (4) are rewritten as:

Ex({tilde over (x)})=2{tilde over (x)}TL{tilde over (x)}+λx({tilde over (x)}−x)T({tilde over (x)}−x),  (5)

and

Ey(y)=2{tilde over (y)}TL{tilde over (y)}+λx({tilde over (y)}−y)T({tilde over (y)}−y).  (6)

Here, L denotes the graph Laplacian matrix, whose off-diagonal entries are defined as L(i, j)=−Σωq|(i,j)εωqAq(i,j), diagonal entries are defined as L(i,i)=ΣjΣωq|(i,j)εωqAq(i,j), and T represents the transpose operator. By differentiating equations (5) and (6) with respect to {tilde over (x)} and {tilde over (y)} respectively, the following linear system is produced:

(2L+λxI){tilde over (x)}=λxx,  (7)

and

(2L+λyI){tilde over (y)}=λyy.  (8)

The optimal solutions are then solved based on the above linear system of equations (7) and (8).

FIG. 2 illustrates an exemplary local contraction process, according to an embodiment. In FIG. 2, the input image in input data 112 is represented by an initial graph 202, in which each vertex 206 represents an image pixel with its color value, and each edge 208 represents an affinity relationship between a pair of adjacent pixels. Application of the contraction process to initial graph 202 results in contracted graph 204, in which pixels with relatively high affinity values are contracted towards each other.
FIG. 3 shows an exemplary input image 302 and a contracted image 304 after the local contraction process. It can be seen that pixels with similar appearance converge toward each other after the contraction process, while pixels with dissimilar appearance tend to move apart from each other.
After the contraction process, the contracted image pixels are merged or condensed into multiple cells. Here, a five-dimensional feature space W is defined, based on the contracted spatial coordinates ({tilde over (x)}, {tilde over (y)}) and the RGB color values (IR, IG, IB). FIG. 4 shows an exemplary embodiment 402 of the five-dimensional feature space W. For ease of illustration, the color coordinates are combined in feature space 402 to show a three-dimensional representation thereof. A feature vector is defined for each contracted image pixel of contracted image 304 of input image 302 (FIG. 3) in feature space 402. In feature space 402, spatially neighboring pixels with different colors are pulled away from each other and are less likely to get blended together.
According to an embodiment, the merging or condensation of image pixels into cells is represented as a pixel-to-cell mapping process. A pixel i with contracted coordinates ({tilde over (x)}, {tilde over (y)}) and RGB values (IR, IG, IB) is mapped to a cell with an index ([{tilde over (x)}i×bs], [{tilde over (y)}i×bs], [IiR×bc], [IiG×bc], [IiB×bc]). Here, the symbol “[ ]” represents a rounding operation, bs represents a number of spatial sampling bins, and bc represents a number of color sampling bins.
The pixel-to-cell mapping of the whole contracted image is recorded in an N×P binary matrix M, where N and P denote the total number of image pixels and cells, respectively. Here, if the ith pixel is mapped to the jth cell, then M(i,j)=1, and M(i, k)=0 for all k≠j.
In one embodiment, parameters bs and bc are set to 15 so that the number of cells P is about 10,000 to 20,000. In other embodiments, parameters bs and bc may be set to any values between 10 and 20. In still other embodiments, parameters bs and bc may be set to any other values as appropriate.
Multi-Scale Affinity and Cell-Level Graph
After the image pixels are merged into cells by pixel processing module 102, the cells are output to cell processing module 104, which determines a cell affinity value between each pair of cells in order to construct a cell-level graph model. In an embodiment, cell processing module 104 applies a multi-scale or multi-resolution approach to determine the affinity information from an image pyramid. The multi-scale cell-level graph model is further described below.
FIGS. 5(a)-5(d) illustrate exemplary embodiments of fixed-resolution scheme and multi-resolution scheme celled-level graph modeling. The schemes enable determining the affinity value between cells at different spatial ranges. The left image of FIG. 5(a) shows an image of an artificial scene that contains a circular object 502 with a square hole, and a small triangular object 504. The middle and right images of FIG. 5(a) illustrate the corresponding feature distributions at the pixel level and the cell level, respectively. Here, circles represent individual pixels, and cubes represent individual cells.
FIGS. 5(b) and 5(c) illustrate different embodiments that use different local windows each including 3×3 sampling pixels to explore the affinity information around an image pixel. Here, each “⊕” symbol represents a sampling pixel. The local window in the left image of FIG. 5(b) covers a relatively small spatial region including only immediately adjacent pixels, while the local window in the left image of FIG. 5(c) covers a relatively large spatial region including more distant pixels.
Based on Equation (2), the affinity value for each pair of the nine sampling pixels is determined. The middle image of FIG. 5(b) shows the corresponding coverage of pixel pairs in the feature space. In this case, only the affinity values of adjacent sampling pixels are determined. A far-range affinity, such as the affinity between the pixels within the hole and the pixels outside circular object 502, is not calculated. In contrast, in the embodiment of FIG. 2(c), the affinity among distant sampling pixels is calculated, while some details may be lost, such as the relationship between triangular object 504 and circular object 502.
The right images of FIGS. 5(b) and 5(c) show the affinity among the cells after the image pixels are merged. Similarly, the small-scale sampling window provides a near-range affinity among the cells, while the large-scale sampling window provides the far-range affinity among the cells.
To explore the affinity for both near and far ranges, the embodiment of FIG. 5(d) uses the multi-scale approach, where both a small-scale window and a large-scale window are used to sample the input image. It can be seen from the right image of FIG. 5(d), both the near-range and far-range affinity information among cells is determined based on the multi-scale sampling scheme. In addition, at the cell level, a lot of redundant affinity computations can be saved as compared to the pixel-level affinity estimation.
According to a further embodiment, the multi-scale affinity estimation is implemented by computing affinity over a set of multi-resolution image patches. FIG. 6 illustrates cell-level processing based on multi-resolution image patches, according to an embodiment. For example, multi-resolution image patches 602 are sampled from a Gaussian image pyramid 604. Here, image pyramid 604 may be generated by module 104 from input image 302 by recursively performing a down-sampling process with a sampling rate ds, along both x and y-axes. Resulting image pyramid 604 includes a coarsest image 604A, one or more intermediate-resolution images 604B, and a finest image 604C, which is input image 302. From each of the images 604A-604C in image pyramid 604, a sliding window is used to extract image patches.
For the image patches, such as image patches 602, module 104 applies a local affinity learning process to estimate the affinity values among cells. At the coarsest level (i.e., image 604A), the estimation of the affinity information is similar to the far-range case illustrated in FIG. 5(c), in which some details of the affinity information may be missing. However, as module 104 gradually scans the images from the low resolution images to high resolution images, more and more details of affinity information are obtained. In general, most affinity information can be extracted from the low-resolution images, while only a small percentage of detailed affinity information is extracted from the high-resolution images. Hence, in one embodiment, the image patches from the lowest-resolution image (i.e., the coarsest image 604A) are completely scanned by sliding windows, while only a subset of the image patches from the higher-resolution images (i.e., images 604B and 604C) are scanned, to determine the cell-level affinity information.
For the sampling of image patches in the higher-resolution images (i.e., images 604B and 604C), module 104 may adopt a residual-based scheme to compensate for the missing details caused by the down-sampling process. More particularly, module 104 maps individual low-resolution pixels and high-resolution pixels into grid cells to form two sets of cells. The difference between these two sets of cells indicates the missing information after the down sampling process. Based on residual cells, module 104 identifies the corresponding pixels and places sampling patches around these pixels. More particular, for the pixels which are mapped into the residual cells, a set of r×r windows centered at each of the pixels are placed on the high-resolution images to obtain high-resolution sampling patches. In addition, a set of sliding windows are placed on the low-resolution image to obtain low-resolution sampling patches. Cell-level affinity information is then computed from the sampling patches.
Based on the cell-level affinity information, module 104 generates a cell-level graph 606 as shown in FIG. 6. To construct cell-level graph 606, it is assumed that Ω represents the set of cells in the cell-level graph, which contains P cells in total. The alpha matte values of these P cells are represented by a P×1 vector α=[α1, α2, . . . , αP]T, where αk denotes the alpha value of the kth cell.
In addition, it is assumed that the alpha matte values of the pixels within a local image patch may be expressed as an affine transformation of the corresponding image features inside the image patch. The coefficients of the affine transformation are assumed to be constant for one image patch, but may be different across different patches. Since in the pixel-to-cell mapping, pixels mapped to the same cell typically share similar color appearance and spatial location, so that these pixels share similar alpha matte values. Hence, within a local image patch, it is assumed that the alpha matte values of the referred cells are expressed as an affine transformation of the corresponding image features. For an image patch ωq of size r×r in the input image and centered at a pixel q, module 104 inspects the image pixels of the patch to determine the set of mapped cells Ωq, which is a subset of Ω. Here, Nq represents the number of cells in Ωq. Since some pixels in the patch ωq may be mapped to the same cell, Nq has a value between 1 and r2. For a cell i in Ωq, φi=[rik, gik, bik]T represents its color feature, which is computed by, for example, averaging the RGB color values of all the related pixels of that cell. Within the local image patch, the alpha value of the cell i is estimated by an affine transformation of the feature vector φi. That is, the alpha value of the cell i is calculated by:




  
    
      
        
          
            α
            i
          
          =
          
            
              [
              
                
                  
                    
                      φ
                      i
                      T
                    
                  
                  
                    1
                  
                
              
              ]
            
            ⁡
            
              [
              
                
                  
                    β
                  
                
                
                  
                    
                      β
                      0
                    
                  
                
              
              ]
            
          
        
        ,
      
    
    
      
        (
        9
        )
      
    
  




where β=[βr, βg, βb]T and β0 is a scalar. Since it is assumed that the affine transformation coefficients {β, β0} are locally constant, module 104 may further determine an affine model for the alpha matte values of all the cells in Ωq. Here, for the kth cell in Ωq, πkq represents the corresponding index of this cell in Ω. Accordingly, an Nq×1 vector





  
    α
    q
  
  ≡
  
    
      [
      
        
          α
          
            π
            1
            q
          
        
        ,
        
          α
          
            π
            2
            q
          
        
        ,
        ...
        ⁢
        
          
        
        ,
        
          α
          
            π
            
              N
              q
            
            q
          
        
      
      ]
    
    T
  




represents the vector of alpha matte values of the Nq cells in Ω, and Φq=[{tilde over (φ)}1T, . . . , {tilde over (φ)}NqT]T represents a matrix stacked by {tilde over (φ)}i=[φiT 1]. Based on the above notations, the alpha matte prediction for all the cells within image patch ωq can be expressed as:





  
    
      
        
          α
          q
        
        =
        
          
            
              Φ
              q
            
            ⁡
            
              [
              
                
                  
                    β
                  
                
                
                  
                    
                      β
                      0
                    
                  
                
              
              ]
            
          
          .
        
      
    
    
      
        (
        10
        )
      
    
  




Equation (10) relates the alpha matte values of all the cells in Q, with the corresponding image features. If it is assumed that both αq and Φq, are given, then the optimal β and β0 can be derived by minimizing the following quadratic cost function E(β, β0):





  
    
      
        
          
            E
            ⁡
            
              (
              
                β
                ,
                
                  β
                  0
                
              
              )
            
          
          =
          
            
              
                
                
                  
                    α
                    q
                  
                  -
                  
                    
                      Φ
                      q
                    
                    ⁡
                    
                      [
                      
                        
                          
                            β
                          
                        
                        
                          
                            
                              β
                              0
                            
                          
                        
                      
                      ]
                    
                  
                
                
              
              2
            
            +
            
              
                c
                β
              
              ⁢
              
                β
                T
              
              ⁢
              β
            
          
        
        ,
      
    
    
      
        (
        11
        )
      
    
  




where cβ is a parameter for regularization. For the cost function E(β, β0) in (11), the optimal solutions of β and β0 are given by:





  
    
      
        
          [
          
            
              
                β
              
            
            
              
                
                  β
                  0
                
              
            
          
          ]
        
        =
        
          
            
              (
              
                
                  
                    Φ
                    q
                    T
                  
                  ⁢
                  
                    Φ
                    q
                  
                
                +
                
                  
                    c
                    β
                  
                  ⁢
                  
                    D
                    β
                  
                
              
              )
            
            
              -
              1
            
          
          ⁢
          
            Φ
            q
            T
          
          ⁢
          
            
              α
              q
            
            .
          
        
      
    
    
      
        (
        12
        )
      
    
  




In equation (12),




  
    D
    β
  
  =
  
    [
    
      
        
          
            I
            3
          
        
        
          0
        
      
      
        
          0
        
        
          0
        
      
    
    ]
  




is a 4×4 matrix, in which I3 is a 3×3 identity matrix. By substituting equation (12) into equation (10), a local constraint over αq can be formulated as

αq=WqTαq,  (13)

where wq=Φq(ΦqTΦq+cβDβ)−1ΦqT. In equation (13), Wq is an Nq×Nq transformation matrix. In equation (13), each entry of αq on the left side is expressed as a linear combination of the entries of αq on the right side. This means that, the alpha matte value of each cell in Ωq, may be expressed as a linear combination of the alpha values of the cells in Ωq. This local constraint over αq is further formulated as a squared error cost function Jq with respect to αq:





  
    
      
        
          
            
              
                
                  J
                  q
                
                ⁡
                
                  (
                  
                    α
                    q
                  
                  )
                
              
              =
              
              ⁢
              
                
                  
                  
                    
                      α
                      q
                    
                    -
                    
                      
                        W
                        q
                        T
                      
                      ⁢
                      
                        α
                        q
                      
                    
                  
                  
                
                2
              
            
          
        
        
          
            
              =
              
              ⁢
              
                
                  
                    α
                    q
                    T
                  
                  ⁡
                  
                    (
                    
                      
                        I
                        q
                      
                      -
                      
                        W
                        q
                      
                    
                    )
                  
                
                ⁢
                
                  
                    (
                    
                      
                        I
                        q
                      
                      -
                      
                        W
                        q
                      
                    
                    )
                  
                  T
                
                ⁢
                
                  α
                  q
                
              
            
          
        
        
          
            
              =
              
              ⁢
              
                
                  α
                  q
                  T
                
                ⁢
                
                  L
                  q
                
                ⁢
                
                  
                    α
                    q
                  
                  .
                
              
            
          
        
      
    
    
      
        (
        14
        )
      
    
  




In equation (14), Iq is the Nq×Nq, identity matrix. The local Laplacian matrix for the cells in Ωq is an Nq×Nq matrix defined as:

Lq=(Iq−Wq)(Iq−Wq)T.  (15)

It is assumed that a graph Γq is defined, in which the vertices represent the cells in Ωq and the edge between a pair of vertices represents the affinity relationship between the corresponding cell pair. For Γq its corresponding graph Laplacian matrix is defined as:

Lq=Dq−Aq,  (16)

where Dq is the degree matrix and Aq is the affinity matrix. The entry Aq(i,j) represents the affinity value between the cells i and j, while the degree matrix Dq is a diagonal matrix with its diagonal terms being defined as:





  
    
      
        
          
            D
            q
          
          ⁡
          
            (
            
              i
              ,
              i
            
            )
          
        
        =
        
          
            ∑
            
              j
              =
              1
            
            
              N
              g
            
          
          ⁢
          
            
              
                A
                q
              
              ⁡
              
                (
                
                  i
                  ,
                  j
                
                )
              
            
            .
          
        
      
    
    
      
        (
        17
        )
      
    
  




According to an embodiment, the affinity matrix for the cell-level graph is not explicitly defined. Instead, the affinity information is derived based on the local learning scheme expressed in equation (14). Furthermore, the cost function Jq in equation (14) can also be interpreted as




  
    
      
        
          
            
              
                
                  J
                  q
                
                ⁡
                
                  (
                  
                    α
                    
                      q
                      ⁢
                      
                        
                      
                    
                  
                  )
                
              
              =
              
              ⁢
              
                
                  α
                  q
                  T
                
                ⁢
                
                  L
                  q
                
                ⁢
                
                  α
                  q
                
              
            
          
        
        
          
            
              
                =
                
                ⁢
                
                  
                    ∑
                    
                      i
                      =
                      1
                    
                    
                      N
                      q
                    
                  
                  ⁢
                  
                    
                      ∑
                      
                        j
                        =
                        1
                      
                      
                        N
                        q
                      
                    
                    ⁢
                    
                      
                        1
                        2
                      
                      ⁢
                      
                        
                          A
                          q
                        
                        ⁡
                        
                          (
                          
                            i
                            ,
                            j
                          
                          )
                        
                      
                      ⁢
                      
                        
                          
                          
                            
                              α
                              i
                            
                            -
                            
                              α
                              j
                            
                          
                          
                        
                        2
                      
                    
                  
                
              
              ,
            
          
        
      
    
    
      
        (
        18
        )
      
    
  




where αi and αj represent the ith and jth elements of the vector αq, respectively.

After determining the local Laplacian matrix based on the cost function Jq defined in equation (14) within a single image patch ωq, module 104 further determines a global cost function by integrating the local cost functions over a whole patch set Spatch. Here, the cost function Jq in equation (14) may be rewritten as

Jq(α)=αTL′qα.  (19)

In equation (19), α≡[α1, α2, . . . , αP]T, and L′q denotes a P×P local Laplacian matrix, whose entries for the pairs of cells in Ωq are equal to the corresponding ones in Lq, while the remaining entries are set to zero. Based on equation (19), a global cost function J is defined as a weighted sum of Jq(α) based on a weighting function w(lq). That is:




  
    
      
        
          J
          ⁡
          
            (
            α
            )
          
        
        =
        
          
            ∑
            
              q
              ∈
              Ω
            
            
              
            
          
          ⁢
          
            
              w
              ⁡
              
                (
                
                  l
                  q
                
                )
              
            
            ⁢
            
              
                (
                
                  
                    α
                    T
                  
                  ⁢
                  
                    L
                    q
                    ′
                  
                  ⁢
                  α
                
                )
              
              .
            
          
        
      
    
    
      
        (
        20
        )
      
    
  




The weighting function w(lq) in equation (20) reflects the importance of each patch according to the corresponding image level in the pyramid. Here, lq denotes the level index. In image pyramid 604, the number of pixels in the jth level is (ds2)j−1 times smaller than that of the original image after being scaled down (j−1) times in both x and y directions with the down-sampling rate ds. By assuming that each pixel in the jth-level image is (ds2)j−1 times more important than that of the original image pixel, the weighting function w(lq) is defined as

w(lq)=(ds2)lq−1.  (21)

Moreover, equation (20) may be rewritten in a more compact form as:




  
    
      
        
          
            J
            ⁡
            
              (
              α
              )
            
          
          =
          
            
              α
              T
            
            ⁢
            L
            ⁢
            
              
            
            ⁢
            α
          
        
        ,
        
          

        
        ⁢
        where
      
    
    
      
        (
        22
        )
      
    
  
  
    
      
        L
        =
        
          
            ∑
            
              q
              ∈
              Ω
            
          
          ⁢
          
            
              w
              ⁡
              
                (
                
                  l
                  q
                
                )
              
            
            ⁢
            
              
                L
                q
                ′
              
              .
            
          
        
      
    
    
      
        (
        23
        )
      
    
  




L in equation (22) is called the cell-level matting Laplacian (CML) matrix for the cell-level graph. Since the CML generated according to equation (23) is an unnormalized Laplacian matrix, it is normalized before spectral clustering in order to avoid unbalanced clustering. In one embodiment, module 104 may apply a symmetric normalization to the CML, which modifies the affinity value between each pair of cells based on a degree matrix of the cells. The normalized CML L is defined to be:

L=D−1/2LD−1/2.  (24)

In equation (24), the diagonal matrix D represents the P×P degree matrix of the CML.

Component-Level Graph

FIG. 7 illustrates a cell-to-component mapping, according to an embodiment. After module 104 obtains cell-level graph 606 as shown in FIG. 6, cell-level graph 606 is output to module 106, which decomposes it into a set of matting components 702, as shown in FIG. 7, and forms a component-level graph for the estimation of foreground mattes. During the construction of the component-level graph, some prior information about the foreground model may be included.
To decompose cell-level graph 606 into matting components 702 as shown in FIG. 7, module 106 performs spectral clustering to generate hard-decision matting segments and then applies an optimization process to transform or refine the hard-decision matting segments into soft-decision matting components. FIG. 8 illustrates exemplary embodiments of an input image 802, a matting segment 804, and a matting component 806 generated by module 106.
For the spectral clustering, module 106 transforms the cell-level data to a higher-dimensional space, in which the cell-level data points with high affinity tend to share similar coordinates, and then performs clustering in the higher-dimensional space. More particularly, module 106 first generates a P×S matrix E based on S normalized eigenvectors, eI, . . . , eS, corresponding to the S smallest eigenvalues of the P×P cell-level Laplacian matrix L discussed above. In the matrix E, the ith row vector represents the coordinates of the ith cell in Ω in a space spanned by the S eigenvectors. By performing k-means clustering over the row vectors of E, module 106 clusters the P cells into K different clusters. The K clusters of cells are treated as the initial matting segments, such as matting segment 804 shown in FIG. 8. In one embodiment, module 106 uses K binary vectors ck of size P×1 to represent the hard-decision clustering result, where 1≦k≦K. If the kth cluster contains the ith cell of Ω, module 106 sets the ith element of ck to 1; otherwise, the ith element of ck is set to 0.
To transform the hard-decision matting segments into soft-decision matting components, such as matting component 806 shown in FIG. 8, module 106 applies a global optimization process based on the cost function in equation (22). Here, module 106 organizes each matting component as an assembly of cells and represents the alpha matte information of a component k in terms of a P×1 alpha matte αk≡[α1k, α2k, . . . , αPk]T. The ith element of αk indicates a soft membership that the ith cell belongs to the kth component. Based on the assumption that the soft-decision matting components do not deviate too much from the hard-decision matting segments, the alpha matte vector αk corresponding to the kth matting component is obtained by minimizing the following equation:

J(αk)=(αk)TL(αk)+λc(αk−ck)T(αk−ck),  (25)

where λc is a constant to control the trade-off between the matting Laplacian cost and the deviation from the matting segments. Based on equation (25), module 106 determines the optimal αk by solving the following sparse system of linear equations:

(L+λcIc)αk=λcck,  (26)

where Ic denotes the P×P identity matrix. It can be seen from FIG. 8 that more detailed matting values are obtained in matting component 806 than in initial matting segment 804.

After the matting components are determined, module 106 generates a component-level graph. Module 106 generates the component-level graph by condensing the cell-level graph or according to a divergence-based process. In one embodiment, module 106 generates the component-level graph by further condensing the cell-level matting Laplacian matrix L into a component-level matting Laplacian Lcondensed. Here, it is assumed that T=[α1, . . . , αK] represents a P×K matrix formed by the alpha matte vectors of the K matting components, which is used to calculate the component-level matting Laplacian Lcondensed as follows:

Lcondensed=TTLT.  (27)

Since the cell-level matting Laplacian L is constructed based on the multi-resolution local affinity learning process described above, the lack of knowledge between spatially isolated components may become a barrier to handle more complicated scenes. To better model the spatial relationship between distant components, module 106 can use a divergence-based graph, according to another embodiment. Module 106 constructs the divergence-based graph by explicitly estimating the affinity value between every component pair, as described hereinafter.
For each pairing of components, module 106 measures the Kullback-Leibler (KL) divergence between the color distributions of the two components. For the matting component k, module 106 uses a Z×1 vector hk=[h1k, . . . , hZk]T to represent its color distribution, where Z is the number of color bins. Here, hik represents the probability value in the ith bin. Module 106 then group cells with similar color values into a color bin. For the ith color bin of the kth matting component, module 106 uses pi to represent the set of cells belonging to this bin. Accordingly, hik is determined as follows:




  
    
      
        
          
            h
            i
            k
          
          =
          
            
              1
              
                N
                k
              
            
            ⁢
            
              
                ∑
                
                  j
                  ∈
                  
                    ρ
                    i
                  
                
              
              ⁢
              
                
                  α
                  j
                  k
                
                ⁢
                
                  N
                  j
                
              
            
          
        
        ,
      
    
    
      
        (
        28
        )
      
    
  




where





  
    N
    k
  
  =
  
    
      ∑
      
        j
        =
        1
      
      P
    
    ⁢
    
      
        α
        j
        k
      
      ⁢
      
        N
        j
      
    
  




is the normalization term. In equation (28), Nj is the number of pixels in cell j, and αjk is the alpha value of the cell j for the kth matting component. Based on the above definitions, the KL divergence between the two matting components m and n is defined as:





  
    
      
        
          
            
              v
              KL
            
            ⁡
            
              (
              
                m
                ,
                n
              
              )
            
          
          =
          
            
              
                
                  D
                  KL
                
                ⁡
                
                  (
                  
                    
                      h
                      m
                    
                    ⁢
                    
                      
                      
                    
                    ⁢
                    
                      h
                      n
                    
                  
                  )
                
              
              +
              
                
                  D
                  KL
                
                ⁡
                
                  (
                  
                    
                      h
                      n
                    
                    ⁢
                    
                      
                      
                    
                    ⁢
                    
                      h
                      m
                    
                  
                  )
                
              
            
            2
          
        
        ,
      
    
    
      
        (
        29
        )
      
    
  




where DKL is a diagonal degree matrix and defined as:





  
    
      D
      KL
    
    ⁡
    
      (
      
        p
        ⁢
        
          
          
        
        ⁢
        q
      
      )
    
  
  =
  
    
      ∑
      i
    
    ⁢
    
      
        p
        ⁡
        
          (
          i
          )
        
      
      ⁢
      
        
          log
          ⁡
          
            (
            
              
                p
                ⁡
                
                  (
                  i
                  )
                
              
              
                q
                ⁡
                
                  (
                  i
                  )
                
              
            
            )
          
        
        .
      
    
  




For any pair of components, a high divergence value corresponds to a low affinity value. Hence, module 106 uses a sigmoid function σ(x)=1/(1+exp(−x)) to define an affinity AKL(m,n) between components m and n as:

AKL(m,n)=σ(vKL−vKL(m,n))  (30)

In equation (30), vKL represents the mean of the KL divergence values over all component pairs. After having obtained the K×K divergence-based affinity matrix AKL, the diagonal degree matrix DKL is computed as:




  
    
      
        
          
            D
            KL
          
          ⁡
          
            (
            
              i
              ,
              i
            
            )
          
        
        =
        
          
            ∑
            
              j
              =
              1
            
            K
          
          ⁢
          
            
              
                A
                KL
              
              ⁡
              
                (
                
                  i
                  ,
                  j
                
                )
              
            
            .
          
        
      
    
    
      
        (
        31
        )
      
    
  




Finally, the divergence-based Laplacian matrix LKL is calculated as:

LKL=DKL−AKL.  (32)

Module 106 then combines the divergence-based Laplacian LKL with the condensed matting Laplacian Lcondensed to calculate the component-level graph Laplacian Lcomp:

Lcomp=Lcondensed+λKLLKL.  (33)

In equation (33), λKL is a parameter to balance the contribution between Lcondensed and LKL. Module 106 calculates λKL based on the ratio between the sum of the condensed matting affinity degrees and the sum of the KL affinity degrees as follows:




  
    
      
        
          λ
          KL
        
        =
        
          
            ∑
            
              i
              =
              1
            
            K
          
          ⁢
          
            
              
                L
                condensed
              
              ⁡
              
                (
                
                  i
                  ,
                  i
                
                )
              
            
            /
            
              
                ∑
                
                  i
                  =
                  1
                
                K
              
              ⁢
              
                
                  
                    L
                    KL
                  
                  ⁡
                  
                    (
                    
                      i
                      ,
                      i
                    
                    )
                  
                
                .
              
            
          
        
      
    
    
      
        (
        34
        )
      
    
  




FIG. 9 illustrates an exemplary component-level graph 902 generated by module 106 based on matting components 702 of FIG. 7.

Component-to-Layer Mapping

According to an embodiment, after module 106 calculates the component-level matting Laplacian Lcomp as discussed above, layer processing module 108 receives the data and applies a component-to-layer mapping procedure based on component-level spectral clustering. FIG. 10 illustrates an exemplary embodiment of the component-to-layer mapping procedure, in which matting components shown in FIG. 7 are mapped to a plurality of layers 1002 based on component level graph 902.
Similar to the cell-to-component mapping described above, the component-to layer mapping may also be performed based on spectral clustering. Here, module 108 generates a component-level matrix Ecomp based on normalized eigenvectors, ecomp1, . . . , ecompK of the K×K component-level Laplacian matrix Lcomp. By performing k-means clustering over the row vectors of Ecomp, module 108 clusters the K matting components into Q clusters, where Q is an integer ranging from 2 to K and may be determined according to user input. Module 108 then uses a plurality of K×1 binary vectors dq, where 1≦q≦Q, to represent the clustering result. If the qth cluster contains the ith matting component, module 108 sets the ith element of dq to 1; otherwise, the ith element of dq is set to 0. Based on dq, module 108 represents the alpha matte information of the qth matting layer using a P×1 vector αlayerq, which is defined as:

αlayerq=[α1 . . . αK]dq.  (35)

By using the cell-to-component mapping and the component-to-layer mapping, system 100 performs spectral clustering twice on the image data, instead of directly clustering cells into matting layers. In particular, system 100 first clusters cells into components and then clusters components into layers. Based on the cell-level graph, such as graph 606 shown in FIG. 6, system 100 computes the affinity values of the graph vertices locally based on the multi-resolution local affinity learning scheme, to explore the affinity information in short ranges. On the other hand, based on the component-level graph, such as graph 902 of FIG. 9, system 100 calculates the affinity value between each pair of components and generates a fully connected graph including both near-range and far-range affinity information. Based on this fully connected graph, system 100 explores the affinity information on a more global scale as compared to the cell-level analysis alone. FIG. 11A illustrates matting results based on a direct mapping from cells to layers, according to an embodiment. In FIG. 11A, the cells are directly clustered into two, three, four, and five layers. As a comparison, FIG. 11B illustrates matting results based on a multi-resolution mapping from cells to components and then to layers, according to an embodiment. In FIG. 11B, the two-stage clustering is applied to the cells by first decomposing the cells into components and then clustering the components into layers. By decomposing an image into a larger number of components first, followed by the component-to-layer mapping, system 100 obtains much more reasonable results.
According to another embodiment, system 100 applies a cell-to-pixel mapping to convert the cell-level information αk back to the pixel domain. For any pixel i, if j denotes the corresponding cell, then μ(j) denotes the set of cells within a neighborhood of j. The pixel-level data oipixel of the pixel i is interpolated by using the cell-level data values okcell of the cells in μ(j) based on the following formula:




  
    
      
        
          
            o
            i
            pixel
          
          =
          
            
              ∑
              
                k
                ∈
                
                  μ
                  ⁡
                  
                    (
                    i
                    )
                  
                
              
            
            ⁢
            
              
                o
                k
                cell
              
              ·
              
                p
                
                  k
                  ❘
                  i
                
              
            
          
        
        ,
        
          

        
        ⁢
        where
      
    
    
      
        (
        36
        )
      
    
  
  
    
      
        
          p
          
            k
            ❘
            i
          
        
        =
        
          
            
              {
              
                
                  ∑
                  
                    k
                    ∈
                    
                      μ
                      ⁡
                      
                        (
                        j
                        )
                      
                    
                  
                
                ⁢
                
                  exp
                  ⁡
                  
                    (
                    
                      -
                      
                        
                          
                            
                            
                              
                                f
                                i
                              
                              -
                              
                                f
                                k
                              
                            
                            
                          
                          2
                        
                        
                          σ
                          f
                        
                      
                    
                    )
                  
                
              
              }
            
            
              -
              1
            
          
          ⁢
          
            
              exp
              ⁡
              
                (
                
                  -
                  
                    
                      
                        
                        
                          
                            f
                            i
                          
                          -
                          
                            f
                            k
                          
                        
                        
                      
                      2
                    
                    
                      σ
                      f
                    
                  
                
                )
              
            
            .
          
        
      
    
    
      
        (
        37
        )
      
    
  




In equation (37), pk|i is a conditional probability and fi denotes the image feature of the pixel i in the five-dimensional feature space W defined by the deformed spatial coordinates ({tilde over (x)}, {tilde over (y)})) and the RGB color values (IR, IG, IB), as described above. On the other hand, fk denotes the average of the feature vectors related to the cell k. The conditional probability in equation (37) models how likely the pixel i belongs to the cell k, based on the distance between fi and fk in the feature space. For example, a shorter distance indicates a higher probability.
Foreground Estimation
After module 108 generates the matting layers, module 110 receives the matting layers and applies a probabilistic estimation process to the matting layers to estimate foreground information. Here, module 110 processes each matting layer in terms of associated matting components and applies a probabilistic scheme to estimate, for each matting component, the probability of being a portion of the foreground objects.
More particularly, module 110 generates a probability distribution model p(b)=p(b1, . . . , bK), where bk ε{0,1} for 1≦k≦K. For the matting component k, module 110 sets bk=1 when this component is identified as a foreground component; otherwise, bk=0. Based on the above definitions, each vector b represents a foreground matte hypothesis and corresponds to an assembly of matting components. Once module 110 derives the probability distribution model p(b) for all possible b's, module 110 selects a subset of b's that is more likely to represent a foreground matte.
According to one embodiment, the distribution model p(b) is based on a consistency assumption that a pair of components with relatively high affinity tends to share the same foreground index. Thus, these two components tend to be either both foreground or both background. Using input image 302 in FIG. 3 as an example, it is assumed that the two flowers on the front are divided into two matting components. Once one of them is classified as a foreground component, while the other has a relatively high probability to also be a foreground component.
Based on this consistency assumption, module 110 evaluates a given vector b based on the component-level Laplacian matrix Lcomp to determine a measure of “inconsistency” defined as follows:

dfb(b)=bTLcompb.  (38)

Based on the definition in equation (38), a vector b with a low value of inconsistency dfb(b) indicates that the corresponding assembly of matting components has a high probability to be a part of the foreground matte. However, this does not imply that a proper foreground vector can thus be found simply based on this measure alone. One example is that a b vector whose entries are all ones (or all zeros) corresponds to zero inconsistency, may not be desired result.
According to another embodiment, in order to avoid the above problem, module 110 further applies a balancing weight based on the assumption that a ratio between the foreground area and the background area should not be overly unbalanced. A balancing weight η(b) is defined as:




  
    
      
        
          
            η
            ⁡
            
              (
              b
              )
            
          
          =
          
            
              1
              
                N
                α
              
            
            +
            
              1
              
                N
                
                  α
                  _
                
              
            
          
        
        ,
      
    
    
      
        (
        39
        )
      
    
  




where




  
    
      N
      α
    
    =
    
      
        ∑
        
          k
          =
          1
        
        K
      
      ⁢
      
        
          N
          k
        
        ⁢
        
          b
          k
        
      
    
  




  and




  
    
      N
      
        α
        _
      
    
    =
    
      
        ∑
        
          k
          =
          1
        
        K
      
      ⁢
      
        
          N
          k
        
        ⁡
        
          (
          
            1
            -
            
              b
              k
            
          
          )
        
      
    
  



denote the sum of matting values in the foreground area and the background area, respectively. The term Nk is defined above in equation (28). Under an unbalanced circumstance, one of Nα and Nα is relatively small and thus the weight η(b) becomes relatively large. By including this balancing weight η(b) into the inconsistency measure, module 110 calculates the inconsistency dfb(b) as follows:

dfb(b)=η(b)(bTLcompb).  (40)

With this weighted inconsistency measure, the probability distribution model is defined as




  
    
      
        
          
            
              
                p
                f
              
              ⁡
              
                (
                b
                )
              
            
            ∝
            
              1
              
                1
                +
                
                  exp
                  ⁡
                  
                    (
                    
                      c
                      ⁡
                      
                        (
                        
                          
                            
                              d
                              fb
                            
                            ⁡
                            
                              (
                              b
                              )
                            
                          
                          -
                          
                            
                              d
                              fb
                            
                            _
                          
                        
                        )
                      
                    
                    )
                  
                
              
            
          
          ,
          
            

          
          ⁢
          where
        
        ⁢
        
          

        
        ⁢
        
          
            
              d
              fb
            
            _
          
          =
          
                        ⁢
            
              
                
                  d
                  fb
                
                ⁡
                
                  (
                  b
                  )
                
              
              .
            
          
        
      
    
    
      
        (
        41
        )
      
    
  




In equation (41), f is a set of foreground vectors, which have the smallest values of inconsistency dfb(b) over all feasible b's. In addition, dfb is the mean of the inconsistency measures of the vectors in f, and the parameter c is a constant, which is empirically set to 0.02 or other appropriate values.
According to an embodiment, system 100 generates a relatively small number (typically about 10 to 20) of matting components for an input image. As a result, module 110 may generate all feasible vectors b's and check the corresponding dfb(b) for each vector b. According to another embodiment, module 110 may improve computational efficiency by ignoring b's that have relatively large values of dfb(b) and only focus on b's that have relatively small values of dfb(b).
Based on the formulation in equations (40) and (41), module 110 determines that, if a combination of matting components is consistent with respect to the component-level Laplacian matrix Lcomp and is balanced with respect to the remaining components, the corresponding pf(b) have a relatively large value. However, for any b and its complement (1-b), the values of pf(b) and pf(1-b) are actually equal. Thus, foreground and background mattes cannot be distinguished from each other simply based on the inconsistency measure in equation (40). According to a further embodiment, module 110 further evaluates a convexity of a matte and a convexity of its complement. Module 110 then identifies the foreground matte based on the assumption that a foreground matte usually tends to be convex. Here, the convexity is measured based on a ratio of the areas between a matte and its corresponding convex hull. By comparing the convexity between any pair of b and 1-b, module 110 eliminates the matting components with relatively low convexity.
FIG. 12 illustrates exemplary embodiments of matting layers 1202-1220 and a possibility map 1222 for a foreground region of input image 302. Matting components 1202-1218 for input image 302 correspond to ten b's with the largest values of pf(b) (i.e., rank #1 to rank #10). It can be seen that these mattes typically have a large overlap with the foreground area, i.e., the flower regions. Hence, if ξ represents the set of leading foreground vectors with the largest values of pf(b), module 110 estimates the foreground vector bFG as the expectation of the b vectors in ξ as follows:




  
    
      
        
          b
          FG
        
        =
        
          
            
              
                ∑
                
                  b
                  ∈
                  ξ
                
              
              ⁢
              
                
                  
                    p
                    f
                  
                  ⁡
                  
                    (
                    b
                    )
                  
                
                ⁢
                b
              
            
            
              
                ∑
                
                  b
                  ∈
                  ξ
                
              
              ⁢
              
                
                  p
                  f
                
                ⁡
                
                  (
                  b
                  )
                
              
            
          
          .
        
      
    
    
      
        (
        42
        )
      
    
  




Based on equation (42), module 110 calculates the foreground possibility map for the foreground matte as a weighted sum of the component-level alpha matte values as follows:

αFG=[α1 . . . αK]·bFG  (43)

As shown FIG. 12, an exemplary possibility map 1222 reflects how likely an image pixel belongs to the foreground region of input image 302.

According to another embodiment, for the multiple layers generated by module 108, such as those shown in FIG. 11B, module 110 calculates a foreground factor for each matting layer αlayerq as follows:




  
    
      
        
          
            
              F
              layer
            
            ⁡
            
              (
              
                α
                layer
                q
              
              )
            
          
          =
          
            
              
                α
                FG
                T
              
              ⁢
              
                α
                layer
                
                  q
                  ⁢
                  
                    
                  
                
              
            
            
              
                1
                P
                T
              
              ⁢
              
                α
                layer
                q
              
            
          
        
        ,
      
    
    
      
        (
        44
        )
      
    
  




where 1p denotes a P×1 all-one vector. FIG. 11B shows the value of the foreground factor for each matting layer. In general, a matting layer with a relatively large foreground factor is more likely to be a portion of the foreground region.

FIG. 13 illustrates a flow chart of a process 1300 for image matting and foreground estimation based on hierarchical graphs, according to an embodiment. Process 1300 may be implemented on system 100 according to the techniques disclosed above. In particular, according to process 1300, at step 1302, an input image is received. The input image includes a plurality of image elements, such as pixels. Each pixel includes color values such as those defined according to the known color spaces. At step 1304, a plurality of matting cells is generated based on the input image. Each matting cell includes a group of image elements. The matting cells may be generated by first applying a contraction process to the input image and then mapping the contracted image elements to the matting cells based on affinity relationships among the image elements.
At step 1306, affinity values are calculated for the plurality of matting cells based on the input image. An affinity value indicates the similarity between each pair of matting cells. The affinity values of the cells may be calculated based on the multi-resolution local affinity learning scheme described above with reference to FIGS. 5 and 6.
At step 1308, a first graph, such as the cell-level graph disclosed above, is formed based on the plurality of matting cells and the affinity values. The first graph includes a plurality of first nodes or vertices representing the matting cells and a plurality of first edges associated with the affinity values of the matting cells. At step 1310, a plurality of matting components are generated for the input image based on the first graph. The matting components may be generated by decomposing the first graph based on the affinity values of the matting cells. One or more of the matting components are then identified as belonging to a foreground region of the input image.
FIG. 14 illustrates a flow chart of a process 1400 for image matting and foreground estimation based on hierarchical graphs, according to another embodiment. Process 1400 may be implemented on system 100 according to the techniques disclosed above. In particular, according to process 1400, an input image is received at step 1402. The input image includes a plurality of image elements, such as pixels.
At step 1404, a first graph, such as the pixel-level graph disclosed above, is formed based on the input image. The first graph includes a plurality of first nodes or vertices representing the image elements and a plurality of first edges representing affinity relationships among the image elements. At step 1406, a second graph, such as the cell-level graph disclosed above, is formed by grouping the image elements into a plurality of cells. The second graph includes a plurality of second nodes or vertices representing the cells and a plurality of second edges representing affinity relationships among the cells.
At step 1408, a third graph, such as the component-level graph disclosed above, is formed by decomposing the second graph into a plurality of matting components. The third graph includes a plurality of third nodes or vertices representing the matting components and a plurality of edges representing affinity relationships among the matting components. At step 1410, probability values are determined, indicating the probabilities of the matting components as belonging to a foreground region of the input image based on the third graph.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

## Claims

1. A method for image matting based on a hierarchical graph model, comprising:
receiving an input image including a plurality of image elements;
generating a plurality of matting cells, the generating including converging a subset of image elements of the plurality of image elements toward each other, wherein each cell includes a group of image elements;
calculating affinity values for the plurality of matting cells based on the input image; and
forming a graph based on the plurality of matting cells and the affinity values, the graph including a plurality of nodes representing the matting cells and a plurality of edges associated with the affinity values of the matting cells;
generating a plurality of matting components for the input image by decomposing the graph; and
identifying at least one of the matting components belongs to a foreground region of the input image.

2. The method of claim 1, further comprising determining probabilities of the matting components being the foreground region of the input image.

3. The method of claim 2, wherein the graph is a first graph, and the method further comprises:
forming a second graph based on the matting components, the second graph including a plurality of nodes representing the matting components and a plurality of edges representing affinity relationships among the matting components; and
calculating a Laplacian matrix based on the second graph; and
determining the probabilities based on the Laplacian matrix.

4. The method of claim 3, further comprising:
defining an inconsistency measure based on the Laplacian matrix; and
determining the probabilities based on the inconsistency measure.

5. The method of claim 1, wherein the graph is a first graph, and the converging further comprises:
forming a second graph based on the input image, the second graph including a plurality of nodes representing the plurality of image elements and a plurality of edges representing affinity information of the plurality of image elements; and
generating a contracted image from the input image based on the second graph.

6. The method of claim 5, further comprising:
defining normalized coordinates for the plurality of image elements; and
calculating contracted coordinates for the plurality of image elements based on the normalized coordinates and the affinity information of the image elements.

7. The method of claim 6, further comprising generating the plurality of matting cells based in part on the contracted coordinates of the plurality of image elements.

8. The method of claim 7, further comprising:
defining a coordinate system based on the contracted coordinates and color values of the plurality of image elements; and
generating the plurality of matting cells by mapping the plurality of image elements to the matting cells based on the coordinate system.

9. The method of claim 1, wherein the calculating of the affinity values of the matting cells further comprises:
generating a plurality of down-sampled images from the input image;
extracting a plurality of image patches from the down-sampled images and the input image; and
determining the affinity values of the matting cells based on the image patches.

10. The method of claim 9, further comprising:
determining a feature vector for each cell based on image elements within the cell; and
calculating the affinity value of the cells by applying an affine transformation to the feature vector.

11. The method of claim 10, wherein the graph is a first graph, and the method further comprises:
defining a global error function based on the affinity values of the cells;
forming a second graph based on the cells; and
determining a Laplacian matrix for the second graph based on the global error function.

12. The method of claim 11, wherein the defining of the global error function further comprises:
defining an error function for each image patches; and
defining the global error function by calculating a weighted sum of the error functions of the image patches, wherein the global error function includes a weight for each image patch that indicates relative importance of the image patch.

13. The method of claim 11, further comprising normalizing the Laplacian matrix using a degree matrix.

14. The method of claim 13, wherein the generating of the components further comprises:
generating a plurality of segments from the graph by performing spectral clustering on the graph based on the normalized Laplacian matrix; and
generating the matting components from the segments by refining the segments.

15. The method of claim 14, further comprising generating a plurality of layers by grouping the matting components based on affinity relationships between the matting components.

16. A method for image matting based on hierarchical graphs, comprising:
receiving an input image including a plurality of image elements;
forming a first graph based on the input image, the first graph including a plurality of first nodes representing the plurality of image elements and a plurality of first edges representing affinity relationships among the plurality of image elements;
forming a second graph by grouping the plurality of image elements into a plurality of cells, the second graph including a plurality of second nodes representing the cells and a plurality of second edges representing affinity relationships among the cells, wherein the forming of the second graph includes converging a subset of image elements of the plurality of image elements toward each other;
forming a third graph by decomposing the second graph into a plurality of matting components, the third graph including a plurality of third nodes representing the matting components and a plurality of edges representing affinity relationships among the matting components;
determining probabilities of the matting components belonging to a foreground region of the input image based on the third graph; and
identifying at least one of the matting components that belongs to a foreground region of the input image.

17. The method of claim 16, wherein the converging further comprises:
applying a contraction process to the input image; and
mapping the plurality of image elements to the cells based on the contracted input image and the first graph.

18. The method of claim 16, wherein the converging further comprises:
generating an image pyramid by recursively down-sampling the input image;
extracting a plurality of image patches from the image pyramid; and
determining the affinity relationships among the cells based on the image patches.

19. A non-transitory computer-readable medium storing instructions, which, when executed by a processor, cause the processor to perform a method for image matting based on hierarchical graphs, the method comprising:
receiving an input image including a plurality of image elements;
generating a plurality of matting cells, the generating including converging a subset of image elements of the plurality of image elements toward each other, wherein each cell including includes a group of image elements;
calculating affinity values for the plurality of matting cells based on the input image;
forming a graph based on the plurality of matting cells and the affinity values, the graph including a plurality of nodes representing the matting cells and a plurality of edges representing affinity information of the matting cells;
generating a plurality of matting components for the input image by decomposing the graph; and
identifying at least one of the matting components that belongs to a foreground region of the input image.