Canny edge detector
A first formal definition of the characteristics of a strong edge detection system was given by John F. Canny, according to this definition a strong edge detection algorithm must:
- correctly extract edges in noisy images.(Good Detection)
- minimize distance between the found edge and the “true” edge. (Good Localization)
- detect one single edge pixel at each “true” edge.(One Response to One Edge)
A good implementation of the Canny edge detector is obtained by Gaussian filtering followed by gradient computation and NMS along the gradient direction
A possible improvement can be done by exploiting the separability of the 2D Gaussian function
Nms edge detection improvements
In order to improve the NMS process Canny propose a 2 threshold approach $T_h$ $T_l$ where a pixel is considered an edge if it’s magnitude it’s above $T_h$ or it’s above $T_l$ and it’s a neighbor of an already edge detected pixel

Final pipeline

Implementation
There is an implementation of Canny edge detector in the opencv2 library follows an example for reference
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('image.jpg', cv.IMREAD_GRAYSCALE)
assert img is not None, "file could not be read, check with os.path.exists()"
edges = cv.Canny(img,100,200)This implementation does not perform Gaussian smoothing before