Analysis of the grammatical principle of canny operator

The Canny operator Canny edge detection operator is a multi-level edge detection algorithm developed by John F. Canny in 1986. More importantly, Canny created the ComputaTIonal theory of edge detecTIon to explain how this technology works.

The Canny algorithm contains a number of parameters that can be adjusted, which will affect the timing and effectiveness of the algorithm's calculations.

The size of the Gaussian filter: The smoothing filter used in the first step will directly affect the results of the Canny algorithm. Smaller filters produce less blurring, which allows for the detection of smaller, significantly changing thin lines. Larger filters also produce more blurring effects, applying a larger area of ​​the image to the color value of a particular point. The result is more useful for detecting large, smooth edges, such as the edges of a rainbow.

Threshold: Using two thresholds is more flexible than using one threshold, but it still has a common problem with thresholds. If the threshold is set too high, important information may be missed; if the threshold is too low, the information will be important. It is difficult to give a common threshold that applies to all images. There is currently no proven implementation.

The Canny algorithm is suitable for different situations. Its parameters allow adjustments to be made to identify different edge characteristics depending on the specific requirements of the different implementations. It may be too slow to use for real-time image processing on a PC, especially if a large Gaussian filter is used. However, when we discuss computing power, we must also consider that as the processor speed continues to increase, it is expected that this will not become a problem in the next few years.

Analysis of the grammatical principle of canny operator

1. Canny edge detection basic principle

(1) Image edge detection must satisfy two conditions: one can effectively suppress noise; the second must accurately determine the position of the edge.

(2) According to the measurement of the signal-to-noise ratio and the positioning product, the optimal approximation operator is obtained. This is the Canny edge detection operator.

(3) Similar to the Marr (LoG) edge detection method, it also belongs to the method of first smoothing and then deriving the derivative.

2. Canny edge detection algorithm:

Step1: smoothing the image with a Gaussian filter;

Step2: Calculate the magnitude and direction of the gradient using the finite difference of the first-order partial derivative;

Step3: non-maximal suppression of the gradient amplitude;

Step4: Detect and join edges with a double threshold algorithm.

Step1: Gaussian smoothing function

Analysis of the grammatical principle of canny operator

(Understand the definition of convolution function on Wikipedia, as shown in the following figure, the red window that moves represents our Gaussian and function, and the blue is the image grayscale function)

Analysis of the grammatical principle of canny operator

Analysis of the grammatical principle of canny operator

Analysis of the grammatical principle of canny operator

Generate a template of k*k by a Gaussian function such as 3*3

Analysis of the grammatical principle of canny operator

Use this template to weight the average of each pixel

Step2: First-order differential convolution template

Analysis of the grammatical principle of canny operator

Step3: non-maximum suppression of gradient amplitude

Simply obtaining a global gradient is not sufficient to determine the edge, so to determine the edge, the point with the largest local gradient must be preserved while the non-maximum value is suppressed. (non-maxima suppression, NMS)

Solution: Use the direction of the gradient.

Analysis of the grammatical principle of canny operator

Figure 1 non-maximum suppression

The four sectors are numbered 0 to 3, corresponding to the four possible combinations of 3*3 neighborhoods. At each point, the center pixel M of the neighborhood is compared to two pixels along the gradient line. If M's gradient value is not greater than the two adjacent pixel gradient values ​​along the gradient line, let M=0.

which is:

Analysis of the grammatical principle of canny operator

Step4: Detect and join edges with a double threshold algorithm:

Two thresholds th1 and th2 are applied to the non-maximum suppression image, and the relationship between them is th1=0.4th2. We set the gray value of the pixel whose gradient value is smaller than th1 to 0 to obtain image 1. Then, the gradation value of the pixel whose gradient value is smaller than th2 is set to 0 to obtain image 2. Since the threshold of image 2 is higher, most of the noise is removed, but useful edge information is also lost. Image 1 has a lower threshold and retains more information. We can use image 2 as a supplement and image 1 as a supplement to link the edges of the image.

The specific steps of the link edge are as follows:

Scan image 2, when encountering a non-zero grayscale pixel p(x, y), trace the contour with p(x, y) as the starting point until the end point of the contour q(x, y) .

The 8 adjacent regions of the point s(x, y) corresponding to the position of the q(x, y) point in the image 2 in the image 1 are examined. If a non-zero pixel s(x, y) exists in the 8 neighborhoods of the s(x, y) point, it is included in the image 2 as the r(x, y) point. Starting with r(x,y), repeat the first step until we can't continue in both Image 1 and Image 2.

When the link to the outline containing p(x,y) is completed, the outline is marked as having been accessed. Go back to the first step and look for the next contour. Repeat steps 1, 2, and 3 until you cannot find a new outline in Image 2.

3. canny algorithm program implementation

In the Canny algorithm program, the above four steps are further subdivided into the following seven steps:

l Generate Gaussian filter coefficients;

l Smoothing the original image with the generated Gaussian filter coefficients;

l Find the gradient of the filtered image;

l Perform non-maximum suppression;

l Statistical histogram of the image to determine the threshold;

l Use the function to find the starting point of the boundary;

l According to the result of step 6, starting from a pixel, searching for all boundary points of a boundary of a boundary starting from the pixel as a boundary starting point;

MTU Diesel Generator

MTU Diesel Generator assembly by MTU diesel engine, alternator, radiator, controller, base frame;

. World Famous diesel engine brand: MTU

. World famous AC alternator brand: Stamford, Leroy Somer, Mecc Alte, Marathon, Faraday, SWT

. World famous genset controller brand: Deepsea, ComAp, Deif, SmartGen,

. Good Quality Cooling Radiator

. Start Battery system

Mtu Generator,Mtu Power Plant,Mtu Diesel Generator,Mtu Power Generator

Guangdong Superwatt Power Equipment Co., Ltd , https://www.swtgenset.com