canny edge

Not too long back, I was working on a project, the “Real-Time Lane Road detection” when I stumbled upon the Canny Edge Detection algorithm. I was simply fascinated by this algorithm. So much so, that I can’t let it go, without explaining to you what is a Canny Edge Detection?

不久之后,当我偶然发现Canny Edge Detection算法时,我正在从事一个项目“实时车道检测”。 我对这个算法很着迷。 如此之多,以至于我不得不放弃它,而不向您解释什么是Canny Edge Detection?

The Canny Edge Detector is an edge detection operator that is used to detect a wide range of edges in images. It uses a multi-stage algorithm to do so.

Canny Edge Detector是一种边缘检测运算符,用于检测图像中的各种边缘。 它使用多阶段算法来执行此操作。

https://en.wikipedia.org/wiki/Canny_edge_detector-https://en.wikipedia.org/wiki/Canny_edge_detector

Edge detection is simply a case of finding regions in an image, where we have a sharp change of intensity. These changes happen between the boundaries of an object in the image. The edges are detected based on the significant change in the intensity between the objects and the image.

边缘检测只是在图像中找到区域的情况,在该区域中我们的强度发生了急剧变化。 这些变化发生在图像中对象的边界之间。 基于对象和图像之间强度的明显变化来检测边缘。

How does one go about doing edge detection? Let me narrow this down to the following :

如何进行边缘检测? 让我将其缩小到以下内容:

  1. Image Smoothening- This is all about removing the noise in the image. The removal or suppression of the noise should be done in such a way that, the quality of the image is not altered.图像平滑-这就是消除图像中的噪点的全部方法。 消除或抑制噪声的方式应确保图像的质量不变。
  2. Edge’s point detection-It is the process in which the noise alone is carefully removed or discarded retaining the edges appropriately.边缘点检测-在该过程中,仅将噪声适当地去除或丢弃,并适当地保留边缘。
  3. Edge localisation-Here is where we apply the thinning and linking processes etc in order to locate the edges.边缘定位-在这里我们应用细化和链接过程等以定位边缘。

The Canny Edge Detector was published in 1986 by John F.Canny. It is a technique that is used to extract the structural information from various vision objects and reduce significantly the amount of data that is to be processed. It has been widely used in computer vision systems.

坎尼边缘检测器由约翰·范尼(John F.Canny)于1986年出版。 它是一种用于从各种视觉对象中提取结构信息并显着减少要处理的数据量的技术。 它已被广泛用于计算机视觉系统。

There are many other edge detection operators such as Sobel, Prewitt, Laplacian, etc. However, Canny Edge Detection has proven to be the best one out there. The canny edge detector is not like the other traditional edge detectors, it is not just masking or hovering of the input image matrix. In fact, it is quite detailed.

还有许多其他边缘检测运算符,例如Sobel,Prewitt,Laplacian等。但是,Canny边缘检测已被证明是其中最好的一种。 坎尼边缘检测器与其他传统边缘检测器不同,它不仅是掩盖或悬停输入图像矩阵。 实际上,它非常详细。

Canny Edge Operator handily produces an orientation at every point which can be very useful for the post-processing of the image. The Canny edge detector takes the Sobel edge operator and makes it just a step better. What I mean by that is, we can get rid of the edges which we aren’t interested in and keeps only the ones that are useful to us. Canny works by taking the output image of the Sobel Operator and thinning the edges so that they are just 1 pixel wide.

Canny Edge Operator可以在每个点方便地生成方向,这对于图像的后处理非常有用。 Canny边缘检测器采用了Sobel边缘算子,使其变得更好了。 我的意思是说,我们可以摆脱不感兴趣的边缘,而只保留对我们有用的边缘。 Canny的工作方式是拍摄Sobel算子的输出图像并细化边缘,使其仅1像素宽。

Before I start explaining to you people about the Canny Edge Detection let me quickly brief you about the Sobel Edge Operator.

在开始向您介绍有关Canny Edge Detection的人员之前,让我快速向您简要介绍Sobel Edge Operator。

In the Sobel Edge Detector, the image is processed in both the X and Y directions. This forms a new image which would be the sum of X and Y edges of the image. Keep in mind that these can be processed separately as well.

Sobel Edge Detector中,图像在X和Y方向上都得到处理。 这形成一个新图像,该图像将是图像的X和Y边缘的总和。 请记住,这些也可以分别处理。

We start off by converting the image from an RGB scale to a Grayscale image. Then from there, we shall use what is called kernel convolution. There are various pairs of Sobel operators such as 3×3, 5x5 convolution.

