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

**URL:** https://forum.opencv.org/t/find-the-contour-of-a-triangle-with-an-acute-angle-using-the-watershed-algorithm/13673
**Category:** Python
**Created:** [June 26, 2023, 9:15am UTC](https://forum.opencv.org/t/find-the-contour-of-a-triangle-with-an-acute-angle-using-the-watershed-algorithm/13673 "2023-06-26T09:15:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dushese](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/dushese/32/8162_2.png) [@Dushese](https://forum.opencv.org/u/Dushese)
#### Post date: [June 26, 2023, 9:15am UTC](https://forum.opencv.org/t/find-the-contour-of-a-triangle-with-an-acute-angle-using-the-watershed-algorithm/13673/1 "2023-06-26T09:15:40Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/6/68a20ec7cf6d52f9fe3fa5241d69e31751a9e939.png)

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [June 26, 2023, 11:48am UTC](https://forum.opencv.org/t/find-the-contour-of-a-triangle-with-an-acute-angle-using-the-watershed-algorithm/13673/2 "2023-06-26T11:48:00Z")

</div>

wrong method. do not use watershed.

---

<div class="post-metadata">

### Author: ![Dushese](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/dushese/32/8162_2.png) [@Dushese](https://forum.opencv.org/u/Dushese)
#### Post date: [June 26, 2023, 1:57pm UTC](https://forum.opencv.org/t/find-the-contour-of-a-triangle-with-an-acute-angle-using-the-watershed-algorithm/13673/4 "2023-06-26T13:57:53Z")

</div>

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

 ![liza_grains_4](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/7/7276f1a0c0e0ed99d1784f6c4d03af40ed965b34.jpeg)

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [June 26, 2023, 3:03pm UTC](https://forum.opencv.org/t/find-the-contour-of-a-triangle-with-an-acute-angle-using-the-watershed-algorithm/13673/5 "2023-06-26T15:03:56Z")

</div>

yes.

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.
