# Patent

## Title
Intelligent background selection and image segmentation

## Abstract

Certain embodiments of these teachings take inputs of a) an image to be segmented and b) a set of user input markers that identify at least a foreground of said image. From these inputs are determined strong foreground regions Sf, strong background regions Sb and ambiguous regions G. Each ambiguous region Gi is classified as either a weak foreground region Wf or a weak background region Wb by comparing color of each ambiguous region Gi against color of regions adjacent thereto and merging the respective ambiguous region Gi with its adjacent region having a most similar color. The strong foreground regions Sf are also merged with the weak foreground regions Wf. What is output therefrom is a foreground image of the image to be segmented, separate and distinct from any region that is classified as one of the strong background regions or weak background regions.

## Background
TECHNICAL FIELD
The invention relates generally to multimedia applications; image and video editing; image cut-outs; and selective filtering. Specifically, embodiments of the present invention relate to methods for image segmentation to separate foreground from background.
BACKGROUND
Image segmentation is a challenging problem in computer graphics, particularly with respect to digitally separating a desired object (foreground) from a background of the digital image. Such separation is useful during digital editing of still images and video. Fully automatic segmentation has been a very difficult task to effectively apply over a wide variety of images due to the difficulty in segregating a desired object from a background in an image. For this reason, methods for interactive image segmentation have recently received much attention.
Several approaches have been suggested, and some of which are relevant to these teachings are described in the following documents. [1] FAST INTERACTIVE IMAGE SEGMENTATION BY DISCRIMINATIVE CLUSTERING, Proceedings of the 2010 ACM Multimedia Workshop on Mobile Cloud Media Computing, MCMC '10, pages 47-52, 2010, by Dingding Liu, Kari Pulli, Linda G. Shapiro and Yingen Xiong; [2] INTERACTIVE IMAGE SEGMENTATION BY MAXIMAL SIMILARITY BASED REGION MERGING, Pattern Recogn., 43(2): 445-456, February 2010, by Jifeng Ning, Lei Zhang, David Zhang, and Chengke Wu; [3]“GRABCUT”: INTERACTIVE FOREGROUND EXTRACTION USING ITERATED GRAPH CUTS, ACM SIGGRAPH 2004 Papers, SIGGRAPH '04, pages 309-314, 2004, by Carsten Rother, Vladimir Kolmogorov, and Andrew Blake; [4] A MULTILEVEL BANDED GRAPH CUTS METHOD FOR FAST IMAGE SEGMENTATION, Proceedings of the Tenth IEEE international Conference on Computer Vision (ICCV '05), ICCV '05, pages 259-265, 2005, by Hez-ve Lombaert. Yiyong Sun, Leo Grady, and Chenyang Xu; [5] LAZY SNAPPING, ACM SIGGRAPH 2004 Papers, SIGGRAPH '04, pages 303-308, 2004 by Yin Li, Jian Sun, Chi-Keung Tang, and Heung-Yeung Shum; and [6] CONTOUR DETECTION AND HIERARCHICAL IMAGE SEGMENTATION, IEEE Trans. Pattern Anal. Mach. Intell., 33(5)898-916, May 2011, by Pablo Arbelaez, Michael Maire, Chanless Fowlkes, and Jitendra Malik.
These approaches generally require significant user guidance and are particularly inaccurate when an object is close to a boundary of the image. At least references [1-5] require the user to manually mark both a background region and foreground region. The inventors have found that these approaches tend to be less accurate in discriminating foreground from background when the true foreground extends to or very near a border/outer boundary of the overall image being segmented. Therefore there is a need for an image segmentation approach that better distinguishes foreground from background at least in those instances, and preferably one that does so with fewer manual user inputs so as to result in a generally more automated system.
SUMMARY
Embodiments of the present invention are directed to an apparatus such as a host computing device, a method and a computer readable memory that satisfy the need for reducing user guidance for background selection and image segmentation while maintaining accurate results in discriminating foreground from background.
A method having certain features of these teachings comprises:

    
    
        using a set of user input foreground markers identifying a foreground of an image to be segmented, defining Nf foreground regions and Nb background regions, where Nf is an integer greater than zero and Nb is an integer at least zero;
        for each respective border region that defines a border of the image and is not one of the Nf foreground regions, performing a multi-level assessment of the respective border region to determine whether the respective border region is a possible foreground region, where each level of the multi-level assessment compares color similarity, with respect to a threshold that is specific for that level, between the respective border region and any of the Nf foreground regions or of a region that satisfied the threshold of a previous level of the multi-level assessment;
        from the multi-level assessment and the foreground markers, classifying each region of the image to be segmented as one of a strong foreground region, a strong background region or an ambiguous region;
        classifying each of the respective ambiguous regions as a weak foreground region or a weak background region; and
        merging the strong foreground regions with the weak foreground regions and output therefrom, to a tangible memory or to a graphical display, a foreground image of the image to be segmented, separate and distinct from any region classified as one of the strong background regions or weak background regions.
    
    


Another method according to these teachings comprises:

    
    
        from inputs of an image to be segmented and a set of user input markers identifying at least a foreground of said image, determining strong foreground regions Sf, strong background regions Sb and ambiguous regions G;
        classifying each ambiguous region Gi as either a weak foreground region Wf or a weak background region Wb by comparing color of each ambiguous region Gi against color of regions adjacent thereto and merging the respective ambiguous region Gi with its adjacent region having a most similar color; and
        merging the strong foreground regions Sf with the weak foreground regions Wf and outputting therefrom, to a tangible memory or to a graphical display, a foreground image of the image to be segmented, separate and distinct from any region classified as one of the strong background regions or weak background regions.
    
    


A computing device or other such apparatus embodying the teachings herein may comprise at least one digital processor and a computer readable memory storing a computer readable program/computer executable code which when executed by the at least one processor causes the apparatus to perform either or both of the methods essentially as summarized above. Other embodiments implementing these teachings may comprise the computer readable memory on which is stored such a program or executable code, which may then be distributed to end users who may then install the program from that memory onto their own computer's native memory or have their computer run the program directly from the non-native memory itself.



BRIEF DESCRIPTION OF THE DRAWINGS
These and other features, aspects, and advantages of the present invention will become better understood with regard to the following description, appended claims, and accompanying drawings, where:
FIG. 1 shows a high level flow chart according to an example embodiment of the invention.
FIGS. 2A and 2B show an image illustrating a user-marked foreground region and also showing border regions that are by default are at first considered background regions according to various embodiments of the invention.
FIGS. 3A and 3B illustrate various types of images to be segmented (left column) and the foreground portions that are segmented and isolated therefrom (right column) and which are output by exemplary embodiments of the invention.
FIG. 4 is a further image to be segmented having user markers identifying foreground regions, and showing various other regions of the image that are evaluated by an algorithm according to these teachings as to whether they are foreground or background.
FIG. 5 is a process flow diagram showing operation of an apparatus according to certain exemplary embodiments of these teachings.
FIG. 6 is a high level schematic block diagram illustrating a computing device that is suitable for practicing the described and exemplary embodiments of these teachings.



DETAILED DESCRIPTION
In the Summary above and in the Detailed Description and the claims below, and in the accompanying drawings, reference is made to particular features (including method steps) of the invention. It is to be understood that these various features may be combined despite that the description herein does not explore explicitly every single such possible combination. The specific embodiments that are detailed with particularity herein are not a limit to the general teachings herein, and such exemplary embodiments by themselves are not a limit to the scope of the ensuing claims but rather teach the principles of the invention and illuminate the meaning of such ensuing claims.
The documents mentioned in the background section describe interactive image segmentation approaches. An interactive image segmentation approach requires some user inputs, typically markers created and input by a user that show which portions of an image are background portions and which portions of the image are foreground portions. If both foreground and background have the same shades of color, then an algorithm must decide whether to omit the color which is similar to foreground when segmenting the image. Background segregation from an assumed default background plays an important role in accurate segmentation. The default background is obtained from the region of interest (ROI) provided from the user.
Efficient energy minimization algorithms, such as graph cuts, are widely used to label the unmarked pixels in interactive segmentation, for example by documents [4] and [5] in the background section. The main steps from document [5] are object marking followed by boundary editing. However, research from document [2] confirmed that accurate segmentation of an image requires enough foreground and background samples. Document [2] suggests using a color histogram of a region to perform Maximally Similar Region Merging (MSRM) by which to merge small regions into background. The red/green/blue (RGB) colors are uniformly quantized into 16 levels per channel and histograms of 16×16×16=4096 bins are used to estimate region similarity. Although this resulted in better segmentation quality than if graph cuts were used with the same markers, document [2] considers only local information in this merging process. Each of the approaches described by documents [1-5] requires extensive use of background and foreground markers and often do not perform proper segmentation when the object is at the border/boundary of the image being segmented.
Embodiments of the invention address these limitations by providing (i) robust object segmentation with intelligent background selection with respect to user marked foreground; (ii) refinement in usage of the obtained foreground regions; and (iii) object segmentation using very few or even no background markers.
FIG. 1 shows a high level flow chart of embodiments of the invention. Each step of the flow chart is detailed more thoroughly below. The set of foreground markers, and optionally also background markers, are the first inputs to be provided from the user at step 100. Low-level pre-segmentation is done at step 102, for example using a mean-shift analysis technique. The pre-segmentation is followed by automatic background selection at step 104 which is performed based on a default background. Using these inputs, discriminating filtering is applied for all regions of the image and local neighborhood classification using strong and weak foreground and background information. These are represented in FIG. 1 as steps 106 and 108. The image is pruned at 110 resulting in the segmented foreground object at step 112. The entire process will reduce the number of foreground markers required and require few, if any, background markers. This is the case even when a foreground portion extends to the border of the image being segmented.
Typically for image and video editing the segmented foreground object resulting at step 112 is output, separate and distinct from the remaining background object of the original image that has been segmented. In some cases the outputs will be both foreground and background objects as separate and independent digital files. In any case each output is a digital file, which may be displayed on-screen such as when the digital file remains stored within the internal memory of the computer which performed the image segmentation, or the output may be a removable memory on which is stored such digital file(s), or the output may be a transmission of the digital file(s) over a wired or wireless communication pathway for storage on an external memory.
In some embodiments of the invention the only user markings on the image that is input for segmentation are of foreground areas, while in other embodiments it is advantageous to additionally have user markings of certain background areas. In the prior art referenced in the background section above user markings are required for both foreground and background areas. Assume a user has marked the desired features of an image indicating only a foreground object. These are the user inputs at step 100 of FIG. 1. At low-level pre-segmentation 102, the image is first over-segmented using for example a mean shift algorithm. The mean shift algorithm is a suitable example as it preserves boundaries well in most cases and provides less over segmentation as compared to other low level image processing techniques such as a watershed algorithm, but this is only one non-limiting technique for the pre-segmentation step 102. However implemented, the pre-segmentation step 102 uniquely labels each region, denoted by L.
At automatic background selection step 104, based on the set of inputs markers by the user, a number Nf of foreground regions Mf are defined, and optionally, a number Nb of background regions Mb are defined. Necessarily the number Nf of foreground regions is at least 1 since the user has input a marker identifying it as such, and while in most implementations there will be background regions identified it is possible that, without a user marked background region the number Nb of background regions may in fact be zero at this stage. A default background region B is selected as ROI border regions. In one implementation all border regions of the image that are not marked by the user as a foreground region are considered initially as such default background regions. In exemplary embodiments of the invention, the default background regions are scrutinized against the user marked foreground regions according to the following steps:

    
    
        (1) For each region {Bi}i=1, 2, . . . m, a set of adjacent regions is formed, denoted as SB={Aj}j=1, 2, . . . n for n adjacent regions. An inter color distance dj is calculated using mean colors in CIELab color space between each region of Bi and its adjacent regions SB. CIE is a term of art in the image processing arts representing a uniform color space or scale in terms of RGB, and is not limiting to the broader teachings herein. A Minimum of (dj) is computed to find the most similar adjacent region, which is denoted below as the kth region. The regions are merged under the following criteria:

if SkAjε{Bi} then, SkAj∪Bi 

If the above criteria is not met then SkAj and Bi will not be merged. New labels are generated Lnew and new border regions, Bnew are obtained. This step allows similar neighbor border regions to be merged into a single region which provides savings to computation cost during execution of the remainder of the algorithm that is detailed below.

        (2) Each distance of {Binew}i=1, 2, . . . m regions is scrutinized against the distance of Mf user marked foreground regions and the minimum color distance differences restricted with a threshold thr are found by the following equation:

diff Di=min(d(Mf)−d(Binewi=1,2, . . . m))

        This step determines the border regions that are similar to the user marked foreground regions Mf.
    
    


(3) The regions satisfied by step (2) immediately above are denoted below as Bsim. With reference to Bsim, a color histogram is computed for each border region. In exemplary embodiments, the RGB color space is used to compute the color histogram. Each color channel is, for example, uniformly quantized into 8 levels and a histogram of each border region is calculated in the feature space, for example, of 8×8×8=512 bins. The normalized histogram of each border region Bnew is denoted by HistBnew. The Bhattacharya coefficient, ρ, is used to measure the similarity between mth and nth border regions,




  
    ρ
    ⁡
    
      (
      
        m
        ,
        n
      
      )
    
  
  =
  
    
      ∑
      
        u
        =
        1
      
      512
    
    ⁢
    
      
    
    ⁢
    
      
        
          Hist
          m
          u
        
        ·
        
          Hist
          n
          u
        
      
    
  




where ρ varies from 0 to 1 and superscript u represents the uth element of normalized histogram bin. As is known in the image processing arts, the higher the Bhattacharya coefficient between m and n, the higher the similarity is between them. The normalized histogram HistBnew for each border region is computed and the similarity is measured only for the normalized histogram HistBsim border regions in this embodiment. The similar regions, designated Bmat, are finally selected with the following criteria:

ρ(HistBnew,HistBsim)>X 

where X is the minimum threshold set for similarity criteria. This step determines the spatially disconnected similar border regions with respect to Bsim, but also finds similarity for texture related regions.

Using this information, the possible foreground and background regions are obtained.
Possible foreground regions Pf are obtained using:

Pf=Bmat∪Bsim.

and, possible background regions Pb, are obtained using:

Pb=BnewPf.

The possible background regions, B, obtained by step 104 are depicted in FIG. 2A as all of the border regions towards the edges of the example image, since in the FIG. 2A-B example no border region is marked by the user as being foreground. The star 200 represents a foreground object. Initially, all of the border regions not marked as foreground are set to a default background based on steps 100 and 102. Regions 202 and 204 represent default background regions. Automatic background selection 104 determines the possible foreground regions Pf which are represented by region 204. Now referring to FIG. 2B, the possible foreground regions 206 have been removed from the background regions which results in a new set of possible background regions, namely Pb. That is, at FIG. 2B the shaded border regions are those which are still possible background regions Pb, whereas the unshaded border regions 206 are those which have been determined via a color matching analysis to be sufficiently close to a user designated foreground region 200 that they are now considered possible foreground regions Pf.
In exemplary embodiments of the invention, at step 106 a set of regions Binit is created by Pb∪Mb, where Mb represents the user marked background, if any. If the user has not marked any background regions, then Mb is assigned as NULL. At least Binit and the user marked foreground Mf are used as inputs for implementing a discrimination filter. Reference [1] in the background section above details discrimination filters and so such filters need not be further described herein. One particular such discrimination filter uses a k-d tree to classify foreground and background regions, and this is the type of discrimination filter used in the example algorithm according to these teachings which generated the isolated foregrounds shown at FIGS. 3A-B. However implemented, the discrimination filter is configured to output the following three types of regions: strong foreground regions Sf; strong background regions Sb; and ambiguous regions G.
After classifying the strong foreground regions Sf and strong background regions Sb, the ambiguous regions G are then classified as either weak foreground Wf or weak background Wb regions at step 108. To accomplish this, local neighbor region information is used according to the following example process:

    
    
        (i) For each ambiguous region {Gi}i=1, 2, . . . m, a set of adjacent regions SB={Aj}j=1, 2, . . . n is formed. The mean colors in the CIELab color space are used to calculate the inter color distance between each ith ambiguous region Gi and its adjacent regions SB. In principle this is similar to the process described above regarding step 104. The minimum color distance (dj) is computed to find the most similar region (kth region). The ambiguous regions Gi are then labeled as
    
    






  
    
      L
      new
    
    ⁡
    
      (
      
        G
        i
      
      )
    
  
  =
  
    {
    
      
        
          
            W
            f
          
        
        
          
            
              if
              ⁢
              
                
              
              ⁢
              
                
                  S
                  _
                
                k
                
                  A
                  j
                
              
            
            ∈
            
              {
              
                S
                f
              
              }
            
          
        
      
      
        
          
            W
            b
          
        
        
          
            
              if
              ⁢
              
                
              
              ⁢
              
                
                  S
                  _
                
                k
                
                  A
                  j
                
              
            
            ∈
            
              {
              
                S
                b
              
              }
            
          
        
      
    
  




If SkAjε{Gi}, then merge:

SkAj∪{Gi}

and repeat step (i).
This merging process classifies each ambiguous region as either a weak foreground region Wf or a weak background region Wb to satisfy step 108 of the overall process at FIG. 1. In one embodiment neither the foreground nor background list is updated yet with these classified weak regions to avoid unwanted labeling and user confusion.
In the pruning step 110, some or all of the following three steps are performed to obtain the segmented foreground object 112:

    
    
        1) Merge the strong and weak foreground regions SWf:

SWf=Sf∪Wf 

        Similarly, merge the strong and weak background regions SWb:

SWb=Sb∪Wb;

        2) Classify any gap of foreground segmentation SWf which is surrounded by foreground region as foreground region; and
        3) Remove isolated foreground regions depending upon the user foreground marker.
    
    


