An Adaptive Threshold Canny Edge Detection Method for Applications with Simple Background

Edge detection is an important image processing problem with many practical applications in diﬀerent ﬁelds. While many methods have been proposed, further improvements still need to be made for speciﬁc applications. This paper focuses on the application of Canny edge in the image with a simple background, proposed an adaptive threshold Canny edge detection method. Considering the distribution of the object and the solid-color background, a pixels intensity statistic is operated for the corresponding gray image. In this way, the double thresholds are determined by analyzing the statistical result. Furthermore, to verify the eﬀectiveness of the proposed method, experiments are done on images that are taken with diﬀerent conditions. The result shows that Canny edge can be well detected by utilizing the two adaptive threshold values and have strong robustness to diﬀerent conditions. Particularly in the applications, such as object detection and image segmentation, the adaptive threshold Canny edge detection method plays a meaningful role.


Introduction
Thanks to technological developments, digital image processing is applied in various fields. (1), (2)Edge detection, which can find the boundaries of objects within images, is a fundamental and long-stand image processing problem and has become one of the widely explored topics.Particularly in areas such as object detection (3) and image segmentation, (4) reliable edge can provide powerful information in practical applications.
Given the importance of edge detection, the last decades has seen dramatic advance.And there are many methods (5), (6) for edge detection.Most of these methods can be grouped into two categories, search-based (7) and zero-crossing-based. (8) The search-based methods detect edge by utilizing the first-order derivative expression, while the zero-crossing-based method detects edge according to the second-order derivative expression.These methods can perform well in simple scenes with controllable illumination conditions.However, for scenes where the illumination condition are affected by some factors and cannot be controlled, these edge detection methods become unstable. (9)Therefore, to better apply these methods to practical applications, it is necessary to modify them according to the specific requirements.
In addition, the edge is detected according to the difference between adjacent pixels. (10)For different applications, it is always necessary to do some experiments to determine the gap of intensity.And the critical difference gap in edge detection is always defined as the threshold. (11)Too large threshold causes some weak edges cannot be detected, while too small threshold causes noises are detected as edges.In this way, how to find a suitable threshold is important for edge detection.Especially for some applications where the illumination cannot be controlled, how to set adaptive thresholds for changeful illuminations is the key issue.
Comparing several commonly used edge detection methods, including search-based and zero-crossing-based methods, the Canny edge detector (12) has shown advantages in solving noise and obtaining high-quality edges.Especially for applications with simple background, it is well handle the intensity changing in the background and ensure the continuity of object boundaries.This paper aims to apply the Canny edge detection method in applications with a simple background, proposed a method to adaptive determine the double thresholds.Since the background is solid color while the object is colorful, the distribution of object and background is regular.The intensity of the background is concentrated, while that of objects is scattered.In this way, the double thresholds can be set according to the distribution of background.By analyzing the statistical result of pixels' intensity in the image, the mode is the average value of the background.Thus, the double thresholds can be determined by setting a relative distance from the mean value of the background.Without the requirement of manually setting the double thresholds, the Canny edge detection method can be used for practice applications easily.Moreover, it can well adapt to the change of the background.

Classical Canny Edge Detector
In 1986, John F. Canny proposed the classic Canny algorithm, (13) which detects edges by utilizing the second-order derivative expression.Since the excellent performance, it is widely used to provide edge information for many industrial applications.Different from other filter-based methods, this method can well eliminate the influences of noise and pseudo edge.The detection of edge is implemented through four steps: • Blurring the image by Gauss algorithm; • Calculating the value and direction of the gradients; • Selecting candidate edge pixels; • Checking and connecting edge pixels.
Before calculating the gradients, the Gaussian blur operation (14) can effectively eliminate the influence of noise.To avoid pseudo edges being detected and ensure that only one pixel response to the single edge, candidate edge pixels are selected out by non-maxima suppression.Moreover, double thresholds are set to reduce the false edges detection as much as possible.

