简体   繁体   English

使用OpenCV的Canny边缘检测来检测二进制图像中的边缘

[英]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: 在应用Canny方法之前的最后一步中,我得到以下图像:

在此处输入图片说明

After applying Canny I get this image: 应用Canny之后,我得到此图像:

在此处输入图片说明

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? 所以,我的问题是,有没有办法以左上图像返回闭合轮廓的方式使用Canny?

If you already have a binary image, Canny does not give much more information. 如果您已经有一个二进制映像,Canny不会提供更多信息。 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, Canny可用于在灰度图像中查找边缘(它确定渐变是否是边缘),如果图像是黑白图像,则Canny将返回您已有的边缘,

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. 我认为您需要使用findContours(),根据参数将仅返回带有孔或不带孔的白色或黑色对象。 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之前和之后使用形态变换来操纵结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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