# Contour extraction

**URL:** <https://forum.opencv.org/t/contour-extraction/4415>\
**Category:** Python\
**Created:** [July 21, 2021, 6:18am UTC](https://forum.opencv.org/t/contour-extraction/4415 "2021-07-21T06:18:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CC\_X](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/cc_x/32/2710_2.png) [@CC\_X](https://forum.opencv.org/u/CC_X)\
**Post date:** [July 21, 2021, 6:18am UTC](https://forum.opencv.org/t/contour-extraction/4415/1 "2021-07-21T06:18:57Z")

</div>

![Snipaste_2021-07-21_14-17-47](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/d/d76e64f4411a58b6921b36ae7515997c47d55aee.jpeg)

Use opencv to get contours like the one on the right from the left

---

<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:** [July 21, 2021, 11:19am UTC](https://forum.opencv.org/t/contour-extraction/4415/3 "2021-07-21T11:19:21Z")

</div>

welcome.

what have you tried? what research have you done?

---

<div class="post-metadata">

**Author:** ![CC\_X](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/cc_x/32/2710_2.png) [@CC\_X](https://forum.opencv.org/u/CC_X)\
**Post date:** [July 22, 2021, 12:57am UTC](https://forum.opencv.org/t/contour-extraction/4415/4 "2021-07-22T00:57:20Z")

</div>

I have tried the cv2.findcontours function myself, but it will get all the contours out. Then I draw the outline, and the result is not what I want. My problem can be imagined as many cables are stacked together. The wire frame I drew in the left picture can be understood as the edge of the cable. Now if there are many cables stacked together, how can I extract the wires? What about the inner and outer contours of the area where the cables are stacked?

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [July 22, 2021, 7:03am UTC](https://forum.opencv.org/t/contour-extraction/4415/5 "2021-07-22T07:03:38Z")

</div>

> [@CC\_X](#):
>
> The wire frame I drew in the left picture can be understood as the edge of the cable

solving an abstraction, like you show above, might be quite different to your real (cables) one, so that’s a bad idea.  
show _real_ images, please.
