Research on Improved Canny Edge Detection Algorithm

. Aiming at the poor noise robustness of traditional Canny algorithm and the defect of false edge or edge loss, an edge detection algorithm using statistical algorithm for filtering denoising and using genetic algorithm to determine the optimal high and low threshold of image segmentation is proposed. Firstly, statistical filtering uses mean and variance to denoise, avoiding the problem of Gaussian denoising susceptible to interference in the traditional Canny algorithm, and ensuring the integrity of image edge information. Secondly, this article uses the genetic algorithm, design the crossover operator and genetic operator to modify the evolution of the population, and determine the optimal height threshold of the image edge connection to make the threshold more accurate. Finally, using MATLAB software to simulate, the results show that the improved Canny edge detection algorithm can further improve the anti-noise ability and robustness, and the edge location is more accurate.


Introduction
Edge detection of images is one of the most fundamental aspects of image analysis and processing. With the rapid development of artificial intelligence, virtual reality, augmented reality and digital image technology, image edge detection technology has been applied to many fields [1]. Most of the traditional edge detection operators are based on the change of gray value between the neighborhoods of the pixels of the original image. The directional derivative in the mathematical processing method is applied to detect the edge. The overall structure of the algorithm is faster and simpler, and the speed of processing the image pixels is relatively fast, which may cause the noise reflection in the process to be sensitive [2]. Images that are subject to noise are difficult to understand in terms of images, resulting in edges that are not easily detected. Therefore, it is necessary to perform demising processing in the preprocessing stage of the image to reduce the influence on processing subsequent images.
Commonly used edge detection operators include Robert operator, Sobel operator, Prewitt operator and Gauss-Laplacian operator. Although these edge operators are simple in method, but the application scenarios are relatively few, they are all calculated in the vicinity of the pixel points, which are sensitive to noise and has poor detection effect [3]. Based on the in-depth study of the traditional Canny edge detection algorithm, this paper proposes an improved algorithm combining statistical filtering and genetic algorithm to reduce noise interference to some extent and improve the accuracy of edge location.

Traditional Canny edge detection algorithm
The traditional Canny edge detection algorithm is widely used due to its short operation time, relatively simple calculation process and better detection results than other edge detection operators. The steps can be basically divided into the following four steps [3]: (1) Smooth the image with a Gaussian function.
Gaussian filtering When σ is small, the positioning edge has high accuracy; when it is large, it may cause the image to be excessively smooth, lose some useful information, and increase the amount of calculation. Therefore, the smoothing parameter should be appropriately selected.
(2) The finite difference formula of the first-order partial derivative is used to calculate the amplitude and direction of the image gradient (Horizontal x G and vertical y G ), as well as the azimuth angle (3) Non-maximum suppression of the magnitude of the gradient, within a 3*3 window, the point at which the local gradient is greatest is retained.
(4) The double threshold is used for edge connection, and the high threshold low threshold is selected to further detect the edge obtained by the non-maximum suppression processing.
(5) Edge connection. The image edge contour is connected with the strong edge as a reference. When connecting to the end point of the image edge, the edge point that can be continued is searched for in the weak edge, thereby obtaining the complete edge information of the image.
The traditional Canny algorithm tends to oversmooth the noise, resulting in the loss of edge images or pseudo-edges, and the method of selecting thresholds is artificial, and the subjective factors are strong and computationally complex [3]. Based on the analysis of traditional algorithms and the improvement of traditional algorithms, this paper proposes an edge detection algorithm that uses statistical filtering to denoise and use genetic algorithm to determine the optimal high and low thresholds for image segmentation.

