Find the contour of a triangle with an acute angle using the watershed algorithm

Hey there!
When I want to find contour using watershed algorithm of this image - (1)
I use the marker - (2)
and as a result, get this contour - (3)
Corner of the triangle missed, is there any way to fix it? Maybe some parameter in the realization of watershed algorithm… This also applies to all polygons with sharp corners - corners are simply cut off.

wrong method. do not use watershed.

Maybe you know an approach how to find contours of this?


basically: connected components labeling.

the basis for that is a decent segmentation (binarization).

the shapes touch. you can’t just binarize as white vs non-white. if you did, touching shapes would be connected.

opencv’s CC labeling, sadly, doesn’t contain a step that can differentiate between different foreground colors. you’ll have to handle that.

you’ll have to exploit the shapes’ differing colors, i.e. first figure out what colors there are (clustering/histogram), then binarize and label for each color in turn.

1 Like