next up previous contents
Next: Horizontal Up: 13.3.5 Useful Convolution Filters Previous: Laplacian Filter Sobel Filter

The Sobel filter consists of two kernels which detect horizontal and vertical changes in an image. If both are applied to an image, the results can by used to compute the magnitude and direction of the edges in the image. If the application of the Sobel kernels results in two images which are stored in the arrays Gh[0..(height-1][0..(width-1)] and Gv[0..(height-1)][0..(width-1)], the magnitude of the edge passing through the pixel x, y is given by:

\begin{displaymath}M_{sobel}[x][y] = \sqrt{Gh[x][y]^2 + Gv[x][y]^2} =
\left\vert Gh[x][y] \right\vert + \left\vert Gv[x][y] \right\vert

(you are justified in using the magnitude representation since the values represent the magnitude of orthogonal vectors). The direction can also be derived from Gh and Gv:

\begin{displaymath}\phi_{sobel}[x][y] = tan^{-1}(\frac{Gv[x][y]}{Gh[x][y]})

The 3x3 Sobel kernels are:


David Blythe