Referring now to FIG. 3A, a first column 300 and a second column 302 of images are shown. The images shown in the first column 300 represent a wide range of image types that are first input for segmentation in the inventors' testing of a specific embodiment of these teachings. Specifically, the gorilla image, in the first row of FIG. 3A, is an image with relatively high contrast and simple texture, where the foreground is connected to the lowermost border of the image. The second row of column 300 shows an image of a man positioned in the center as a foreground object and no part of the man extends to the borders of the image. The third row shows an image with a starfish in the foreground where the starfish has a block texture, part of which extends to the uppermost and right borders of the image. Finally, the forth row shows an image of woman with a complex repeated pattern on her blouse in the foreground which extends to the lowermost, left and right borders of the image.
The gorilla image in column 300 contains a set of input markers, indicated by light shading 304, which the user inputs to identify at least portions of the foreground of the image to be segmented. In the gorilla image, the gorilla is the foreground of the image to be segmented. Each of the other images in column 300 also contains a set of user markers on a foreground of the respective images. Note that none of the input markers in column 300 identify background regions. The images in column 302 show the output of the foreground image after the input image with foreground markers is processed according to an algorithm following these teachings. The gorilla image in column 302 shows the foreground image 306 separate and distinct from any region that is classified, considered or marked as background. The remaining space of the input image (column 300) that is not output as the foreground image (column 302) includes all regions that were classified, considered or marked as background.
FIG. 3B shows another set of images in column 306 and column 308. The first row in column 306 shows an image with a small girl in the foreground on the right and this is the only portion of that image that has user marks 304 as foreground. The girl's dress has some texture and the girl, including her dress, is connected to the right border of the image. The next row shows an image of a tribal woman with a child on her back and both are marked by the user as foreground. The tribal woman's skirt provides high texture and is attached to the lowermost border of the image while her headwrap extends to the uppermost border. It is a high contrast image with more color variation than some of the previous images. The last row of column 310 shows an image of an airplane in the foreground extending to the border of the image on the right. The concrete in the background closely matches the color of the airplane and in the inventors' experimentation some prior art image segmentation techniques had particular difficulty with distinguishing the cement from the airplane fuselage. This is a low contrast image.
Similar to FIG. 3A, the first column 306 in FIG. 3B shows a set of input markers 304 on each image, indicated by light shading, identifying the foreground of the image to be segmented. Optional background markers 310 are also used in the images of column 306. The set of input markers for each image comprises both the markers indicating foreground 304 and the markers indicating background 310. The images in column 308 show the output of the foreground image based on an exemplary embodiment of the invention.
In FIG. 4 the top image shows a blown up version of the gorilla image from FIG. 3A. The same input markers 304 are placed on the foreground of the image. The bottom image shows various different regions as used in embodiments of the invention. Regions 402 are the regions following pre-segmentation that are defined by the set of input markers, while border regions 404 are possible foreground regions due to their color matching with the user-marked foreground regions 402. The remainder 408 of the lower portion of FIG. 4 is made up of regions that are determined as background after intelligent background selection. Isolated regions 406 are regions yet to be determined as foreground, background or ambiguous regions.
FIG. 5 is a logic flow diagram that summarizes some of the above embodiments for segmenting an image using a computer, termed broadly as simply a device. Referring to FIG. 5, at block 502 a device using a set of user input foreground markers that identify a foreground of an image to be segmented, defines Nf foreground regions and Nb background regions, where Nf is an integer greater than zero and Nb is an integer at least zero.
In one embodiment the set of user input consists of only the foreground markers, and the Nf foreground regions and Nb background regions are defined from the image using a mean shift algorithm. In another embodiment the set of user inputs includes user input foreground markers identifying the foreground of the image to be segmented, and also user input background markers identifying a background of the image to be segmented.
In general terms and as summarized at block 504, for each respective border region that defines a border of the image and is not one of the Nf foreground regions, the above-described algorithm performs a multi-level assessment of the respective border region to determine whether the respective border region is a possible foreground region. Each level of the multi-level assessment compares color similarity, with respect to a threshold that is specific for that level, between the respective border region and a) any of the Nf foreground regions or b) of a region that satisfied the threshold of a previous level of the multi-level assessment.
In the specific embodiment detailed above, an initial level of the multi-level assessment comprises comparing a color distance between the respective border region and each of the Nf foreground regions and concluding the respective border region is a similar border region Bsim if the color distance is within a first threshold thr. While the implementation above utilized the equation diff Di=min(d(Mf)−d(Binewi=1, 2, . . . , m)) for this initial level, it is not necessary in all embodiments that the border regions first be merged to yield the Binew border regions before conducting this initial level assessment. For implementations in which such border region merging is accomplished, then as detailed more particularly above prior to the initial level each border region Bi is merged with adjacent regions Aj thereof if an inter-color distance between the border region Bi and any respective adjacent region Aj is within a minimum color distance di, to result in new border regions Bnew for which the color distance diff Di is compared against each of the Nf foreground regions during the initial level of the assessment.
For this multi-level assessment the specific implementation above details that a subsequent level following the initial level of the multi-level assessment comprises comparing similarity of color histograms of each similar border regions Bsim that are output from the initial level as possible foreground regions against color histograms of other border regions that were not output from the initial level as possible foreground regions. It is these similar border regions Bsim that satisfy the threshold of the previous level as step 504 states. In this subsequent level, if the similarity of the color histograms is greater than a second threshold X then it is concluded that the respective other border region Bmat is a possible foreground region. The possible foreground regions Pf resulting from both the initial and subsequent levels of the assessment are then the similar border regions Bsim and the other border regions Bmat.
Returning to FIG. 5, the next main step at block 506 is that, from the multi-level assessment and the foreground markers, each region of the image to be segmented is classified as one of a strong foreground region, a strong background region or an ambiguous region.
More specifically, the algorithm detailed by example above has the strong foreground regions consisting of the Nf foreground regions that are identified by the user marked foreground markers and the possible foreground regions Pf. The strong background regions consist of the new border regions Bnew that are not output from the subsequent level as possible foreground regions Bmat, along with any further region identified by any user input background marker that may have been input, as a background of the image to be segmented. A discrimination filter is utilized to find the ambiguous regions Gi which are neither strong foreground regions nor strong background regions. In the detailed implementation above the user-marked Nf foreground regions and the background are all input to the discrimination filter which outputs the strong foreground regions, strong background regions and ambiguous regions. In this case the background is designated above as Binit, which is the user marked background regions Mb (if any) plus all the possible background regions Pb, where Pb is all the Bnew that are not considered as possible foreground regions Pf.
FIG. 5 then has at block 508 classifying each of the respective ambiguous regions as a weak foreground region or a weak background region. The more detailed implementation above classifies each of these respective ambiguous regions Gi as a weak foreground region or a weak background region by comparing an inter-color distance between each respective ambiguous region Gi and its adjacent regions Aj and merging the respective ambiguous region Gi with the adjacent region Aj that is nearest in color distance to the respective ambiguous region Gi. This classifies each ambiguous region Gi, after the merging, as either a weak foreground region Wf or a weak background region Wb. More concisely, in this step there is a comparing of color of each ambiguous region Gi against color of regions adjacent thereto and a merging the respective ambiguous region Gi with its adjacent region having the most similar color.
FIG. 5 concludes with step 510 at which the strong foreground regions are merged with the weak foreground regions and from this merging is output a foreground image of the (original) image to be segmented, and it is output separate and distinct from any region that is classified as one of the strong background regions or one of the weak background regions. Such foreground images for output are shown by example at column 302 of FIG. 3A, and also at column 308 of FIG. 3B. This output of the foreground image may be to a tangible computer readable memory, or to a graphical display such as a computer screen or projector.
This merging at step 510 is detailed as the pruning in the non-limiting example above, which can be neatly summarized as a) merging the strong foreground regions with the weak foreground regions Wf′, b) merging the strong background regions with the weak background regions Wb; c) filling gaps that are surrounded by the merged strong and weak foreground regions; and d) depending on the user input foreground markers, removing from the merged and filled strong and weak foreground regions [part c) above] any isolated regions. From this more particularized merging/pruning step is output the foreground image, which in this case is separate and distinct from the merged strong and weak background regions and also separate and distinct from any removed isolated regions.
The logic diagram of FIG. 5 may be considered to illustrate the operation of a method, and a result of execution of a computer program stored in a computer readable memory, and a specific manner in which components of an electronic device are configured to cause that electronic device to operate. The various blocks shown in FIG. 5 may also be considered as a plurality of coupled logic circuit elements constructed to carry out the associated function(s), or specific result of strings of computer program code or instructions stored in a memory.
As shown in the high level block diagram of FIG. 6 a computing system is shown, which includes processing means such as at least one central processing unit (CPU) 600, a graphics processing unit (GPU) 602, storing means such as at least one computer-readable memory (MEM) 604 storing at least one computer program (PROG) 606, a display device 608, and an input device 610, which are connected to communicate with one another through a bus 612. Also stored in the MEM 604 at reference number 606 are the computer code or computer implementable algorithm(s) for the computer system to define foreground and background regions of an image to be segmented, quantize similarity of border regions, and classify regions as foreground or background according to the exemplary embodiments described above.
The computer readable memory 604 may comprise a random access memory (RAM) and a mass storage. Various embodiments of the computer readable MEMs 604 include any data storage technology type which is suitable to the local technical environment, including but not limited to semiconductor based memory devices, magnetic memory devices and systems, optical memory devices and systems, fixed memory, removable memory, disc memory, flash memory, DRAM, SRAM, EEPROM and the like.
The CPU 600, the GPU 602, and the memory 604 are shown as separate components, however in some embodiments, the memory 604 may be integrated with one or both of the CPU 600 and the graphics processor 602. In some embodiments, the memory 604 may be shared dynamically by the CPU 600 and the graphics processor 602. In some embodiments, memory 604 is used by the CPU 600, and a second graphics RAM is dedicated for the use by the graphic processor 602. In some embodiments, the GPU 602 may be integrated with the CPU 600. In some embodiments, the computer system in FIG. 6 may lack a dedicated GPU 602, and the CPU 600 may be adapted to perform computations in place of the GPU 602. The CPU 600 and the graphic processor 602 may be operating in either single precision floating point (32-bit) or double precision floating point (64-bit) format.
The input device 610 may be a commonly known device for providing user input to a computer system, such as a mouse, a keyboard, a touch pad and/or a touch screen, or a transducer (e.g., a microphone) in conjunction with voice recognition software. The display device 608 may be a commonly known graphical display screen or projector for displaying graphical images to a user. Although shown as separate blocks, the display device 608 and the input device 610 may be integrated with one another, such as may be the case with a touch screen device. In some embodiments, the bus 612 may include a north bridge for connecting the CPU 600, the graphics processor 602, and the memory 604, and a south bridge for connecting the display device 608 and the input device 610.
In some embodiments, the input device 610 is adapted to provide commands to select a set of input markers identifying a foreground and/or a background of an image to the CPU 600. The commands may be entered through a user interface displayed on the display device 608. For example, a user many select an image, select a portion of the image which represents a background or foreground of the image through the user interface. The image may be a picture, a graphic, a video or the like. In some embodiments, the application of the input markers may be triggered by another program running on the computer system. The image file may be stored on the memory 604 and retrieved by the CPU 600 to be displayed on the display device 608.
In response to a command to select a set of input markers of an image, the CPU 600 may be adapted to execute codes stored in the memory 604. In some embodiments the computer system may be adapted to apply embodiments of the invention to a single image, a video comprising a series of still images, or some other video file such as a compressed video file. The outputted foreground image and/or regions classified, considered or marked as background, may be displayed on the display device 608 and stored into the memory 604.
In general, the various embodiments of the computer system in FIG. 6 can include, but are not limited to workstations, servers, personal desktop computers, laptop or tablet computers, and even personal portable digital devices having wireless communication capabilities, including but not limited to handheld or wearable computers such as cellular phones and smart phones, Google glass devices, and the like.

## Claims

1. A method of segmenting an image using a computer, the method comprising:
using a set of user input foreground markers identifying a foreground of an image to be segmented, defining Nf foreground regions and Nb background regions, where Nf is an integer greater than zero and Nb is an integer at least zero;
for each respective border region that defines a border of the image and is not one of the Nf foreground regions, performing a multi-level assessment of the respective border region to determine whether the respective border region is a possible foreground region, where each level of the multi-level assessment compares color similarity, with respect to a threshold that is specific for that level, between the respective border region and any of the Nf foreground regions or of a region that satisfied the threshold of a previous level of the multi-level assessment;
from the multi-level assessment and the foreground markers, classifying each region of the image to be segmented as one of a strong foreground region, a strong background region or an ambiguous region;
classifying each of the respective ambiguous regions as a weak foreground region or a weak background region; and
merging the strong foreground regions with the weak foreground regions and output therefrom, to a tangible memory or to a graphical display, a foreground image of the image to be segmented, separate and distinct from any region classified as one of the strong background regions or weak background regions.

2. The method according to claim 1, wherein the set of user inputs consists of only the foreground markers, and the Nf foreground regions and Nb background regions are defined from the image using a mean shift algorithm.

3. The method according to claim 1, wherein an initial level of the multi-level assessment comprises:
comparing a color distance between the respective border region and each of the Nf foreground regions and concluding the respective border region is a similar border region Bsim if the color distance is within a first threshold thr.

