4.3 Edge Detection Techniques
4.3.2 Canny Edge Detection
The Canny edge detection algorithm was developed by John F. Canny in 1986, and devised according to the rules given below.
There are three criteria that an edge detector should fulfil. 1) It should have a good detection quality.
There should be a low probability of false detection of an edge point, and a low probability of erroneous missing of an edge point.
2) The edge detector should have a good localisation quality.
The extracted edges should be as close as possible to the true edges. This is formalised by minimising the variance of the extracted edge positions.
3) The edge detector should return only a single image edge for each object edge. It should avoid multiple responses.
The first criterion was applied in Section 4.2 by using Gaussian and image decomposition to smooth noise.
(݅ െ ͳǡ ݆ െ ͳ) (݅ െ ͳǡ ݆) (݅ െ ͳǡ ݆ ͳ)
(݅ǡ ݆ െ ͳ) (݅ǡ ݆) (݅ǡ ݆ ͳ)
(݅ ͳǡ ݆ െ ͳ) (݅ ͳǡ ݆) (݅ ͳǡ ݆ ͳ)
Figure 4. 10: Neighbourhood of the pixel at point
The second criterion involves computation of pixel magnitude gradients and of the direction, as well as application of non-maximal suppression.
44
To compute the values for gradients and the direction of gradient, the derivative of calculus measure function is utilised. Partial derivatives enable derivation of the following equations from the image neighbourhood in Figure 4.10.
݀ܵ
݀ݔሺ݅ǡ ݆ሻ ൌ
ͳ
ʹሾܵሺ݅ ͳǡ ݆ሻ െ ܵሺ݅ǡ ݆ሻ ܵሺ݅ ͳǡ ݆ ͳሻ െ ܵሺ݅ǡ ݆ ͳሻሿ
Equation 4.3 Derivative of function with respect to ݀ܵ
݀ݕሺ݅ǡ ݆ሻ ൌ
ͳ
ʹሾܵሺ݅ǡ ݆ ͳሻ െ ܵሺ݅ǡ ݆ሻ ܵሺ݅ ͳǡ ݆ ͳሻ െ ܵሺ݅ ͳǡ ݆ሻሿ
Equation 4.4 Derivative of function with respect to
To find the pixel gradient, Pythagoras theorem is used, and the gradient of the pixel is calculated by means of derivative Equation 4.3 and Equation 4.4.
ܩሺ݅ǡ ݆ሻ ൌ ඨሺ݀ܵ
݀ݔሺ݅ǡ ݆ሻሻ
ଶ ሺ݀ܵ
݀ݕሺ݅ǡ ݆ሻሻ
ଶ
Equation 4.5 Gradient magnitude ࡳሺǡ ሻ of the pixel
The pixel gradient direction can be obtained from Equation 4.3 and Equation 4.4, and then the angle ሺǡ ሻ can be calculated.
\ ሺǡ ሻ ൌ ሺ ݀ܵ ݀ݕ ሺ݅ǡ ݆ሻ ݀ܵ ݀ݔ ሺ݅ǡ ݆ሻ ሻ
45
The final part of the second criterion is non-maximal suppression. The edge pixel gradient magnitude locates the local maximal in the gradient direction. To determine whether the gradient magnitude of the pixel at ሺ݅ǡ ݆ሻ is local maximal or not, it is necessary to locate the two neighbouring pixels p1 and p2 of the pixel at point ሺ݅ǡ ݆ሻ, and to calculate the gradient magnitudes of the three pixels. It is supposed that pixels p1 and p2 are located at positions
ሺ݅ͳǡ ݆ͳሻ and ሺ݅ʹǡ ݆ʹሻǡrespectively. If the gradient magnitude of the pixel at positions ሺ݅ǡ ݆ሻ is
maximum, it is an edge point, and the gradient magnitude is used as its intensity. Otherwise, the pixel is not an edge point, and its intensity is set to 0. The resulting image δ
can be described as follows:
ߜሺ݅ǡ ݆ሻ ൌ ൜ܩሺ݅ǡ ݆ሻǡ ܫ݂ܩሺ݅ǡ ݆ሻ ܩሺ݅ͳǡ ݆ͳሻܽ݊݀ܩሺ݅ǡ ݆ሻ ܩሺ݅ʹǡ ݆ʹሻ
Ͳǡݐ݄݁ݎݓ݅ݏ݁
Equation 4.7 Local maximal
Because the locations of pixels are discrete, gradient directions also need to be quantised. The 8-neighbouring domain, as shown in Figure 4.10, with the pixel at position (i,j) can be taken as an example.
Figure 4.11 presents the use of the following angle criteria: a. If െଵ ଼ߨ ൏ ሺ݅ǡ ݆ሻ ଵ ଼ߨǡ ߠሺ݅ǡ ݆ሻݍܽݑ݊ݐ݅ݏ݁݀ܽݏͲ b. If ଵ ଼ߨ ൏ ሺ݅ǡ ݆ሻ ଷଵ ଼ ߨǡ ߠሺ݅ǡ ݆ሻݍܽݑ݊ݐ݅ݏ݁݀ܽݏ ଵ ସߨ c. If െଷ ଼ߨ ൏ ሺ݅ǡ ݆ሻ െ ଵ ଼ߨǡ ߠሺ݅ǡ ݆ሻݍܽݑ݊ݐ݅ݏ݁݀ܽݏ െ ଵ ସߨ d. ଷ ଼ߨ ൏ ሺ݅ǡ ݆ሻ െ ଵ ଶߨݎ െ ଵ ଶߨ ൏ ߠሺ݅ǡ ݆ሻ ൏ െ ଷ ଼ߨǡ ߠሺ݅ǡ ݆ሻݍܽݑ݊ݐ݅ݏ݁݀ܽݏ గ ଶ
The angle regions are represented by colour space where the four angles are shown as yellow (a), green (b), red (c) and blue (d).
46
Figure 4. 11: Edge directions (Green, 2002)
Fulfilment of the third criterion is the threshold with hysteresis. Non-maximal suppression reduces the border of an object to the width of just one pixel. Due to the existence of noise and thin texture, this process may result in spurious responses, which leads to streaking problems. Streaking here means the breaking up of the edge contour caused by the operator fluctuating above and below the threshold. Figure 4.12 demonstrates the non-maximum suppression and hysteresis. An example of the edge gradient magnitude is drawn, along with two thresholds, one upper and one lower. The process of non-maximum suppression is selecting the points along the top of the ridge. Given that the top of the ridge initially exceeds the upper threshold, the threshold output is set to white until the peak of the ridge falls beneath the lower threshold. The threshold output is then set to black until the peak of the ridge exceeds the upper switching threshold.
47
Figure 4. 12: Hysteresis and non-maximum suppression (Cui et al., 2009)
The Canny algorithm is applied to the original image from Chapter 3, as shown in Figure 4.13 and Figure 4.14. Subjective to the criteria of the Canny algorithm, the image is transformed into a single edge image. The edges are bounded by the non-maximum suppression regulation, and therefore the image is transformed from a greyscale to a black and white edge image. Figure 4.14 shows the close-up of the license plate, and the shape of the plate can be seen. The threshold hysteresis optimisation will be discussed in Chapter 5 (Methodology).
48
Figure 4. 13: After Canny algorithm process, with lower threshold = 10, and upper threshold = 50.
49