varsha_holla
varsha_holla

Reputation: 862

Interactive Foreground Extraction using GrabCut in python,OpenCV

I want to separate the background and foreground in a set of 70 images. But when I try with GrabCut Algorithm, i find that along with the background, foreground is also getting deleted. And the problem is, I can't do this manually.

This is my original image:

This is the result of GrabCut :

enter image description here

Upvotes: 2

Views: 1790

Answers (1)

Sambasivarao. K
Sambasivarao. K

Reputation: 29

As you cant draw rectangle manually, best way is you can try giving the bounding box just 10-20 pixels width inside of your original image (just as an inside boundary) and try with it. But if your foreground object of interest is at the borders, it will get chopped out in this case.

That can be avoided to some extent by checking the biggest blobs and black pixel count of the output image and you can restore back the original pixel values for those cases till 10-20 pixel width away from border. Mostly you have to do after-check on the result and apply some heuristics to atleast restore back the portion of original image.

Upvotes: 1

Related Questions