4. The method according to claim 3, wherein prior to the initial level each border region Bi is merged with adjacent regions Aj thereof if an inter-color distance between the border region Bi and any respective adjacent region Aj is within a minimum color distance di, to result in new border regions Bnew for which the color distance diff Di is compared against each of the Nf foreground regions during the initial level of the assessment.

5. The method according to claim 3, wherein a subsequent level following the initial level of the multi-level assessment comprises:
comparing similarity of color histograms of each similar border regions Bsim that are output from the initial level as possible foreground regions against color histograms of other border regions that were not output from the initial level as possible foreground regions, and if the similarity of the color histograms is greater than a second threshold X concluding that the respective other border region Bmat is a possible foreground region, such that the possible foreground regions Pf are the similar border regions Bsim and the other border regions Bmat.

6. The method according to claim 5, wherein:
the strong foreground regions consist of the Nf foreground regions identified by the user marked foreground markers and the possible foreground regions Pf;
the strong background regions consist of the new border regions Bnew that are not output from the subsequent level as possible foreground regions Bmat with any further region identified by a user input background marker as a background of the image to be segmented; and
the method further comprises utilizing a discrimination filter to find the ambiguous regions Gi which are neither strong foreground regions nor strong background regions.

7. The method according to claim 1, wherein classifying each of the respective ambiguous regions Gi as a weak foreground region or a weak background region comprises:
comparing color of each ambiguous region Gi against color of regions adjacent thereto and merging the respective ambiguous region Gi with its adjacent region having the most similar color.