Using statistical methods for filtering and denoising
Noise problems exist in any image pre-processing. At present, image denoising algorithms have methods such as median filtering, wavelet transform denoising, and grey scale morphological denoising. However, it is sensitive to noise, and the denoising effect is not ideal, and even some image feature information is removed, which makes image processing difficult. Therefore, choosing an effective denoising algorithm is important for edge detection. In the traditional Canny algorithm, the first derivative of the Gaussian function is used. The noise belongs to the high-frequency signal, and the noise itself is orders of magnitude higher than the Gaussian function, so when the Gaussian function increases, the noise also increases exponentially. The Gaussian function is susceptible to noise interference, which blurs the edges of the image, and the Gaussian filtering algorithm has high complexity and low operating efficiency. The noise appearing in the image is a multidimensional stochastic process that can be processed with the relevant knowledge of statistical methods [4]. Therefore, in the improved algorithm, statistical filtering is used to replace the Gaussian filtering to reduce the influence of noise on the filtering function.
In the neighbourhood ω , the characteristics of the pixel transformation are reflected by the variance, and the noise is a multidimensional stochastic process that satisfies the statistical characteristics. The statistical properties of noise can be used to remove noise without introducing other extraneous properties to avoid new noise interference to the image. Therefore, using variance as a parameter for smoothing denoising can avoid the influence of external factors on smooth denoising [5].
Statistical filtering uses the mean and variance to filter and denoise. The basic process is to first determine When processing an image in the neighbourhood, it cannot be processed because there are no complete 3*3 neighbourhood around the edge of the image. Usually, white or black fills the area that cannot be processed. In the statistical filtering, the neighbourhood matrix is used to complement the circulate matrix by using the cyclic continuation, so that the entire image pixel can be filtered and denoised without using white or black complement regions [5].
After variance, and the filter function threshold value are respectively calculated and compared. If the absolute value is less than the product, the pixel value of the point is retained, that is, the point is considered to be less affected by the noise, otherwise the pixel value of the point is replaced by the mean of the neighbourhood, and that is, the noise is greatly affected [6].

Threshold selection based on genetic algorithm
The genetic algorithm based on Darwin's theory of evolution, Mendel's population genetics and Weizmann's species selection theory is a method to simulate the optimal solution of biological evolutionary processes. The basic idea of the algorithm is natural selection and survival of the fittest [8]. The basic implementation process is as follows: (1) Gene coding. The range of values (phenotype) to be solved is divided into k 2 segments according to the obtained precision, thereby forming a k-bit binary (genotype), and the mapping from phenotype to genotype is called encoding; (2) Initialized the population. Randomly generating N K-bit binary codes as an initial population; (3) Calculated the fitness function. Calculate the fitness function of the parent population of the current round, and the fitness function characterizes the superiority and inferiority of the individual; (4) Genetic manipulation. According to the fitness, the parent population is selected and cross-operated, and the generated progeny population is mutated. The genetically manipulated population will be used as the next parent population.
(5) End the judgment. If the individual of the population satisfies a certain performance index or reaches the specified genetic algebra, the evolution ends, otherwise it is repeated from step 3.
With the genetic algorithm has simple principle, it not only in parallel, but also the good self-organization and self-learning can be searched. Therefore, it has been widely used in the fields of optimization calculation, information processing and strategy planning [7]. However, the shortcomings of the basic genetic algorithm are also obvious: the degradation phenomenon in the search process will make the population diversity worse, the convergence speed slows down, and even the global optimal solution cannot be obtained [8]. In order to solve the above problems, this paper based on genetic algorithm, from the adjustment of crossover operator and mutation operator to improve, to achieve the optimal threshold selection.
1) Crossover operator The crossover operator uses the arithmetic cross method, and the two bodies individuals generated after the crossover operation.
In order to achieve adaptive adjustment of the number of bits and position of the crossover operator, the selection of the probability parameter θ satisfies the formula (2):      Figure 3. Improved Canny algorithm for detecting images.

Conclusions
This paper analyses the traditional Canny algorithm and finds the shortcomings of traditional algorithms. In terms of filtering and threshold selection, the traditional Canny algorithm is improved, and the mean and variance in the statistical method are used instead of Gaussian filtering. And the genetic algorithm is used to select the optimal threshold, and the crossover operator and genetic operator are improved to improve the accuracy of the algorithm. The improved algorithm and traditional algorithm simulation results show that the edge detection result of the algorithm is closer to the edge of the original image, and the algorithm denoising effect is improved. Therefore, the improvement of this paper is feasible and effective in edge detection.