我们首先将图像从RGB比例转换为灰度图像。 然后从那里开始,我们将使用所谓的内核卷积。 有各种Sobel算子对,例如3×3、5x5卷积。

In this case, I shall refer to a kernel (3x3) matrix, consisting of differently weighted indexes. This will represent the filter that we will be implementing for edge detection.

在这种情况下,我将参考由不同加权索引组成的内核(3x3)矩阵。 这将代表我们将为边缘检测实现的过滤器。

When we want to scan across the X direction of an image, for example, we will want to use the following X Direction Kernel to scan for large changes in the gradient and vice versa.

例如,当我们想在图像的X方向上扫描时,我们将要使用以下X方向内核来扫描梯度的大变化,反之亦然。

https://www.projectrhea.org/rhea/index.php/An_Implementation_of_Sobel_Edge_Detection: //www.projectrhea.org/rhea/index.php/An_Implementation_of_Sobel_Edge_Detection

The kernels applied to the input image, produce separate gradient component measurements in each orientation (Gx and Gy). The magnitude of the gradient at every pixel and the direction of the gradient is computed by combining Gx and Gy together.

应用于输入图像的核在每个方向(Gx和Gy)上产生单独的梯度分量测量值。 通过将Gx和Gy组合在一起,可以计算每个像素处的梯度大小和方向。

https://file.scirp.org/Html/5-9301774_42100.htm://file.scirp.org/Html/5-9301774_42100.htm

A pictorial representation below will explain what i stated above wrt X and Y direction.

下面的图片表示将解释我在X和Y方向上所讲的内容。

https://www.projectrhea.org/rhea/index.php/An_Implementation_of_Sobel_Edge_Detection: //www.projectrhea.org/rhea/index.php/An_Implementation_of_Sobel_Edge_Detection

The image below is when the two filter results are added together to create an accurate representation of all of the edges (X and Y Direction) in the image.

下图是将两个滤镜结果加在一起以创建图像中所有边缘(X和Y方向)的准确表示时的图像。

https://www.projectrhea.org/rhea/index.php/An_Implementation_of_Sobel_Edge_Detection: //www.projectrhea.org/rhea/index.php/An_Implementation_of_Sobel_Edge_Detection
Comparison of the various Edge Detecting Operators
各种边缘检测算子的比较

The main purpose of the edge detector is to figure out — where the edges are? and not, how thick they are? So let’s come back to the point where I stated that Canny is one of the best edge detectors. For that let’s take an example.

边缘检测器的主要目的是弄清楚边缘在哪里? 不是,它们有多厚? 因此,让我们回到我所说的Canny是最好的边缘检测器之一的角度。 为此,我们来看一个例子。

Take, for instance, we want to find the edges of the petals of a flower.

例如,我们要查找花朵花瓣的边缘。

http://www.public-domain-photos.com/flowers/wet-flower-free-stock-photo-4.htm: //www.public-domain-photos.com/flowers/wet-flower-free-stock-photo-4.htm

When we apply Sobel Edge Detection it is going to detect the gradients on both left and right side of the petal. If we have a real high-resolution image of the flower the gradient is going to spread out and if we don’t, what we will get is a blurry edge. That is the best we could get out of a low-resolution image.

当我们应用Sobel Edge Detection时,它将检测花瓣左侧和右侧的梯度。 如果我们有花朵的真实高分辨率图像,则梯度会散开,如果没有,则将得到模糊的边缘。 那是我们可以从低分辨率图像中获得的最好结果。

Sobel Operator applied on the image
Sobel算子应用于图像
Canny Operator applied on the image
Canny运算符应用于图像

While the Canny Edge detector will remove all those rough blurry edges and will give you just the edge of the petal, exactly what we needed.

虽然Canny Edge检测器将去除所有这些粗糙的模糊边缘,并且只给您花瓣的边缘,而这正是我们所需要的。

The Canny edge detection algorithm is one of the most widely used in many computer vision and image analysis applications. It is extremely effective as well. It’s used, to name a few, are fingerprint matching, medical diagnosis, self-driving cars for lane detection, etc.

Canny边缘检测算法是许多计算机视觉和图像分析应用程序中使用最广泛的算法之一。 它也非常有效。 仅举几个例子,它用于指纹匹配,医疗诊断,用于车道检测的自动驾驶汽车等。

Let’s cut to the chase.

让我们开始追逐。

The process of this effective edge detection is broken down into:

