A Study and Improvements on Canny Algorithm

This paper studies principle of the traditional Canny edge detection algorithm and the existing problems. Some solutions toward the problems are also proposed. The improvement methods consisted of two parts. On the one hand, as Canny edge algorithm itself does not have strong noise immunity while ensuring edge positioning accuracy, an adaptive median filter denoising program based on the Canny Gaussian filter is proposed to enhance the Canny algorithm filter performance. On the other hand, given the Canny algorithm high and low threshold parameter is not determined by the feature information of the image edge, but rather set manually which does not have the adaptive ability, this paper proposes an adaptive threshold setting scheme for high and low thresholds to improve the adaptive ability of Canny algorithm to different images.


Introduction
The image edge information is important both for human being and machine vision.Edge has many advantages such as shaping an area, being defined partially, and delivering most image information, therefore, edge detection can be seen as the key to deal with many complex problems [1].The meaning of edge is reflected in the mutation of grayscale.There are various geometric forms of gray-scale mutations, and the most common one is the laplace domain edge.When considering the influence of the fuzzy, the laplace edge will change as shown in Fig 1.So far there are many kind of edge detection method: Roberts, Prewitt, Sobel, Laplacian and so on.But as the edge detection problem is relatively complex, and edge and noise are high frequency signal, it is difficult to trade-off between noise and edge to make these methods achieve good results in the characteristics of anti-noise and edge positioning.Moreover, the changes of the target and background of each image are different, how to realize the automatic detection of image edge has become an increasingly important issue accordingly.Among all the existing edge detection algorithms, Canny algorithm is a good one and is widely used.The main contribution of Canny algorithm is the deduction of the optimal edge detection operator.The characteristics of edge detection operator includes [2] (1) Low misjudgment rate, namely as little as possible to misjudge the edge points as non-edge points.(2) High positioning precision, refers to accurately locate the edge points at the pixel which has the biggest gray change.(3) Inhabitation of the false edge.This paper analyzes the advantages and disadvantages of traditional Canny algorithm, and proposes the improvement solutions toward existing problems of this algorithm.

The Principle and Existing Problems of Canny Algorithm
The Principle and Advantages of Canny Algorithm.The procedure of Canny algorithm is as follow [3]: (1)Smooth the image by using Gaussian function.Let Gaussian function: A x, y x y  Then A reflects edge strength, and α is the direction perpendicular to the edge.
(3)Determine whether a pixel is an edge point: ① The edge strength of pixel (x, y) is greater than that of two adjacent pixels in the gradient direction.② The angle with two adjacent pixels in the gradient direction is less than 45 degree.③ The maximum value of edge strength in the 3 × 3 neighborhood area centered with this pixel is less than a threshold.It is verified by previous experiments that Canny algorithm is better than such edge detection algorithms as Roberts, Prewitt, Sobel, etc., because Canny algorithm can reduce the edge interruption in image detection and is favorable to get a relative complete edge.The Existing Problems of Canny Algorithm.The practical application problems of Canny algorithm can be divided into two parts: (1) The contradiction between the noise smoothing capabilities and the accuracy of edge position of Canny algorithm.The main purpose of image smoothing is to improve the signal to noise ratio and to eliminate noises.However, with Canny algorithm, when Gaussian is used to smooth the image, the larger the Gaussian space coefficient σ values is, the lower the edge positioning accuracy will be.Therefore, the slowly varying edge will also be lost during the non-maxima suppression, as part of the edges as high-frequency components will be smoothed out and part of edges are likely to become slowly varying ones.If the value of Gauss space coefficient σ is small, the edge positioning accuracy will be high enough to smooth the weak noise, but the ability to smooth strong noise will be lost.
(2) The gradient's high and low thresholds which used in Canny algorithm to detect edges are completely obtained by manual work, and cannot realize the adaptive detection to different images.The high threshold controls the starting point of edge detection in gradient map.The smaller the high threshold, the more the edge information remaining, and the more sophisticated the target edge is.However, the mixed pseudo edges will increase as well.With the increase of high threshold, the false edges can be effectively suppressed, but the edge information will be lost.The smaller the low threshold, the more the edge information remained and the more continuous the edge is.With the increases of low threshold, the visible target edge characteristics decrease, and the edge appears broken [4].As can be seen above, if the high and low thresholds are set manually, the influences upon the effect of edge detection will be marvelous.One is that the automation cannot be achieved.The other is that the local characteristics information of the image cannot be taken into account, because the local noise cannot be eliminated and the local edge with slowly changing gray value may lost, which leads to the discontinuous of target's contour edge.