8. The method according to claim 7, wherein merging the strong foreground regions with the weak foreground regions comprises:
merging the strong foreground regions with the weak foreground regions Wf;
merging the strong background regions with the weak background regions Wb;
filling gaps that are surrounded by the merged strong and weak foreground regions; and
depending on the user input foreground markers, removing from the merged and filled strong and weak foreground regions any isolated regions; and outputting therefrom the foreground image, separate and distinct from the merged strong and weak background regions and from any removed isolated regions.

9. The method according to claim 7, wherein each ambiguous region Gi is classified as either a weak foreground region Wf or a weak background region Wb by:
forming set of adjacent regions SB={Aj}j=1, 2, . . . n that are adjacent to the respective ambiguous region Gi;
calculate an inter color distance between each respective ambiguous region Gi and each of its adjacent regions SB;
merging the respective ambiguous region Gi with the adjacent region Aj for which the inter-color distance is lowest; and
classifying the respective ambiguous region Gi as a weak foreground region Wf or a weak background region Wb based on whether the merged adjacent region Aj is a strong foreground region Sf or a strong background region Sb.

10. A non-transitory computer readable memory storing a program for segmenting an image, wherein the program comprises computer executable code for causing a host device to:
use a set of user input foreground markers identifying a foreground of an image to be segmented, to define Nf foreground regions and Nb background regions, where Nf is an integer greater than zero and Nb is an integer at least zero;
for each respective border region that defines a border of the image and is not one of the Nf foreground regions, perform a multi-level assessment of the respective border region to determine whether the respective border region is a possible foreground region, where each level of the multi-level assessment compares color similarity, with respect to a threshold that is specific for that level, between the respective border region and any of the Nf foreground regions or of a region that satisfied the threshold of a previous level of the multi-level assessment;
from the multi-level assessment and the foreground markers, classify each region of the image to be segmented as one of a strong foreground region, a strong background region or an ambiguous region;
classify each of the respective ambiguous regions as a weak foreground region or a weak background region; and
merge the strong foreground regions with the weak foreground regions and output therefrom, to a tangible memory or to a graphical display, a foreground image of the image to be segmented, separate and distinct from any region classified as one of the strong background regions or weak background regions.

