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:
(we 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:
The 3x3 Sobel kernels are: