how to increase the accuracy of Grabcut Algorithm using OpenCV?

本小妞迷上赌 提交于 2021-02-10 09:13:27

问题


I am using the grabcut algorithm of OpenCV for the background subtraction of an image in android. Algorithms runs fine but the result it gives is not accurate. E.g. My input image is:

Output image look like:

so How can we increase accuracy of Grabcut Algorithm?

P.S: Apology for not uploading example images due to low reputation :(


回答1:


I have been battling with the same problem for quite some time now. I have a few tips and tricks for this

1> Improve your seeds. Considering that GrabCut is basically a black box, to whom you give seeds and expect the segmented image as output, the seeds are all you can control and it becomes imperative to select good seeds. There are a number of things you can do in this regard if you have some expectation for the image you want to segment. For a few cases consider these:

a> Will your image have humans? Use a face detector to find the face and mark those pixels as Probable/definite foreground, as you deem fit. You could also use skin colour models within some region of interest to further refine your seeds

b> If you have some data on what kind of foreground you expect after segmentation, you can train colour models and use them as well to mark even more pixels

The list will go on. You need to creatively come up with different ways to adds more accurate seeds.

2> Post Processing: Try simple post processing techniques like the Opening and Closing operations to smoothen your fgmask. They will help you get rid of a lot of noise in the final output.

In general graphcut (and hence grabcut) tends to snap quickly to edges and hence if you have strong edges close to your foreground boundary, you can expect inaccuracies in the result.



来源:https://stackoverflow.com/questions/24948606/how-to-increase-the-accuracy-of-grabcut-algorithm-using-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!