Adaptive Threshold Based on Otsu
The double thresholds are the reference values to determine whether a pixel is an edge.Therefore, they are important to detect edges.And the double thresholds are usually set according to experiments.However, since the various illuminations have a great impact on the image's color, constant thresholds always cannot satisfy the changing of illumination.Therefore, adaptively setting the double thresholds is a good solution to applications that cannot well control the illumination.
Otsu algorithm (15) is one of the most popular methods to adaptive determine threshold.This method first computes the histogram and probabilities of each intensity level, and then searches the possible threshold by minimizing the intraclass variance. (16)In this way, all the pixels in the image are separated into two classes.Otsu algorithm performs well when the histogram has a bimodal distribution with a deep and sharp valley between the two classes.However, for applications with a small object or a colorful object in the image, no two peaks in the histogram.This makes it difficult for the Otsu algorithm to carry out a suitable threshold to accurately separate the image into two classes. (17)

Proposed Adaptive Threshold Method
Targeting applications with a simple background that is a solid color, this paper proposed an adaptive threshold method for Canny edge detection.In this way, the excellent Canny edge detection method can be used to detect and segment the object from the image in a simple and automatic way for various industry applications.
Inspired by the Otsu algorithm that determines the threshold according to the distribution of pixels' intensity, this paper first makes a statistical analysis about the intensity of pixels in the corresponding gray scale image to find the mean value of the background, and then determine the double thresholds based on the mean value of the background.Finally, the canny edge can be well detected according to the double thresholds.The pipeline of the proposed method is shown in Fig. 1.In the following, the proposed adaptive threshold method is described in detail.

Finding the Mean Intensity of the Background
It is well known that RGB image has three channels and gray image has only one channel.So, the date of an RGB is three times that of the same size gray image.In this work, to simplify the calculation, the RGB image is first converted to a gray image, and other operations are all implied based on the gray image.
Since the background is a solid color, the distribution of the background in the histogram is concentrated and leads to a peak.In addition, due to the large area size of the background, the highest peak in the histogram is the background.The intensity statistic result of the corresponding gray image is shown in Fig. 2. The peak corresponding to the background Fig. 2. The statistic result about the intensity of gray image.
is very obvious and it is a Normal distribution.In this way, the mean value of the background can be found easily based on the distribution of intensity.
Considering the Normal distribution of background with very low variance , and the area size of the object is small, the proportion of the object is ignored.Therefore, the full image is assumed to be a Normal distribution.
Where  denotes the intensity of pixels in the image. and  are the mean and variance of the Normal distribution.The mean value of the background   is formulated by the mean value of the full image   .In this way, the mean intensity of the background is solved well.

Adaptive Setting the Double Threshold
Since the area size of the object in the image is small, and there is a intensity gap between the background and the object, the double thresholds can be obtained according to the intensity distance to the center of the background.In the simplest form, this paper sets the double thresholds by a relative distance.
Where   and  ℎ are the low threshold and the high threshold respectively.According to the experiment result,  1 and  2 are set as 0.7 and 0.5.In this way, the Canny edge can be well detected according to the intensity gradient  between each pixel and its surroundings.
If the intensity gradient of one pixel is larger than ℎ , this pixel must be the edge point of the object.At the same time, if the gradient is larger than   but lower than  ℎ , it is a weak edge point.Whether it is a reliable edge or not is determined by the states of surrounding pixels.In addition, if the gradient is lower than   , it is not the edge point of the object.Thus, for any image taken with different illuminations and backgrounds, two adaptive thresholds can be automatically set to obtain suitable edge information.

Adaptive Threshold Canny Edge Detection
According to the double thresholds, the Canny edge can be detected step by step as the classic Canny edge detector.First, the image is smoothed by the Gaussian filter.
Where  denotes the standard deviation of Gaussian filer. and  are the location of the pixel in the image.  is the original image while   is the image after Gaussian smoothing.After Gaussian smoothing the image, the gradient can be calculated.
(5)  is the gradient of the pixel, which is calculated by comprehensive considering gradient   and   in direction  and .And the gradient in each direction is calculated according to the pixel's intensity.
Moreover, to guarantee only one pixel response to each edge, non-maximum suppression is performed on the image.A 3x3 neighboring area is used to perform interpolation along with the two gradient directions.If the  is the largest one in both two directions, it is a candidate edge point.Otherwise, it is not an edge point.
Finally, according to the double thresholds described in Sec.3.2, all the candidate edge points are checked.For pixels that are lower than  ℎ but larger than   , if its neighboring pixels is edge point, it will be masked as edge point.Otherwise, it is not edge point.Thus, the edge detection is finished and the edge information can be output.

