home

canny

20/10/2022

Today I want to talk a bit about Canny Edge Detection's algorithm.

What is Edge Detection?

Edge detection is about extracting information about an image, in this case the edges of an object. At the end of the algorithm, we want to know for each pixel of the image whether or not it is part of an edge or not.

Why is it useful?

Edge detection is crucial for multiple areas of computer science such as Image Segmentation and Processing (medical imaging) or even Machine Vision (autonomous driving) [1] .

Demonstration

Given a simple square picture (A), we first need to remove any noise produced by the electronic camera used to take it.

Original picture (A)

We call such a noise a Gaussian Noise and therefore use a Gaussian Filter in order to remove it. As a result, this filter also makes the picture a little blurry since it removes some of the really high frequencies (B).

After application of Gaussian Filter (B)

Then, we compute the norm (C) and the angle (D) of the normal to the gradient for each pixel. Then, notice that image (C) roughly contains the information we want, but has thick lines, because of the blur introduced by the Gaussian Filter.

Norm of the normal to the gradient (C)
Angle of the normal to the gradient (D)

We therefore want to make the edges thinner with a technique called Deletion of Non-Maxima (E).

Image after deletion of non-maxima (E)

Finally, observe than some edges are not continuous (look at the left part of the coat). We see that there is an edge before and after this gap going in the same direction so we can assume for some pixels that this should be an edge as well, this technique is called Hysterisis Thresholding and gives us our final picture (F).

Final result of Canny Filter (F)

Semi-Automatic Edge Detection

I ommited numerous details in the previous section to try and simplify the explanation. In fact the algorithm I described is not fully automatic, it requires the user to enter two variables used in the Hysterisis Threshold algorithm. In this section we show briefly the results of trying to guess such values.

Result for semi-automatic Canny Filter (G) - GIF