Canny Edge Detector

by Chien-I Liao

Source code: edge_detector.rar

In this project I use C++ program read in a color bitmap photo, then transform it into a gray scale one. As shown in Fig.1,2.

Fig.1 Color Photo (Original)                                                Fig.2 Gray Scale Photo

Then apply £_xG*I and £_yG*I to Fig.2, I got Ix and Iy. (Fig. 3)

Fig.3(a) Ix (Detect horizontal edges)                                       Fig.3(b) Iy (Detect vertical edges)

¡@

Now we have |Grad(G*I)| and Arg(Grad(G*I)). The following plots are results from different values of £m used in Guassian Function. (Fig. 4)

(a)

(b)                                                                                                (c)

Fig 4. Plot of |Grad(G*I)|. (a) when £m = 1.0 (b) when £m = 2.0 (c)  when £m = 0.5

Then find the local maximum to determine the edge, however, noise may exist so a H_Threshold was used to remove noise. (Fig. 5)

(a)                                                                                    (b)

(c)                                                                                (d)

Fig. 5. Edge Image (a) No Threshold (b) H_Threshold = 5

(c) H_Threshold = 60 (d) H_Threshold = 100

Finally, I used a priority queue to record edge pixel then apply a L_Threshold to pixels on the tangent line of gradient field. In the following figures, gray pixels denote the edge recovered by this technique:

(a)                                                                                      (b)

(c)                                                                                  (d)

Fig 6. Hysteresis Thresh (a) H_Threshold = 60 (b) H_Threshold = 60; L_Threshold = 15

(c) H_Threshold = 100 (b) H_Threshold = 100; L_Threshold = 15

In above pictures I search 5 pixels each direction in the tangent line to recover edge. Another possibility is to search for 8 neighbors of each edge pixel. These results could be improved, however, by combine two heuristics:

(a)                                                                                    (b)

(c)

Fig 7. H_Threshold=100, L_Threshold=15 (a) Search only on tangent line

(b) Search only on neighborhood (c) Use both heuristics

Here is an example which contains shadow; the results were shown in Fig. 8:

(a)                                                             (b)

(c)                                                    (d)

Fig 8. (a) Original image (b) H_Threshold = 5

(c) H_Threshold = 100 (d) H_Threshold = 100; L_Threshold = 15

Home