11. The non-transitory computer readable memory according to claim 10, wherein the set of user inputs consists of only the foreground markers, and the Nf foreground regions and Nb background regions are defined from the image using a mean shift algorithm.

12. The non-transitory computer readable memory according to claim 10, wherein during an initial level of the multi-level assessment the computer executable code causes the host device to:
compare a color distance between the respective border region and each of the Nf foreground regions and concluding the respective border region is a similar border region Bsim if the color distance is within a first threshold thr.

13. The non-transitory computer readable memory according to claim 12, wherein prior to the initial level the computer executable code causes the host device to merge each border region Bi with adjacent regions Aj thereof if an inter-color distance between the border region Bi and any respective adjacent region Aj is within a minimum color distance di, to result in new border regions Bnew for which the computer executable code causes the host device to compare color distance diff Di against each of the Nf foreground regions during the initial level of the assessment.

14. The non-transitory computer readable memory according to claim 12, wherein during a subsequent level following the initial level of the multi-level assessment the computer executable code causes the host device to:
compare similarity of color histograms of each similar border regions Bsim that are output from the initial level as possible foreground regions against color histograms of other border regions that were not output from the initial level as possible foreground regions, and if the similarity of the color histograms is greater than a second threshold X to conclude that the respective other border region Bmat is a possible foreground region, such that the possible foreground regions Pf are the similar border regions Bsim and the other border regions Bmat.

