Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Grabcut foreground problem

Grabcut works on the method that we define the pixel of our image as sure foreground or sure background in our mask. And then try to iterate to see the result.

In my case when I define certain pixel as background it takes that properly but when I define a certain pixel as foreground it changes the result to background(black).

Any possible reason why this is happening :

for(int x=419;x<438;x++){
        for(int y=317;y<456;y++){
            result.get(x,y,buffer);
            buffer[0] = 1;
            result.put(x,y,buffer);
        }
    }
    Imgproc.grabCut(srcImage,result,rect,new Mat(),new Mat(),10,Imgproc.GC_INIT_WITH_MASK);

Which gives that blackish mark in middle of the face as you can see (same result for hair part which I marked as sure background value of 0). Any possible reason why its happening?

image description