The operator uses two 3x3 kernels convolved with the original image to produce a map of intensity gradient. The areas of highest gradient are where the intensity of the image changes rapidly over a few pixels, and are thus likely to represent edges.
Two convolution kernels are needed to detect the first-order derivative of both horizontal and vertical changes in a 2-dimensional image. If we define
as the source image, we can compute:
Which can then be combined to give the overall magnitudes using:
Using this information, we can also calculate the gradient's direction:
will be 0 for a vertical edge, and will increase for edges anti-clockwise of this.