2
votes

I have a edge detected by Canny. And I want to extract contours of the edges.

I have checked the following post. OpenCV converting Canny edges to contours.

But it didn't deal with complex shape. e.g, circle with rectangle or circle with line.

cv::findContours() function has 2 issues. 1. Return closed contour for non closed edge, but I want non closed contour 2. Return 2 closed contours for closed edge(maybe one of the contours is for edge, and another one is for inner side of the edge, but I want one of the two.

Is there any way to solve this out? Thanks.

PS : I have uploaded the sample image.

Sample Image.

1
The image doesn't show to be showing the problem you describe. Futhermore you don't really explain what the "sample image" shows. You need to be more specific if you expect an answer.m3h0w

1 Answers

3
votes

It all depends on the parameters you choose while finding contours.

In OpenCV you can find contours using

contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

and draw them

cv2.drawContours(im, contours, -1, (0, 255, 0), -1) #---set the last parameter to -1

enter image description here