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]]])

image 8-bit input image.
edges output edge map; single channels 8-bit image, which has the same size as image .
threshold1 first threshold for the hysteresis procedure.
threshold2 second threshold for the hysteresis procedure.
apertureSize aperture size for the Sobel operator.
L2gradient a 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 ).

猜你喜欢

转载自blog.csdn.net/Airfrozen/article/details/104450540