Second Programming Sessions

The goal is to implement a Canny edge detector. You can find a precise description in the course, and in many other places on the web, including Wikipedia.


Some of you have implemented Deriche's gradient. We are going to focus on something different: the hysteresis thresholding step.


The step for Canny's edge detextion:

1. Smooth the image with a Gaussian filter
2. Compute the gradient magnitude and angle images
3. Apply nonmaxima suppresion to the gradient magnitude image
4. Use the hysteresis thresholding and connectivity analysis to detect and link edges


Step 1 is not mandatory, but useful for clean results. If you have time, you will also program steps 2 and 3, but in this session, we will program step 4. Hence, you can replace steps 2 and 3 with a simple sobel gradient filter, and use a double thresholding to perform step 4.


Step 4 can be described as follows:

(a) Locate the next strong edge pixel p in the high threshold image High.

(b) Mark as valid edge pixels all the weak pixel in the low threshold image Low that are connected to p using, say, 8-connectivity. [Hint: there is a propagation to do here].

(c) If all nonzero pixels in High have been visited, go to step (d). Else return to step (a)

(d) Set to zero all pixels in High that were not marked as valid edge pixels.


At the end of this procedure, the final image output is formed by appending to High all the nonzero pixels from Low.



In practice, the use of the Low and High images is not useful. Hysteresis thresholding can be implemented during nonmaxima suppression and thresholding can be implemented directly on the gradient by forming a list of strong pixels and the weak pixels connected to them.