Restricted Hysteresis Reduce Redundancy in Edge Detection

In edge detection algorithms, there is a common redundancy problem, especially when the gradient direction is close to -135°, -45°, 45°, and 135°. Double edge effect appears on the edges around the ...


Introduction
Edge detection is a fundamental image processing method that has been studied for decades [1][2][3][4][5][6][7]. In general, the aim of edge detection is to significantly reduce the amount of data in an image, while retaining the structural properties to be used for further image processing. Therefore, efforts have been spent in decades to reduce noise and increase the detection rate in edge detection. However, there is a problem that has not been fully addressed in the literature. As shown in Figure 1, edge detection algorithms that follow Canny's framework usually have redundancy effect. On the diagonal direction, an edge detected with Canny edge detector has a width of two pixels. This will in the worst case yield 50% redundancy to the resulting data. The redundancy problem happens especially when the gradient direction is close to -135°, -45°, 45°, and 135°. This is caused by the discrete calculation of non-maximum suppression. Our proposed method can successfully delete such redundancy and its relative increased cost is less than 5%.
Generally, time consumption of an algorithm is between O(n) to O(n c ) depending on its complexity. Here n is the number of inputs and c is the power number. In natural images, the number of detected edge points is usually less than 5 % of the number of the original image pixels. Our method is able to further reduce n by eliminating the edge redundancy. Edge feature brings an op-portunity of fast computing for high level computer vision tasks. Edge as an important image feature has been used in many high level tasks [12][13][14][15][16][17]. For example, straight line can be detected by Hough transform. Ballard developed a generalized Hough transform to detect arbitrary shapes [12]. In both [13,15] they experimented with edge matching method in their application scenario. Borgefors developed a face recognition method using line edge map [15]. One reason of using edge instead of using pure image is because pure image is high dimensional and it brings extraordinary computational cost. For example [16] subclass discriminant analysis method is used to detect object based on pure image as input. In their algorithm, image transformation to a high dimensional matrix is the main factor of time consumption. The time consumption of above algorithms highly depends on the number of detected edge points. Our proposed method is able to reduce time consumption caused by edge redundancy.
Canny's [1] edge detector has been developed as a standard function in Matlab and OpenCV [8]. Many edge detectors have been developed in the last two decades after Canny [3][4][5][6]. Most edge detectors follow Canny's tion including non-maximum suppression and hysteresis. We present our simple solution using restricted hysteresis in section 3. Experiment result is presented in section 4.

Background
Edges are normally representations of changes in intensity functions of an image; i.e., image intensity variations such as steps, lines and junctions [3]. The widespread edge detection methods detect edges by finding local maxima of first-order derivative function or zero-crossing of second-order derivative function of the intensity profile of given image. In practice, image gradients are estimated by convoluting images with first-order derivative operators (also known as kernels), such as Robert's cross operator, Prewitt operator and Sobel operator [9]. The kernel convolution finds the abrupt changes in intensity of the image. In case of Sobel kernel both horizontal and vertical changes are approximated. Formally if I(x, y) is intensity level at a point in a given source image, and G x , G y are horizontal and vertical derivative approximations, then the gradient magnitude is given as Once the gradient magnitude is computed, the next step is to apply a threshold, to decide whether an edge is present or not at an image point. Appropriate thresholds filter out most noise and keep edge points. After this step, the resulting edge is still thick. Canny [1] introduced the notion of non-maximum suppression (NMS) to find edges with one-pixel thickness by comparing gradient value along gradient direction. The gradient direction is computed as: As shown in Figure 2, non-maximum suppression procedure checks if the pixel is a local maximum along gradient direction by comparing pixel with its interpolated neighbor pixels p and r [10]. This interpolation is implemented in Matlab.
In order to achieve a real-time algorithm, OpenCV do not use interpolated pixels but its rounded neighbor pixels [8]. As shown in Figure 3, such approximation rounds the angle θ to one of four directions: 0°, 45°, 90°, or 135°. This means in the ranges [−22.5°, -22.5°] and [157.5°, -202.5°] the algorithm round θ to 0 o . Since the comparison is symmetrical, the absolute value of the lower half of the circle is mirrored to the upper one. So, three pixels around pixel (x, y) are examined:  If θ (x, y) = 0°, then the pixels at (x + 1, y), I(x, y), and I(x − 1, y) are examined.  If θ (x, y) = 90°, then the pixels at (x, y + 1), (x, y), and (x, y − 1) are examined.  If θ (x, y) = 45°, then the pixels at (x + 1, y + 1), (x, y), and (x − 1, y − 1) are examined.  If θ (x, y) = 135°, then the pixels at (x + 1, y − 1), (x, y), and (x − 1, y + 1) are examined. If pixel (x, y) has the highest gradient magnitude of the three pixels examined, it is kept as an edge. We have evaluated Canny edge detection provided by Matlab and OpenCV. Both of them yield the same result with a redundancy problem.  The redundancy problem is caused by the inherent nature of discretization of image. As shown in Figure 4, the pixels with gradient value of 8 are the local maximum compared with their neighbor along the gradient direction. However, because there is a staggered effect because of discretization, the local maximum pixels present double edge effect and thus cause redundancy. If any algorithm could link these redundant edge pixels as one line with one pixel edge, the redundancy problem can be solved. However, this is not a straightforward method because most linking methods use gradient direction to predict the next pixel and then the result would be two parallel lines.
Canny edge detector's final step is called hysteresis. It keeps all the week edge pixels which are linked to the strong edge pixels. Canny edge detector uses two thresholds on the gradient image-a lower threshold decides if a pixel is a weak edge and an upper threshold decides if a pixel is a strong edge. Hysteresis step starts tracing from a strong edge and stops when the gradient is below the lower threshold. It improves noise reduction rate by eliminating weak edges which are not connected to a strong edge. However, the redundancy problem remains in the detected edge. The tracing involves predicting the next edge point. As shown in Figure 5, assume the marked point is an edge point. Then we construct the tangent to the edge curve and use this to predict the next point. The tangent is normal to the gradient at the point. The predicted next point is either point r or s. The choosing of r or s can be similar to the non-maximum suppression step by using rounded direction range.

