2.1.2. Formulation

Strictly speaking, the operator uses 3 × 3 cores to calculate output values. If *A* is the original image, and *Gx* and *Gy* are two images with approximate points of derivatives in *x* and *y*:

$$G\_{\mathbf{y}} = \begin{bmatrix} -1 & -2 & -1 \\ 0 & 0 & 0 \\ 1 & 2 & 1 \end{bmatrix} \* A \text{, and } G\_{\mathbf{x}} = \begin{bmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \end{bmatrix} \* A \tag{1}$$

where ∗ means a two-dimensional convolution operation.

The *x*-coordinate here increases "to the right", and *y* "down". At each point of the image, the approximate value of the gradient value can be calculated using the obtained approximate values of the derivatives (meaning element by element):

$$G = \sqrt{G\_x^2 + G\_y^2} \tag{2}$$

Using this information, we can also calculate the direction of the gradient:

$$\Theta = \arctan\left(\frac{G\_x}{G\_y}\right) \tag{3}$$

where, for example, the angle Θ is zero for the vertical boundary in which the dark side is on the left.

The brightness function is known to us at discrete points, we need to determine the differentiated function that passes through these points. Derivatives at any single point are functions of brightness from all points of the image. The solution of the derivatives can be calculated with a certain degree of accuracy.

Sobel's operator is an inaccurate approximation of the image gradient, but it is high enough for practical application in many problems. Specifically, the operator uses the intensity value only around 3 × 3 of each pixel to obtain an approximation of the corresponding image gradient and uses only integer values of the luminance weights to estimate the gradient.

2.1.3. Extension to Another Number of Dimensions

The Sobel operator consists of two separate operations:

• Smoothing with a triangular filter perpendicular to the derivative direction:

$$h(-1) = 1, \ h(0) = 2, \ h(1) = 1$$

• Finding a simple central change in the direction of the derivative:

$$h(-1) = 1, \; h'^{(0)} = 0, \; h'^{(1)} = -1$$

Sobel filters for image derivatives in various dimensions for

$$y, z, t \in (0, -1, 1)$$

$$\text{1D}: \ h'\_x(\mathbf{x}) = h\iota(\mathbf{x})$$

$$\text{2D}: \ h'\_x(\mathbf{x}, y) = h\iota(\mathbf{x})h(y)$$

$$\text{3D}: \ h'\_x(\mathbf{x}, y, z) = h\iota(\mathbf{x})h(y)h(z)$$

$$\text{4D}: \ h'\_x(\mathbf{x}, y, z, t) = h\iota(\mathbf{x})h(y)h(z)h(t)$$

Here is an example of a three-dimensional Sobel core for an axis *z*:

$$\begin{aligned} h\nu\_z(\colon,\,-1) &= \begin{bmatrix} 1 & 2 & 1 \\ 2 & 4 & 2 \\ 1 & 2 & 1 \end{bmatrix} \\\\ h\nu\_z(\colon,\,0) &= \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix} \\\\ h\nu\_z(\colon,\,1) &= \begin{bmatrix} -1 & -2 & -1 \\ -2 & -4 & -2 \\ -1 & -2 & -1 \end{bmatrix} \end{aligned}$$
