Ask Your Question

Merge Two Closely Overlapping Contours

asked 2018-06-17 05:10:17 -0500

abeltan13 gravatar image


Say I have these two shapes,

image description

They can be represented by contours. I have identified the contour points that are close together. I want to merge them if their edges are close together.

How do I create another contour path that represents the merged shape?

image description

I have tried convex_hull on the concatenation of the two paths, but that only works on convex shapes!

Is there any algorithm that works on concave shapes?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2018-06-17 05:49:31 -0500

LBerger gravatar image

updated 2018-06-17 15:24:49 -0500

Try :

  1. Fill contours
  2. dilate image (may be N=10 iterations)
  3. erode image (N iterations)
  4. findContours

I hope that you will get only one contour

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-06-17 05:10:17 -0500

Seen: 7,006 times

Last updated: Jun 17 '18