Graph cut: Create a grid graph from an image and set custom weight of edges connecting pixels

asked 2014-10-08 23:04:56 -0600

Devylin gravatar image

updated 2020-11-07 02:03:09 -0600

Hi all,

In the algorithm I'm developing I need to use graph cut for images using opencv with python.
I have to define a new graph from an image with custom weight of arcs and then use graph cut to find the min cut. I know that there is the grabcut opencv function that uses a user-specified bounding box around the object to be segmented to find the background/foreground.

Here is grabcut weight of edges description:

The weights of edges connecting pixels to source node/end node are defined by the probability of a pixel being foreground/background. The weights between the pixels are defined by the edge information or pixel similarity. If there is a large difference in pixel color, the edge between them will get a low weight.

I don't have to find the background of an image, I need something similar opencv function but with the possibility to set my custom weight of edges connecting pixels, and then use graph cut to find the min cut.

Any idea?

Thank you!

edit retag flag offensive close merge delete