有效边缘检测的过程分为:

  1. To smoothen the image we will be applying the Gaussian filter to reduce the noise in the image为了使图像平滑,我们将应用高斯滤波器以减少图像中的噪声
  2. Find the intensity gradients of the image查找图像的强度梯度
  3. Apply non-maximum suppression and double threshold to determine potential edges应用非最大抑制和双阈值以确定潜在边缘
  4. Tracking the edges finally by hysteresis.最后通过磁滞跟踪边缘。

Gaussian filter helps in removing the noise in the image. This noise then removed enables further processing to be smooth and flawless.

高斯滤波器有助于消除图像中的噪点。 然后消除的噪音使进一步处理变得平滑无瑕。

The smoothened image is then filtered by Sobel Kernel vertically and horizontally to get the first derivative which is (Gx). In the vertical direction, we will get our second derivative i.e (Gy). From this, we can now find the edge gradient.

然后,通过Sobel Kernel垂直和水平过滤平滑图像,以获得一阶导数(Gx)。 在垂直方向上,我们将得到二阶导数,即(Gy)。 由此,我们现在可以找到边缘渐变。

https://docs.opencv.org/trunk/da/d22/tutorial_py_canny.htmlhttps://docs.opencv.org/trunk/da/d22/tutorial_py_canny.html

Gradient direction is always perpendicular to edges. It is rounded to one of four angles representing vertical, horizontal and two diagonal directions

渐变方向始终垂直于边缘。 将其舍入为代表垂直,水平和两个对角线方向的四个角度之一

Non-maximum suppression can effectively locate the edge and suppress the occurrence of false edges. Once we get the gradient magnitude and direction, a full scan of an image is done to remove any unwanted pixels which may not be considered to be an edge. For this, at every pixel, the point is checked to see if it is a local maximum in its neighborhood in the direction of the gradient. Check the image below:

非最大抑制可以有效地定位边缘并抑制假边缘的发生。 一旦我们获得了梯度的大小和方向,就可以对图像进行全面扫描,以去除不需要的像素,这些像素可能不被视为边缘。 为此,在每个像素处,检查该点以查看其是否在梯度方向上在其附近是局部最大值。 查看下面的图片:

https://docs.opencv.org/trunk/da/d22/tutorial_py_canny.htmlhttps://docs.opencv.org/trunk/da/d22/tutorial_py_canny.html

Point A is on the edge ( in the vertical direction). The gradient direction is normal to the edge. Point B and C are located in the gradient direction. So point A is checked with point B and C to see if it forms a local maximum. If it does, then we can move to the next step, otherwise, it is suppressed (put to zero). The result you get is basically a binary image with thin edges.

点A在边缘上(在垂直方向上)。 渐变方向垂直于边缘。 点B和C位于梯度方向上。 因此,将A点与B点和C点进行检查,看是否形成局部最大值。 如果是这样,那么我们可以转到下一步,否则,它被抑制(置为零)。 您得到的结果基本上是边缘较薄的二进制图像。

Let’s move on to the next step.

让我们继续下一步。

We will now define the two thresholds: maxVal and minVal.

现在,我们将定义两个阈值:maxVal和minVal。

https://docs.opencv.org/trunk/da/d22/tutorial_py_canny.htmlhttps://docs.opencv.org/trunk/da/d22/tutorial_py_canny.html

Now we will use the higher threshold to start the edge curves and the lower threshold to continue them. Any edges with intensity gradient more than maxVal are sure to edge and those below minVal are sure to be non-edges, so they are discarded.

现在,我们将使用较高的阈值开始边缘曲线,并使用较低的阈值继续边缘曲线。 强度梯度大于maxVal的任何边缘必定为边缘,而低于minVal的那些边缘必定为非边缘,因此将其丢弃。

The ones that lie in between them are classified based on their connectivity.

介于它们之间的那些对象将根据其连接性进行分类。

Let’s take a look at the code:

让我们看一下代码:

Original Image:

原始图片:

I have chosen a picture of a butterfly. You can try it out on any image you wish to.

我选择了一张蝴蝶的照片。 您可以在任何想要的图像上尝试一下。

https://wsimag.com/economy-and-politics/61348-murder-and-the-monarch-butterfly//wsimag.com/economy-and-politics/61348-murder-and-the-monarch-butterfly

Firstly, import the necessary libraries and the image which we would be using.

首先,导入必要的库和我们将要使用的图像。

import cv2 as cvimport matplotlib.pyplot as pltimage=cv.imread('./Butterfly.jpg')

Now, let’s find the edges in the image using the Canny algorithm.

现在,让我们使用Canny算法查找图像中的边缘。

edges = cv.Canny(image, 100, 200, 3, L2gradient=True)plt.figure()plt.title('Butterfly')plt.imsave('Butterfly.jpg', edges, cmap='gray', format='jpg')plt.imshow(edges, cmap='gray')plt.show()