15. The non-transitory computer readable memory according to claim 14, wherein:
the strong foreground regions consist of the Nf foreground regions identified by the user marked foreground markers and the possible foreground regions Pf;
the strong background regions consist of the new border regions Bnew that are not output from the subsequent level as possible foreground regions Bmat with any further region identified by a user input background marker as a background of the image to be segmented; and
the computer executable code comprises a discrimination filter by which is found the ambiguous regions Gi which are neither strong foreground regions nor strong background regions.

16. The non-transitory computer readable memory according to claim 10, wherein the computer executable code causes the host device to classify each of the respective ambiguous regions Gi as a weak foreground region or a weak background region by:
comparing an inter-color distance between each respective ambiguous region Gi and its adjacent regions Aj and merging the respective ambiguous region Gi with the adjacent region Aj that is nearest in color distance to the respective ambiguous region Gi such that each merged ambiguous region Gi is classified as a weak foreground region Wf or a weak background region Wb.

17. The non-transitory computer readable memory according to claim 16, wherein merging the strong foreground regions with the weak foreground regions comprises:
merging the strong foreground regions with the weak foreground regions Wf;
merging the strong background regions with the weak background regions Wb;
filling gaps that are surrounded by the merged strong and weak foreground regions; and
depending on the user input foreground markers, removing from the merged and filled strong and weak foreground regions any isolated regions; and outputting therefrom the foreground image, separate and distinct from the merged strong and weak background regions and from any removed isolated regions.