Experiments and Results
In this section, we analyze the edge detection result based on the proposed method.What's more, the edge information detected by the proposed method is used to object detection and object segmentation applications.At the some time, the advantages of the proposed method are described in detail.

Accurate Edge Detection
The edge detection result is shown in Fig. 3.For an object in a simple background image, the edge information can be well detected according to the proposed method.Moreover, to better instruct the advantages of the proposed method.We analyze the result by dividing images into three groups.
The analysis of the adaptability to different solid color backgrounds is shown in Fig. 3(a), edge is detected on images that are taken with different backgrounds.The result shows that edge information can be well detected and not be influenced by the color of the background.In addition, the false edge caused by large area size shadow is prevented well.
The analysis of the adaptability to different illuminations is shown in Fig. 3(b), three images are taken with the same background while different illuminations.Since the camera is sensitive to illumination, pixels' intensity is different in images that are taken with different illuminations.The edge result shows that it performs well and has a high ability to adapt to different illuminations.A slight disadvantage of the proposed method is that it cannot detect a very weak edge.For example, the weak edge in the top left part of the first image is not well detected due to unclear boundary between object and background.
The analysis of the adaptability to different objects is shown in Fig. 3(c).The first object is full of texture, while the second object is lack of texture.About the third object, a part area is full of texture, while the other part area is lack texture.The result shows that the proposed method can well detect edge for both objects with rich texture and object with less texture.For edge caused by small area size strong shadow, the proposed method cannot handle it well.Fortunately, the strong shadow is always small.In this way, the additional error edge information has only a small impact on industrial applications.
In summary, the proposed method has well adaptability to different backgrounds, illuminations, and objects.But it cannot handle problems introduced by unclear boundaries and strong shadow.Fortunately, these problems have less impact on practical industrial applications.

Object Detection and Segmentation Based on Edge
Thanks to the low data volumes and easy calculation, edge information detected from the image have become one kind of popular data in various practical industrial applications.This paper proposed the adaptive Canny edge detection method, which targets applications with a simple solid color background.In this way, to verify that the proposed method has a good performance and can be used easily, we do experiments about detecting and segmenting objects based on the edge information detected by the proposed method.
The object detection and segmentation result are shown in Fig. 4. To better show the details, the region including the object is zoomed out from the second row to the fourth row.According to the edge information of the object, as shown in the second row, the object can be well detected and segmented from the background.The object detection result is shown in the third row, a minimum bounding rectangle of the object is drawn.The location and orientation of the object are obtained accurately.In this way, it can provide reliable location and orientation information for later processing in practical industry applications.
The object segmentation result is shown in the fourth row, the region of the object in the image is well masked according to the edge information.The object can be extracted based on the mask.Thus, providing accurate object information for other matching and identification applications.However, a flaw in the proposed method is that object segmentation is influenced by the weak edge and strong shadow.For example, the weak edge in the second image is not detected and the strong shadow in the fifth image leads to a litter background is masked as the object.

Conclusions
A novel Canny edge detection method that adaptively determines the double thresholds according to the statistic result of the corresponding gray image is proposed for practical industry applications in this study.Since the Normal intensity distribution of pixels in the background, the mean value can be found easily.Thus, the double thresholds can be set by keeping a suitable distance to the background based on the mean value.Moreover, this method can be used to provide accurate edge information for practical industrial applications with a simple background.However, there are still some shortcomings, such as the weak edge cannot be detected well and strong shadow is detected as edge.In future work, we plan to research to overcome these shortcomings.

Fig. 1 .
Fig. 1.The pipeline of proposed adaptive threshold Canny edge detection method.

Fig. 3 .
Fig. 3. Edge detection result from the proposed adaptive Canny edge detection method.Top to Button: the full image; the object; the edge result.

Fig. 4 .
Fig. 4. Detect object and segment object from image based on edge information.Top to bottom: input image; edge information detected by the proposed method; object detection result based on the edge information; object segmentation result based on the edge information.