Results:

结果:

Canny edge detection applied to the image of the Butterfly
Canny边缘检测应用于蝴蝶图像

Conclusion:

结论:

An improved edge detection algorithm based on the Canny algorithm has replaced the traditional Gaussian function for denoising. We calculate the image gradient, non-maxima suppression as mentioned above. Based on the higher and lower threshold we decide how the edges are started and continued. It has proven to have a good anti-noise ability to improve the accuracy of edge detection.

一种基于Canny算法的改进的边缘检测算法已经取代了传统的高斯函数进行去噪。 我们如上所述计算图像梯度,非最大值抑制。 根据较高和较低的阈值,我们确定边缘的开始和继续方式。 它被证明具有良好的抗噪声能力,可以提高边缘检测的准确性。

You can refer to the following links below:

您可以参考以下链接:

https://aip.scitation.org/doi/pdf/10.1063/1.5005213

https://aip.scitation.org/doi/pdf/10.1063/1.5005213

https://ieeexplore.ieee.org/document/8265710

https://ieeexplore.ieee.org/document/8265710

翻译自: https://medium.com/@saisha892001/introduction-to-canny-edge-detector-add1a3a13ca1

canny edge


http://www.taodudu.cc/news/show-1873958.html

相关文章:

  • 迄今为止2020年AI的奋斗与成功
  • 机器学习算法应用_机器学习:定义,类型,算法,应用
  • 索尼爱立信k510驱动_未来人工智能驱动的电信网络:爱立信案例研究
  • ai驱动数据安全治理_利用AI驱动的自动协调器实时停止有毒信息
  • ai人工智能_古典AI的简要史前
  • 正确的特征点匹配对_了解如何正确选择特征
  • 在Covid-19期间测量社交距离
  • nlp gpt论文_GPT-3是未来。 但是NLP目前可以做什么?
  • ai人工智能软件_您应该了解的5家创新AI软件公司
  • 深度学习 个性化推荐_生产中的深度强化学习第2部分:个性化用户通知
  • opencv 识别火灾_使用深度学习和OpenCV早期火灾探测系统
  • 与Maggy统一单主机和分布式机器学习
  • 极速火箭网络助手怎么用_在检测火箭队方面,神经网络比灰烬更好吗? 如果是这样,如何?...
  • nlu 意图识别_在NLU中,您无视危险的意图
  • BERT-从业者的观点
  • 检测和语义分割_分割和对象检测-第4部分
  • 工业革命 书_工业革命以来最重大的变化
  • 实现无缝滑屏怎么实现_无缝扩展人工智能以实现分布式大数据
  • colab 数据集_Google Colab上的YOLOv4:轻松训练您的自定义数据集(交通标志)
  • 人工智能和机器学习的前五门课程
  • c语言儿童教学_五岁儿童的自然语言处理
  • 星球大战telnet_重制星球大战:第四集(1977)
  • ai人工智能的数据服务_建立AI系统的规则-来自数据科学家
  • 语音库构建_推动数据采用,以通过语音接口构建更好的产品
  • openai-gpt_GPT-3是“人类”吗?
  • 自动化运维--python_自动化-设计师的朋友还是敌人?
  • ai人工智能的数据服务_数据科学和人工智能如何改变超市购物
  • 游戏ai人工智能_AI与游戏,第1部分:游戏如何推动了两门AI研究流派
  • AI的帕雷多利亚
  • ai转型指南_穿越AI转型的转折点

