3、edge detection

The purpose of edge detection is to significantly reduce the data size of the image while retaining the original image attributes. There are currently many algorithms for edge detection. Although the Canny algorithm is old, it can be said that it is a standard algorithm for edge detection and is still widely used in research.

Canny edge detection is a technology that extracts useful structural information from different visual objects and greatly reduces the amount of data to be processed. It has been widely used in various computer vision systems. Canny found that the requirements for edge detection on different vision systems are relatively similar. Therefore, an edge detection technology with broad application significance can be implemented. General standards for edge detection include:

 

  1. Detect edges with a low error rate, which means capturing as many edges as possible in the image as accurately as possible.
  2. The detected edge should be accurately positioned at the center of the real edge.
  3. A given edge in the image should be marked only once, and where possible, noise in the image should not produce false edges.

 

To meet these requirements, Canny uses the calculus of variations. The optimal function in the Canny detector is described by the sum of four exponential terms, which can be approximated by the first derivative of the Gaussian function.

Among the currently commonly used edge detection methods, the Canny edge detection algorithm is one of the strictly defined methods that can provide good and reliable detection. Because it has the advantages of meeting the three criteria of edge detection and being simple to implement, it has become one of the most popular algorithms for edge detection.

The Canny edge detection algorithm can be divided into the following 5 steps:

  1. Use Gaussian filter to smooth the image and filter out noise.
  2. Calculate the gradient intensity and direction of each pixel in the image.
  3. Apply non-maximum suppression to eliminate spurious responses caused by edge detection.
  4. Apply Double-Threshold detection to determine real and potential edges.
  5. Finally complete edge detection by suppressing isolated weak edges.

The code was run on jupyterlab

Compare two pictures

Code path: /home/pi/Yahboom_Project/1.OpenCV course/03 Image processing and drawing text line segments/03_2 Edge detection 2.ipynb