OpenCV: Canny Edge Detector

摘自https://docs.opencv.org/4.2.0/da/d5c/tutorial_canny_detector.html

摘自https://docs.opencv.org/4.2.0/dd/d1a/group__imgproc__feature.html#ga04723e007ed888ddf11d9ba04e2232de

The Canny Edge detector was developed by John F. Canny in 1986. Also known to many as the optimal detector, the Canny algorithm aims to satisfy three main criteria:

  • Low error rate: Meaning a good detection of only existent edges.
  • Good localization: The distance between edge pixels detected and real edge pixels have to be minimized.
  • Minimal response: Only one detector response per edge.

Steps

  1. Filter out any noise. The Gaussian filter is used for this purpose.

  2. Find the intensity gradient of the image. For this, we follow a procedure analogous to Sobel.

  3. Non-maximum suppression is applied. This removes pixels that are not considered to be part of an edge. Hence, only thin lines (candidate edges) will remain.

  4. Hysteresis: The final step. Canny does use two thresholds (upper and lower): If a pixel gradient is higher than the upper threshold, the pixel is accepted as an edge. If a pixel gradient value is below the lower threshold, then it is rejected. If the pixel gradient is between the two thresholds, then it will be accepted only if it is connected to a pixel that is above the upper threshold. Canny recommended a upper:lower ratio between 2:1 and 3:1.

edges=cv.Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]])

image8-bit input image.
edgesoutput edge map; single channels 8-bit image, which has the same size as image .
threshold1first threshold for the hysteresis procedure.
threshold2second threshold for the hysteresis procedure.
apertureSizeaperture size for the Sobel operator.
L2gradienta flag, indicating whether a more accurate L2 norm = sqrt[(dI/dx)^2+(dI/dy)^2]should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default L1 norm =|dI/dx|+|dI/dy| is enough ( L2gradient=false ).
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值