canny edge_Canny Edge检测器简介相关推荐

  1. 7.边缘检测:2D运算——Canny边缘原理、Canny边缘检测器、Canny-Matlab实战_2

    目录 Canny边缘原理 Canny边缘检测器 Canny-Matlab实战 Canny边缘原理 既然我们知道了如何计算光滑导数和梯度,我们就可以回到如何找到边的问题上. 基本上这是一个多步骤的过程, ...

  2. 学习笔记-canny边缘检测

    Canny边缘检测 声明:阅读本文需要了解线性代数里面的点乘(图像卷积的原理),高等数学里的二元函数的梯度,极大值定义,了解概率论里的二维高斯分布 1.canny边缘检测原理和简介 2.实现步骤 3. ...

  3. SUMO/检测器设置(E3)学习总结

    一.E3检测器简介 Multi-Entry-Exit Detectors(E3)可以用来检测通过检测区域的平均速度.车辆通过检测区域的平均停车次数.车辆通过区域的平均延误.一段时间内进入检测区域车辆数 ...

  4. OpenCV 笔记(02)— 图像显示、保存、腐蚀、模糊、canny 边缘检测(imread、imshow、namedWindow、imwrite)

    OpenCV 提供两种用户界面选项: 基于原生用户界面的基本界面,适用于 Mac OS X 的 cocoa 或 carbon,以及适用于 Linux 或 Windows 用户界面的 GTK ,这些界面 ...

  5. Chromium 内核新款 Edge 浏览器对比评测,微软找回面子全靠它了

    近日微软在官网终于放出了基于 Chromium 内核打造的新款 Edge 浏览器,感兴趣的朋友可以"点击此处"进行下载.此前,有关微软将使用 Chrome浏览器内核打造全新 Edg ...

  6. 自动驾驶感知-车道线系列(二)——Canny边缘检测

    Canny边缘检测 前言 一.Canny是什么? 二.算法详细步骤 1. 平滑处理 2. 梯度检测 3. 非极大值抑制 4. 滞后阈值处理 三.函数原型 四.应用实例 五.总结 前言 边缘检测是图像处 ...

  7. 1.图像显示图像腐蚀图像模糊canny边缘检测视频操作调用摄像头

    今天是开始学习OpenCV的第一天,简单记录下,运气不错,环境配置一遍过,很舒服.主要使用简单快速上手下 显示图片 /*1.显示图片*/Mat srcimg = imread("1.png& ...

  8. 新Edge浏览器对比评测,微软找回面子全靠它了

    (给技术最前线加星标,每天看技术热点) 转自:中关村在线 根据外媒消息,Chromium芯的Edge浏览器可能会随Windows 10 20H1更新直接登陆Windows 10系统,并取代老款Edge ...

  9. Canny边缘检测算法(python 实现)

    文章目录 最优边缘准则 算法实现步骤 1. 应用高斯滤波来平滑(模糊)图像,目的是去除噪声 2. 计算梯度强度和方向 3. 应用非最大抑制技术NMS来消除边误检 4. 应用双阈值的方法来决定可能的(潜 ...

  10. 新版Microsoft Edge Chromium 内核浏览器简体中文 支持 win7 win8 win8.1 win10 macOS ios android...

    近日微软在官网终于放出了基于 Chromium 内核打造的新款 Edge 浏览器,感兴趣的朋友可以"点击此处"进行下载.此前,有关微软将使用 Chrome浏览器内核打造全新 Edg ...

最新文章

  1. 数据结构 - 静态单链表的实行(C语言)
  2. Application log handling when maintaining product sales area data COM_PRWB_SET_LOGSETTYPE
  3. 查看一个结构体成员的方法
  4. 2022国内低代码平台厂商排行榜—经典收藏
  5. 随想录(libc.so和ld.so调试)
  6. 计算机课程在线作业,计算机科学与技术作业答案
  7. 【操作系统/OS笔记20】打开文件、文件数据块分配、空闲空间管理、多磁盘管理(RAID)、磁盘调度算法概述
  8. BZOJ3073: [Pa2011]Journeys
  9. 190126每日一句
  10. CS231n李飞飞计算机视觉 神经网络训练细节part2上
  11. 【大数据之路-阿里巴巴大数据实践】第一篇 数据技术篇
  12. java动漫网站_基于SSM框架下的JAVA漫画展示系统
  13. IIS5 IIS6 IIS7区别
  14. 一套完整仿拉勾网HTML静态网页模板(含38个独立HTML)
  15. [笔记分享] [Camera] msm8926 camera hal 流程小结
  16. 芜湖计算机专业学校录取分数线,芜湖市各类高中2018年中考录取分数线是多少...
  17. 南方都市报:红心照耀MSN
  18. 新大陆云平台使用笔记
  19. nvm use出现乱码
  20. 查看CentOS的版本

热门文章

  1. 7款应用最广泛的Linux桌面环境盘点
  2. SQL Server数据导入导出的几种方法
  3. 第一章 SQL Server 2005概述文档信息
  4. C# 2.0泛型编程基础(1)
  5. C/C++ 内存四区模型
  6. orb特征描述符 打开相机与图片物体匹配
  7. Atitit 编程语言的类型系统 目录 1.2. 动态类型语言(Dynamically Typed Language): 1 1.3. 静态类型语言(Statically Typed Languag
  8. Atitit 减少财政支出之减少通讯支出 解决方案attilax总结
  9. Atitit.病毒木马的快速扩散机制原理nio 内存映射MappedByteBuffer
  10. Atitit. BigConfirmTips 控件 大数据量提示确认控件的原理and总结O9