Canny edge detection is an algorithm for finding edges in an image, like below.

The method consists of five steps:

  1. Convolve image with derive of gaussian (see ๐Ÿฟ Gaussian Kernels),
  1. Compute magnitude of gradient, . The above operations give us a rough idea of where edges are, but the detection is too soft and imprecise. To address this, we process to find the pixels with the โ€œmaximumโ€ edge (non-maximum suppression):
  2. Compute edge orientation,
  3. For each pixel, mark it as edge only if its gradient is greater than or equal to its two neighbors along the direction. The idea behind this is to extract the most significant area of the soft edges from (see image below).
  4. Filter the result with high (strong) and low (weak) thresholds on the gradient magnitude. Starting from strong edges, continue them with connected weak edges (Hysteresis).