The computational process of the operator is divided into several stages:
Gradient calculation
The input image is convolved both vertically and horizontally using a Sobel kernel whose size is determined by the Sobel size parameter.
Then it is filtered horizontally and vertically using an edge detection filter that this produces Gx and Gy.
The intensity and angle of each pixel is calculated as follows:
Intensity=dx2+dy2
Angle=arctan(dxdy)
Non-maximum suppression
For each pixel in the image, check if the intensity is a local maximum in the gradient direction. If yes, keep it as an edge pixel, otherwise remove it as a non-edge pixel.
Double thresholding
The intensity magnitude of each pixel is compared with a strong threshold (ℎ𝑖𝑔ℎ_𝑡ℎ𝑟𝑒𝑠ℎ𝑜𝑙𝑑) and a weak threshold (𝑙𝑜𝑤_𝑡ℎ𝑟𝑒𝑠ℎ𝑜𝑙𝑑),
and if the intensity is greater than the strong threshold, it is labeled as a strong edge.
If the intensity is less than the weak threshold, it is labeled as no edge. Intensity values between the strong and weak thresholds are labeled as weak edges.
Edge Tracking
If a weak edge is connected to a strong edge, then that weak edge becomes a strong edge.
Repeat this process until all weak edges connected to strong edges are found.
Then the remaining weak edges are labeled as non-edges, the edge detection result for the whole image is obtained.