1

I have been looking to close contour for shapes that are similar to circles or rounded objects.

I found a very interesting answer here.

I thought my problem was solved until I tested with different images.

This is my mask from OpenCV canny AFTER dilating. As you can see, there is a big gap at the bottom.

enter image description here

If the shape was a circle, I could try to recreate the circle, but the thing is the shape could be different. I could look like a cucumber or a rugby balloon.

I wonder if it's actually possible to connect the contour without doing a straight line, which will make me lose a lot of information.

Approximating the "curveness" or "straightness" according to the neighbor?

enter image description here

Muhammad Mohsin Khan
  • 1,444
  • 7
  • 16
  • 23
Marie
  • 81
  • 7
  • What does your input image look like? Perhaps a different approach from using canny edges would be better, such as thresholding and finding the contour. – fmw42 Mar 30 '22 at 15:05
  • the input image is the canny edge image. :) Cannot avoid that – Marie Mar 30 '22 at 15:18
  • What image did you start with before the canny and any other processing? – fmw42 Mar 30 '22 at 16:01
  • Try [cv2.minEnclosingCircle](https://docs.opencv.org/3.4/dd/d49/tutorial_py_contour_features.html) and [this](https://docs.opencv.org/3.4/d3/dc0/group__imgproc__shape.html#ga8ce13c24081bbc7151e9326f412190f1) – nathancy Mar 30 '22 at 17:27
  • 1
    @nathancy I tried cv2.minEnclosingCircle, but it's creating a bigger circle around my object. How could I use it to close my object ? Thank you. – Marie Mar 31 '22 at 09:55

0 Answers0