206
Information Technology for Manufacturing Systems III As these problems affect the application of Canny algorithm in a large extent, this article addresses some ideas to improve the Canny algorithm.With these ideas, following objectives can be realized: ① to achieve a balance between edge positioning accuracy and noise suppression effect.② to achieve the self-adaptive determination of high and low thresholds of edge detection to further improve the effect of the edge detection of Canny algorithm .

Proposed Improvements to Canny Algorithm in this Paper
Improvements in Smoothing Filtering.After studed various research toward image smoothing algorithm, this paper proposes an adaptive median filter based on the traditional Canny Gaussian filter.The procedure is as follow: First, smooth the weak noise in the image by using Canny Gaussian filter.Second, remove the strong noise in the image by using adaptive median filtering.
The median filtering has the following characteristics: (1) It remains unchanged to monotonically increasing or monotonically decreasing sequences ( ) and the step sequence ( , , , , , ,  c c c d d d , where c d ≠ ).In other words, the input signal is the same as the output one.
(2) It can be used to remove random noise, pulse interference and other types of strong noise.Taking into account the case of strong noise density that when density of the strong noise of image changes, a relative serious distortion may occur if the same size of the filter window is used in filtering.Therefore, this paper use the adaptive median filtering [5], which algorithm is as follows : Name ij A as the current filter window center point (i,j) and ij f as to-be-filtered gray value f (i,j).
Let min f , max f and med f stand for the minimum, maximum and median grey value of window ij A respectively, and max A stands for the maximum allowed window.The basic procedure is as follows: (1) , then go to step (2).Otherwise, increase the size of window ij A .If the size of ij A is smaller than that of max A , then repeat step (1).Otherwise, output ij f . ( , then output ij f .Otherwise, output med f .The improvements in Setting of High and Low Threshold Values.Improvements are as follows: First, perform non-maxima suppression on the filtered images, and describe its gradient histogram NMS (i).Second, after analysing NMS (i), the high and low thresholds should be selected from the smooth area between the background peak and the first edge peak.The determination of high threshold high TH can be divided into three steps: Step 1: Make difference of adjacent two points in the gradient magnitude of the gradient histogram NMS (i), and then differential histogram Diff (i) can be get.The expression of Diff (i) is: Step 2: After making difference, the smooth area between the background peak and the first edge peak in NMS (i) is transferred into a zero-crossing point set in Diff (i).In this paper, the gradient amplitude of the last zero-crossing point in this collection is selected as the high threshold high TH .
The part greater than high TH is absolute edge and the part smaller than high TH is non-absolute edge.
Step 3: Perform Otsu [6] method to the category of non-absolute edge to calculate the low-threshold low TH .Thus, the adaptive setting of high and low thresholds for edge detection is finished.
Step 4: Use the following boundary tracking algorithm to complete the connection of edge points.First, take point whose gradient value is higher than high TH and set it as the absolute edge point which is the starting point of edge connection.Second, determine whether there is any other absolute edge Advanced Engineering Forum Vols.6-7 207 point within eight point neighborhood area.If yes, then the point is connected as edge point.If no, then turn to judge whether there are any point whose gradient value is higher than low TH .If yes, this point is also connected as edge point.After all the absolute edge points are processed, the edge connection is finished and the edge detection process is also completed.

Experimental Results
Analysis.In this paper, a grayscale image with strong noise is selected.The edge detection is performed by using Matlab as shown in Fig 2 .Fig. 2 It can be seen from the figure, the traditional Canny edge detection algorithm is better than other edge detection algorithm as Roberts, as Canny edge detection algorithm can obtain more complete edge.However, while ensuring the accuracy of edge positioning, the traditional Canny algorithm itself is lack of suppression to strong noise.Its high-and low-threshold values are set manually and it is lack of adaptability.After improvements, the effect of edge detection of Canny algorithm has been improved significantly.

Conclusion
Majority of main information of an image is in its edge, while there is a strong contrast in the neighborhood gray scale of the edge pixel.Therefore, edge is the most essential basis for image segmentation.This paper analyzes the principle and problems of traditional Canny edge detection algorithm, then, puts forward the corresponding improvement measures to those problems, and finally, confirm the effectiveness of the proposed methods to improve algorithm through Matlab experiments.This study has referential significance for the general gray-scale image edge detection.