Canny edge detector is a multi-step algorithm to detect the edges for any input image. It involves below mentioned steps to be followed while detecting edges of an image.

1. Removal of noise in input image using Gausian filter.

2. Computing the derivative of Gausian filter in order to calculate the gradient of image pixels to obtain magnitude along x and y dimension.

3. Considering a group of neighbours for any curve in direction perpendicular to given edge supress the non-max edge contributor pixel points.

4. Lastly use the Hysteresis Thresholding method to preserve the pixels higher than gradient magnitude and neglect the ones lower than the low threshold value.

Before deep diving into the steps below are the three conclusions that J.K Canny who derived the algorithm :

- **Good Detection : **The optimal detector must eliminate the possibility of getting false positives and false negatives.

Good Localisation : The detected edges must be as close to true edges.

Single Response Constraint : The detector must return one point only for each edge point.

Steps to followed during Canny Algorithm:

Noise Removal or Image Smoothing:

During the noise presence the pixel may not be close to being similar to its neigbouring pixels. This might result in obtaining improper or inappropriate detection of edges . In order to avoid the same we use the Gausian filter which is convolved with the image and removes the noise which prevents from getting the desired edges in output images.

In the below example we are convolving gausian filter or kernel g(x,y) with image I. Here we wish to make sure that any given pixel must be alike its neighbouring pixels in output and so we use the matrix [1 1 1] in order to maintain the similarity between pixels and remove the noise.

Image for post

Image for post

g(x,y)= Gausian Distribution

#machine-learning #canny-edge-detection #python

What is Canny Edge Detection Algorithm?
5.40 GEEK