18. The non-transitory computer readable memory according to claim 10, in combination with the host device comprising at least one processor and the computer readable memory storing the program for segmenting an image.

19. A non-transitory computer readable memory storing a program for segmenting an image, wherein the program comprises computer executable code for causing a host device to:
from inputs of an image to be segmented and a set of user input foreground markers identifying a foreground of said image, determine strong foreground regions Sf, strong background regions Sb and ambiguous regions G;
classify each ambiguous region Gi as either a weak foreground region Wf or a weak background region Wb by comparing color of each ambiguous region Gi against color of regions adjacent thereto and merging the respective ambiguous region Gi with its adjacent region having the most similar color; and
merge the strong foreground regions Sf with the weak foreground regions Wf and output therefrom, to a tangible memory or to a graphical display, a foreground image of the image to be segmented, separate and distinct from any region classified as one of the strong background regions or weak background regions.

20. The non-transitory computer readable memory according to claim 19, wherein each ambiguous region Gi is classified as either a weak foreground region Wf or a weak background region Wb by:
forming set of adjacent regions SB={Aj}j=1, 2, . . . n that are adjacent to the respective ambiguous region Gi;
calculate an inter color distance between each respective ambiguous region Gi and each of its adjacent regions SB;
merging the respective ambiguous region Gi with the adjacent region Aj for which the inter-color distance is lowest; and
classifying the respective ambiguous region Gi as a weak foreground region Wf or a weak background region Wb based on whether the merged adjacent region Aj is a strong foreground region Sf or a strong background region Sb.