The Canny edge detector is another very important algorithm. It also uses the concept of gradients like in the Sobel edge detector, but in Sobel we only considered the magnitude of the gradient. In this we will also use the direction of the gradient to find the edges.

This algorithm has four major steps:

**Smoothing**: In this step, the Gaussian filter is applied to the image to reduce the noise in the image.

**Finding the gradient**: After removing the noise, the next step is to find the gradient magnitude and direction by calculating the*x*-derivative and*y*-derivative. The direction is important, as the gradient is always perpendicular to the edge. Therefore, if we know the direction of the gradient, we can find the direction ...