Edge Detection and Gradients
Discovering object boundaries by taking the derivative of an image using Sobel operators.
To a computer, an image is just a grid of numbers. An "edge" isn't a geometric line; it's a sudden, sharp change in intensity values.
In calculus, we find rapid changes by taking the derivative. The same applies to images: we compute the image gradient, turning sudden changes into measurable spikes.
We compute these derivatives using convolution kernels. The Sobel operators are standard 3x3 matrices: one calculates horizontal differences () and the other calculates vertical differences ().
Once we have the differences in both and , we combine them. The magnitude tells us how strong the edge is, and the direction tells us the angle of the edge normal.
These steps form the core of algorithms like the Canny Edge Detector, which uses these gradients, thins the resulting edges, and applies thresholds to produce clean object boundaries.