Third Approach:Depth Based Seeding



The central idea of this approach is to take advantage of the raw depth data and the normal map of the scene to get an initial estimate of the of the object to be extracted. Then we take this estimate as basis to build the Foreground and Background Color Models, and finally we apply GrabCut on an energy function that take into account both depth and color information.




FinalCaballo-0.png FinalPumba-0.png FinalMorral2-0.png FinalFabian2-0.png FinalFabian4-0.png




The initial estimate of the object is done using the following two criteria :

Central and Closest is Foreground

  1. A random sample of pixels is taken from the central rectangle (i.e, the rectangle with sides 1/2 and in the middle of the ROI). Using K-means we identify n clusters of depth data.
  2. The clusters are sorted by depth distance from closest to farthest. The closest cluster is fixed as FG. Define d12,d23,...,dn-1n  the distance between consecutives cluster:.

    • If d12<dtol  the second cluster is added as FG. Otherwise it is rejected and the unique cluster associated FG is the closest one.
    • If d23<mtol d12 the third cluster is added as FG. Otherwise it is rejected, and the clusters associated FG are the previous one.
    • ....
    • If dn-1n<mtol dn-2n-1 the nth cluster is added as FG. Otherwise it is rejected, and the clusters associated FG are the previous one.
  3. From all the pixels belonging to the clusters marked as FG we took the lowest value of depth  (minDepthFG) and the largest value of depth (maxDepthFG).

DepthHCaballo-1.png DepthHPumba-1.png DepthHMorral2-1.png DepthHFabian2-1.png DepthHFabian4-1.png

External and Planar is Background

  1. The normal at each pixel of the image is calculated from the raw depth data.
  2. Take a random sample of pixels in the outer annulus of  the ROI and store them in a queue.
  3. Fix a normal tolerance parameter (en) and color tolerance parameter (ec).
  4. Pick the first pixel of the queue (p) and identify the connected set of pixels around p that satistifies the conditions, ||np-nx||<en and ||cp-cx||<ec. Call this set of pixels PN(p), and label all these pixels as belongComponent.
  5. In order to confirm PN(p) as a valid plane the following two conditions must hold: 
If the previous conditions holds, we label all the pixels in PN(p) as planarPixels. Otherwise, we undo the belongComponent labelling, and we start to construct a new component from the next non planarPixel in the queue.

PlanarCaballo-1.png PlanarPumba-1.png PlanarMorral2-1.png PlanarFabian2-1.png PlanarFabian4-1.png

Seeding

In order to identify as BG pixels those that have a relative large depth value, belong to a planar patch, or are located near  the frontier of the rectangular selection, lets define the following  functions WBG and WFG that will be constructed in three steps:

First Step

 Let dp be the depth associated to pixel p:
  1. if  minDepthFG<dp<maxDepthFG, set  WBG(p)=1400.
  2. if  dp<minDepthFG,  set  WBG(p)=max(1400+300(d-minDepthFG)/(maxDepthFG-minDepthFG) , 0).
  3. if  dp>maxDepthFG,  set  WBG(p)=max(1400-300(d-maxDepthFG)/(maxDepthFG-minDepthFG) , 0). 
  4. if dp=0 (noisy depth value), set WBG(p)=900.
  5. For all p set WFG(p)=1200.
Second Step

Let (i,j) be the image coordinates of pixel p ( i=1,...,r and  j=1...c )
  1. Set dcenter(p)=max(abs(i-(r/2))/(r/2),abs(j-(c/2))/(c/2)).
  2. Set WFG(p)=WFG(p)+40*dcenter(p).
  3. Set WBG(p)=WBG(p)+40*(1-dcenter(p)).
Third Step
  1. If pixel p is planar set WFG(p)=WFG(p)+1200.
Once WBG and WFG are constructed we define the seeds as follows:

SeedCaballo-1.png SeedPumba-1.png SeedMorral2-1.png SeedFabian2-1.png SeedFabian4-1.png

Final Results

FinalCaballo-1.png FinalPumba-1.png FinalMorral2-1.png FinalFabian2-1.png FinalFabian4-1.png

Remarks

Pros:

Cons: