Algorithm of Sobel

The algorithm of Sobel is an operator used in Image processing for the Détection of contours. It is about one of the simplest operators who gives however correct results.

Simplified description

To make simple, the operator calculates the Gradient intensity of each pixel. This indicates the direction of the strongest variation of light to dark, as well as the rate of change in this direction. One then knows the points of sudden change of luminosity, probably corresponding on board, as well as the orientation of these edges.

In mathematical terms, the Gradient of a function of two variables (here intensity according to the coordinates of the image) is a vector of dimension 2 whose coordinates are the derived according to the directions horizontal and vertical. In each point, the gradient points in the direction of the strongest change of intensity, and its length represents the rate of variation in this direction. The gradient in a zone of constant intensity is thus null. On the level of a contour, the gradient crosses contour, of the darkest intensities to the clearest intensities.

Formulation

The operator uses matrices of convolution. The matrix (generally of size 3× 3) undergoes a convolution with the image to calculate approximations of the horizontal and vertical derivative. Either \ mathbf {has} the image source, \ mathbf {G_x} and \ mathbf {G_y} two images which in each point respectively contain approximations of the horizontal and vertical derivative of each point. These images are calculated as follows:

\ mathbf {G_x} = \ begin {bmatrix} -1 & 0 & +1 \ \ -2 & 0 & +2 \ \ -1 & 0 & +1 \ end {bmatrix} * \ mathbf {has} \ quad \ mbox {and} \ quad \ mathbf {G_y} = \ begin {bmatrix} +1 & +2 & +1 \ \ 0 & 0 & 0 \ \ -1 & -2 & -1 \ end {bmatrix} * \ mathbf {has}

In each point, the approximations of the horizontal and vertical gradients can be combined as follows to obtain an approximation of the standard of the gradient:

\ mathbf {G} = \ sqrt {\ mathbf {G_x} ^2 + \ mathbf {G_y} ^2}

One can also calculate the direction of the gradient as follows:

\ mathbf {\ Theta} = \ operatorname {arctan} \ left ({\ mathbf {G_y} \ over \ mathbf {G_x}} \ right)
where, for example, \ Theta is worth 0 for a darker vertical contour on the left.

Precise details

Since the intensity of an digital image is discrete, the derivative of this function cannot be defined if it is not under an assumption of continuity of the function continuous intensity which was sampled. In practice one can calculate more or less faithful approximations of the gradient in each point.

The algorithm of Sobel calculates a rather inaccurate approximation of the gradient of intensity, but that is enough in practice in much case. Indeed, it generally uses only one vicinity (of size 3× 3) around each point to calculate the gradient, and the weights used for the calculation of the gradient are whole.

Details of implementation

From its simplicity, the algorithm of Sobel can be easily implemented in a software or even material way: only 8 points around the point considered are necessary to calculate the gradient. This calculation uses simply calculations on the entireties. Moreover, the filters horizontal and vertical are separable:

\begin{bmatrix}

-1 & 0 & +1 \ \ -2 & 0 & +2 \ \ -1 & 0 & +1 \ end {bmatrix} = \ begin {bmatrix} 1 \ \ 2 \ \ 1 \ end {bmatrix} * \ begin {bmatrix} -1 & 0 & +1 \end{bmatrix} \quad \quad \begin{bmatrix} +1 & +2 & +1 \ \ 0 & 0 & 0 \ \ -1 & -2 & -1 \ end {bmatrix} = \ begin {bmatrix} +1 \ \ 0 \ \ -1 \ end {bmatrix} * \ begin {bmatrix} 1 & 2 & 1 \end{bmatrix}

and both derived \ mathbf {G_x} et \ mathbf {G_y} can be calculated as follows:

\ mathbf {G_x} = \ begin {bmatrix} 1 \ \ 2 \ \ 1 \ end {bmatrix} * \ begin {bmatrix} -1 & 0 & +1 \ end {bmatrix} * \ mathbf {has} \ quad \ mbox {and} \ quad \ mathbf {G_y} = \ begin {bmatrix} +1 \ \ 0 \ \ -1 \ end {bmatrix} * \ begin {bmatrix} 1 & 2 & 1 \ end {bmatrix} * \ mathbf {has}

Separability can be made profitable in certain types of implementation to allow less operations during calculation.

More basically, while dividing by 4, these formulas show that derivation in a direction is associated with a triangular smoothing in the other direction intended to eliminate “false contours”, the same technique being used in the filter of Prewitt with a rectangular smoothing which introduces phase shifts (see Lissage of the image).

See too

External bond

  • Bibliographic quotations for Irwin Sobel in DBLP

Random links:Kal PEN | City-Pommerœul | Tevita Tu' ifua | Shannon Rutherford | Park of Contades | Biscuit_de_la_Floride