简体   繁体   中英

Detect edge from binary image using Canny edge detection from OpenCV

I'm trying to extract the contour of some traffic signs. The images pass through several steps in order to get a good segmented image. In the final step before applying Canny method I get this image:

在此处输入图片说明

After applying Canny I get this image:

在此处输入图片说明

The algorithm performs as expected except the top left image for which returns an open contour. So, my question is, is there any way to use Canny in a manner that the top left image returns an closed contour?

If you already have a binary image, Canny does not give much more information. Canny is useful for finding edges in grayscale images (it decides if a gradient is an edge or not), if the image is black and white, Canny will return the edges that you already have,

I think that you need to use findContours(), which depending on the parameters will return only white or black objects, with or without the holes. It also handles the edges of the image.

Image boundary conditions are problematic in most cases. In this particular case, I would try padding the original image with some extra pixels around the image. Depending on how you add those padding pixels, you should get a complete contour around the signs.

您可以在应用Canny Edge Detection之前和之后使用形态变换来操纵结果。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM