An Improved Canny Algorithm with Adaptive Threshold Selection

: Canny is a classic algorithm of edge detection which has been widely applied in various fields of image processing for years. However, the algorithm has some defects. The most serious defect is that the traditional canny algorithm can’t set threshold adaptively. If the threshold set manually is not accurate, it will seriously affect the quality of the algorithm to detect the edge. This makes the poor adaptability of the algorithm. This paper proposes a method which combines maximum entropy method with Otsu method to determine the high and low threshold of Canny algorithm. Experiments show that the modified algorithm has stronger robustness than traditional method. For the images which have complex distributions of grey level histogram, the modified algorithm has better performance.


INTRODUCTION
In image processing, the edge is the important information which reflects the feature of an image, and edge detection is the first step in image processing.Among the various edge detection algorithms, Canny algorithms has been widely used in scientific research and practical engineering projects because of its excellent performance since it was proposed in 1986.In recent years, people put forward many improving methods in view of the traditional Canny algorithms.Selection of threshold is an important factor that determines the Canny algorithm performance.The traditional canny algorithm can't set threshold adaptively, which makes the algorithm robustness weak.In some applications, the algorithms cannot be used directly.So the improvements of this aspect have been the focus in the study of edge detection.
We can use the image segmentation methods to select high and low threshold of Canny algorithm.In the field of image segmentation, there are a lot of methods, such as, histogram method, maximum entropy method, Otsu method and so on [1].Otsu method determines the segmentation threshold by calculating interclass variance, which is a kind of classic method of image segmentation.For the image that has a simple distribution of grey level histogram, Otsu method can calculate the segmentation threshold effectively.But for the image that has a complex distribution of grey level histogram, the accuracy of the algorithm will decrease, unable to segment image effectively [2].Maximum entropy method utilizes entropy which is an important concept of information theory to segment image.For the image that has a complex distribution of grey level histogram, maximum entropy method is more effective than Otsu method [3].
For the defect of Canny algorithm that cannot de-termine the high and low threshold automatically.This paper proposes a method that combines maximum entropy method with Otsu method.Solving the defect that Otsu method cannot calculate the correct threshold in the image greatly improves the robustness of the algorithm.The image divided into three categories both calculates the high threshold and dual threshold which effectively improves the quality of the edge of image.Experimental results show, the improved algorithm can detect the image edge details effectively and have better performance than other methods.

TRADITIONAL CANNY EDGE DETECTION
The traditional Canny algorithm is a classic algorithm of image processing.Since it was brought up by John F. Canny in 1986, Canny algorithm has been applied to image processing in industrial and many other areas because of its excellent performance.It is also an important method for edge detection in machine vision.Canny also defines three performance criterions to evaluate the edge detection algorithms, which are: (1) Good detection performance.Ensure that do not determine the pseudo edge as real edge, and not miss the real edge.This criterion corresponds to maximizing signal-to-noise ratio (SNR).The mathematical expression of signal-to-noise ratio is: (2) Good localization.Ensure that the points marked as edge points by the operator should be as close as possible to the center of the true edge.The An Improved Canny Algorithm with Adaptive Threshold Selection Yupeng Wang & Jiangyun Li* School of Automation & Electrical Engineering, University of Science and Technology Beijing, Beijing, China ABSTRACT: Canny is a classic algorithm of edge detection which has been widely applied in various fields of image processing for years.However, the algorithm has some defects.The most serious defect is that the traditional canny algorithm can't set threshold adaptively.If the threshold set manually is not accurate, it will seriously affect the quality of the algorithm to detect the edge.This makes the poor adaptability of the algorithm.This paper proposes a method which combines maximum entropy method with Otsu method to determine the high and low threshold of Canny algorithm.Experiments show that the modified algorithm has stronger robustness than traditional method.For the images which have complex distributions of grey level histogram, the modified algorithm has better performance.

Keywords
(3) Only one response to a single edge.Ensure that each edge point only has one response, and inhibits pseudo edge.The mathematical expression is: According to the three criteria, we can calculate an optimal approximate solution.It can use a one-ordered derivative of a two-dimensional Gaussian function to approximate [4].

ALGORITHM STEPS
Canny algorithm mainly can be divided into the following four steps: (1) Image smoothing by Gaussian function Considering the Gaussian smoothing filter is linearly separable, it can be divided into two parts.Therefore, we can do convolution with a Gaussian smoothing filter in order to smooth the image according to the row and column respectively.The mathematical expression of Gaussian smoothing filter is: V is the standard deviation of Gaussian smooth- ing filter, and it controls the degree of smooth.If the value of V is small, it will lead to good localization and lower SNR.If the value of V is big, it will low- er the location accuracy, but obtain less noise.The image after smooth is: , , , , , f x y is the original image, and , I x y is the image after filtering.
(2) Calculating the value in the direction of gradient The algorithm adopts first order limited difference of 2 2 u neighboring area to calculate the horizontal direction derivative P x and vertical direction derivative P y , and the mathematical expression of P x and P y is: Then, we use the partial derivative above to calculate the value of gradient , M i j and the direction of gradient , i j T , and the mathematical expression is: , , arctan , (3) Non-Maxima Suppression (NMS) Considering that the gradient image cannot ensure edges of an image and in order to satisfy the third criterion of Canny which is only one response to a single edge, we need to refine the value of image gradient in the fastigium strip, and retain the points changed mostly in local.The algorithm adopts 3 3 u neighboring area to carry on interpolation to the value of gradient along gradient's direction aiming to each value in array , M i j .If the point of the center of the area is bigger than the two points on the gradient's direction, then the pixel is not a local maximum, and mark it as 0 which represents it is not an edge point.On the contrary, the point may be an edge point.
(4) Connecting edges with dual threshold method In order to reduce the false edge as much as possible, we need to process the image with dual threshold method.Traditional Canny algorithm set two thresholds by experience, and we must determine the low threshold l T and high threshold h T needed in the algo- rithm.First, detect each point in the image.If the value of the gradient of point , i j is bigger than the high threshold h T , this point is an edge point.Then we get edge map 1 , T i j .And if the value of the gradient of point , i j is smaller than the low threshold l T , this point is not edge point.If the value of the gradient of point , i j is bigger than l T and smaller than h T , then we get edge map 2 , T i j .Pixel in 1 , T i j does not contain false edge points, but has intermittency on the contour.So we need to make connection points of 1 , T i j as outline.When faced with discontinuous endpoints, we find edge in 2 , T i j at location in 8 neighborhood.In this way, we can connect discontinuous edge points through the recursive tracking [5].

DEFECTS OF ALGORITHM
Four steps described above are all the process of Canny algorithm.Easy to find, the traditional algorithm has the following problem: The edge of the image is determined by the high and low threshold.So the selection of threshold is important to decide whether we can detect the right Web of Conferences MATEC image edge.But the traditional Canny algorithm can't set threshold adaptively, which makes the algorithm robustness weak.
If the threshold determined is not reasonable, it can't reflect the actual characteristics of the image.At this time, there will be the problems of missing edge and detecting the false edge.Canny algorithm can't display normal performance.And the algorithm which can't set threshold adaptively has a great influence for the actual engineering projects.So the improvement in this area is very important to promote the performance of the Canny algorithm.

MODIFIED CANNY EDGE DETECTION AL-GORITHM
The most serious defect of traditional Canny algorithm is that it can't set threshold adaptively.This defect makes the algorithm robustness weak.Therefore, this paper improves the traditional Canny algorithm mainly from this aspect.In recent years, there are a lot of methods in the field of image segmentation, such as, histogram method, maximum entropy method, Otsu method and so on.Maximum entropy method and Otsu method is the important methods of image binaryzation.In the literature [6], they used Otsu method to calculate dual threshold of Canny algorithm.Based on the gradient histogram of the image instead of the image grey value histogram to calculate high threshold of the Canny algorithm, and obtain the edge map [7].But this algorithm only fits for the condition of image whose gradient amplitude histogram has clear bimodal.In the actual, there are very few images that have the conditions above.Their gradient amplitude histogram has a high peak in the left.According to the situation above, this paper proposes a new method that combines maximum entropy method with Otsu method.
Otsu method is an automated non-parametric unsupervised threshold selection method put forward by a Japan scholar in 1979.The algorithm is also known as the maximum between-cluster variance method.The algorithm uses the least squares method to calculate the high threshold with gray histogram information, which is the best segmentation threshold in statistics and a stable threshold segmentation algorithm.The basic idea is: the image pixel information is divided into two categories: background and target.It determines the optimal threshold by calculating the maximum of between-cluster variance of the two categories.
For an image, the number of pixels is N, the range of gray levels is > @ 0, 1 L , gray level i corresponding to the number of pixels is i n , and i p is probability of gray level i, so we have: The image is divided into two categories of back-ground and target through threshold k.They are o C and 1

C . o
C is the background, and it is consisted of pixels whose grey level is between > @ 0, k . 1 C is the target, and it is consisted of pixels whose grey level is between > @ 1, 1 k L [8].So we can calculate the mean value of the whole image: The mean value of o C and 1 C are: The average gray value of whole image is: The between-cluster variance of background and target can be represented as: The basic idea of Maximum entropy method is utilizing entropy which is an important concept of information theory to image segmentation.Similar to Otsu method, the image is divided into two categories, calculating the two categories' entropy separately.The higher the grey value of this category changes, the smaller the entropy is.In the opposite, the lower the grey value of this category changes, the bigger the entropy is.Select a threshold k in gray level set > @ 0, 1 L .When the two categories have a maximum entropy, k is the threshold we select.The entropy of background and target is defined as follows: The entropy of whole image is: By the equation ( 23), the essence of between-cluster variance of background and target is the weighted sum of as far as possible.This is the basic idea to determine whether a pixel is the threshold in the Otsu method, and it can be written as the following equation: Similar to equation (23), equation ( 26) can also reflect the distance of between-cluster distance of two categories [9].For the image whose grey value histogram has clear bimodal, the result of image segmentation using Otsu method is accurate enough.But in fact, grey value histogram of many images does not have clear bimodal, and the distribution of grey value histogram is very complex.Therefore, we can calculate between-cluster entropy instead of between-cluster variance.Then for most images, the algorithm is able to calculate the threshold accurately.Compared to Otsu method, to some extent, it improves the robustness.The equation is as follows: Equation ( 29) shows that the percentage of pixels which is not edge when we select the threshold k.Equation (30) shows that the percentage of pixels which is not edge when we select the threshold m.Utilizing the gradient amplitude histogram of image combined with l G and h G , We can calculate the high and low threshold of Canny algorithm.Equations are as follows: Where, i s is the probability of the pixels occurred whose value of gradient is i.The least value of l T and h T are the threshold we needed which satisfy the equation (31) and equation (32).

EXPERIMENTS AND ANALYSIS
To verify the validity of the modified algorithm, we program the algorithm using MATLAB R2014a to test the validity of this paper's algorithm.We use traditional Canny algorithm, Canny algorithm with Otsu method and the modified algorithm in this paper to perform the following simulation respectively.For traditional Canny algorithm, unified selected 0.8 as the percentage of pixels which is not edge, and 0.4 times of low threshold to high threshold.We use two gray level images to test these algorithms.The size of the image is 512 512 u and every pixel is 8bits.The distribution of grey level histogram is different, and it's the curve of the nuclear magnetic image's grey level histogram tilted to a side.The following is the result of simulation, the upper left is the original image, the upper right is the result obtained by the traditional Canny algorithm, the lower left is the result obtained by the Canny algorithm with Otsu method, and the lower right is the result obtained by the modified algorithm in this paper.
High and low thresholds calculated by these algorithms above are shown in table 1.We also calculate the proportion of high and low thresholds.
The running time of the algorithm are shown in the Table 2.

Web of Conferences MATEC
01017-p.4 If we want to obtain the best threshold, we need to make the distance between

Figure 1 .
Figure 1.Edge detection effect of lena image : edge detection; adaptive threshold; maximum entropy method; Otsu method; Canny algorithm DOI: 10.1051/ C Owned by the authors, published by EDP Sciences, 2015 '