Return to Computer Vision Notebooks

Sobel Operator



Sobel and gradient operation with spatial filtering.

Sobel operator


The Sobel–Feldman is a gradient operator that consists of two separable convolutional operations:

Given that, we could define the operations as:

$$ \large G_x = \begin{bmatrix} 1 \\ 2 \\ 1 \end{bmatrix} * \left( \begin{bmatrix} +1 & 0 & -1 \end{bmatrix} *I \right) = \begin{bmatrix} +1 & 0 & -1 \\ +2 & 0 & -2 \\ +1 & 0 & -1 \end{bmatrix} * I $$$$ \large G_y = \begin{bmatrix} +1 \\ 0 \\ -1 \end{bmatrix} * \left( \begin{bmatrix} 1 & 2 & 1 \end{bmatrix} *I \right) = \begin{bmatrix} +1 & +2 & +1 \\ 0 & 0 & 0 \\ -1 & -2 & -1 \end{bmatrix} * I $$

Sobel operator and patial filtering


Applying Sobel operator as spatial filtering by the application of discrete convolution on images.

The gradient magnitude is defined as:

$$ \large G = \sqrt{G_x^2+G_y^2} $$

The gradient direction is defined as:

$$ \large \Theta = \arctan\left(\frac{G_y}{G_x}\right) $$

Different operator sizes