Skip to main content
2 of 4
added details
Laurent Duval
  • 32.3k
  • 3
  • 35
  • 105

A first rationale is to be very short, as there was a time when computing on images was expensive. Then, a contour or an edge often present a fast variation in image intensities, that can be enhanced by derivatives. Sobel filters emulate such derivatives in one direction, and slightly average pixels in the complementary direction, to smooth light variations or noise.

One direction implements the shortest possible centered 1D discrete derivative:

$$\begin{bmatrix} -1 &0 &1 \end{bmatrix} $$ to detect variations across lines, the other the shortest non-trivial Pascal/Gaussian smoothing $$\begin{bmatrix} 1&2&1 \end{bmatrix} $$ to smooth along lines, resulting in, for instance: $$ \begin{bmatrix} -1 &0 &1 \\ -2 &0 &2 \\ -1 &0 &1 \\ \end{bmatrix} $$

As you can see, this only involves dyadic numbers, so it can be implemented with adds and binary shifts.

Laurent Duval
  • 32.3k
  • 3
  • 35
  • 105