Restricted Hysteresis
Restricted hysteresis means that when one starts to link a new edge part, a restriction is required to check if a pixel's 8 neighbor pixels have already been linked in previous hysteresis. If anyone of the 8 neighbors has already been linked as an edge point, we do not start new hysteresis from this pixel. As shown in Figure 6, P(x,y) is a strong edge so hysteresis step can be started. However, because of the restriction, we cannot start linking because two of its neighbors are already determined as edge points. Our restriction is only applied on each new starting point of hysteresis step. Once the starting point pass the restriction, the following linking is done as usual.
Otherwise, it will corrupt all the following linking. We have tested our method on many images including synthetic images and natural images. Restricted hysteresis performs well both regarding redundancy reduction rate and algorithm speed. The above mentioned method works well in most cases. However there are occasional exceptions according to our observation. As shown in Figure 7 (b), a new hysteresis starts from point P(x,y) and stops at Point R(x,y) by mistake. The pixels in red color are denoted as redundant pixels. This happens when there is a T-junction or X-junction in the edge. We can easily fix this exception by revising our restriction. In hysteresis linking step, we check if less than three of a pixel's eight neighbors have already been linked as edge, then we continue the hysteresis linking. Otherwise the hysteresis linking is stopped and we start a new hysteresis from a new pixel. New restricted hysteresis can successfully stop the linking on the position of T-junction while not eliminating the correct edge points.

Experiment Result
We find that most edge detection algorithms have redundancy of 50% in the worst case and 0% in the best case depending on the edge direction distribution. The average redundancy on natural images is approximately 15% to 20%. The worst case happens when all the edge direction is ±45° or ±135°. The best case happens when all the edge direction is ±0° or ±90°. In Figure 8, we can see that when edge direction is close to ±45°, the redundancy is about 50% and reduce when edge become more The time consumption of restricted hysteresis is minor compared with gradient calculation and non-maximum suppression. Gradient calculation and non-maximum suppression need to operate N times on each pixel. And hysteresis only operates on the edge detected by nonmaximum suppression. After non-maximum suppression, the number of edge pixels is on average less than 5% of image resolution. This means the time consumption of hysteresis is less than 5% of gradient calculation and non-maximum suppression.
In order to evaluate our proposed method, we compare the number of detected edge points by Canny edge detector and restricted hysteresis. The number of detected edge points by Canny edge detector is denoted as N c , and restricted hysteresis as N rh . Then the successful reduced number of redundancy points is: Redundancy reduction rate is: Since there is no available dataset providing the ground truth of redundant points, it is difficult to know the true redundancy rate of an edge image, denoted as R re (R' re <= R re ). Based on our experiment, R' re is about 15% to 20% on natural images. Table 1 presents our experiment results of on natural image. The natural images are resized and then tested on Canny edge detector and restricted hysteresis (Figure 9). Since the hysteresis itself eliminates the edges which are not connected to strong edge points, and we want to analyze the power of redundancy reduction but not the power of noise cancellation, we just set the lower threshold and upper threshold to the same value in our calculation. This means all the detected edges are strong edge and eliminated edge points are due to redundancy. In applying restricted hysteresis in real application, the principle of setting threshold is the same as in Canny's framework.

Discussion
There is a concern about the accuracy of the detected edge. As shown in Figure 10, is we use Hough transform to detect straight lines on detected edge points, then the detected line positions based on Canny edge detection are different from restricted hysteresis (Figure 10(a) and  (b) ) . The difference is 0.3535 pixel. Since edge pixels are presented in discrete locations, it is not sufficient to present accurate sub pixel locations unless we implement further sub-pixel analysis [7]. Therefore, even assuming line position in Figure 10(a) is more accurate, the maximum error of 0.3535 pixel in Figure 10(b) is reasonable. Compared with the accuracy issue, the advantage of restricted hysteresis is obvious. For example, Hough transform is time consuming. By reducing average redundancy of 20%, the time consumption of Hough transform will be reduced by 20%. Most high level object detection and recognition tasks do not use Hough transform but linking based line or curve detection because of speed consideration. Linking based algorithms usually result detected lines such as in Figure 10(c). This will result in redundant lines. Redundant lines are a potential factor of low speed and accuracy in high level computer vision tasks.

Conclusions
Non-maximum suppression and hysteresis as the fundamental thinning step in Canny's edge detector has been used widely in many other edge detection algorithms. The procedure can be found in many literatures [1,3,5,7,17]. However, there is no work that discusses the redundancy effect of detected edge points. Our work highlights that there is a common redundancy problem, especially when the gradient direction is close to -135°, -45°, 45°, and 135°. Double edge effec appears on the edge around t  these directions. This is caused by the discrete calculation of non-maximum suppression. Our proposed solution is to put a restriction in the hysteresis step to further reduce the double edges to one pixel width. The increased time consumption is far less than 5%. Our proposed method successfully reduces redundant edge points which are usually 15% to 20% of the detected edge points. Restricted hysteresis is simple to implement and can be used by any edge detection algorithm which need a thinning step. Redundancy reduction helps to improve algorithm speed when edge points are needed for further computer vision task such as line extraction or object recognition.