2

Grab cut algorithm gives different results for different number of iterations and settle down after some time without any further change. But for my dataset, if i allow it to settle down, it is cropping foreground also. If i do for 2,3 iterations only, then the result is better.

My target is to get the complete foreground without missing any detail. Even the output has some background, it is acceptable. SO my question is how many iterations are optimal for grabcut with minimum foreground cut?

fedorqui
  • 275,237
  • 103
  • 548
  • 598

1 Answers1

1

in the function cv2.grabCut(img,mask,rect,bgdModel,fgdModel,iterCount,cv2.GC_INIT_WITH_RECT) you can change iterCount upto 5 for normal use of Grabcut Algorithm.

When you use iterCount = 1 or iterCount = 2 you will get minimum background subtraction as per your drawn rectangle.

So, if you want grabCut with minimum foreground cut, user iterCount=2 and then specify your rectangle close to main object.

Hope this helps...

Shubham
  • 19
  • 1