Hubbry Logo
Sobel operatorSobel operatorMain
Open search
Sobel operator
Community hub
Sobel operator
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Sobel operator
Sobel operator
from Wikipedia
A color picture of an engine
The Sobel operator applied to that image

The Sobel operator, sometimes called the Sobel–Feldman operator or Sobel filter, is used in image processing and computer vision, particularly within edge detection algorithms where it creates an image emphasising edges. It is named after Irwin Sobel and Gary M. Feldman, colleagues at the Stanford Artificial Intelligence Laboratory (SAIL). Sobel and Feldman presented the idea of an "Isotropic 3 × 3 Image Gradient Operator" at a talk at SAIL in 1968.[1] Technically, it is a discrete differentiation operator, computing an approximation of the gradient of the image intensity function. At each point in the image, the result of the Sobel–Feldman operator is either the corresponding gradient vector or the norm of this vector. The Sobel–Feldman operator is based on convolving the image with a small, separable, and integer-valued filter in the horizontal and vertical directions and is therefore relatively inexpensive in terms of computations. On the other hand, the gradient approximation that it produces is relatively crude, in particular for high-frequency variations in the image.

Formulation

[edit]

The operator uses two 3×3 kernels which are convolved with the original image to calculate approximations of the derivatives – one for horizontal changes, and one for vertical. If we define A as the source image, and Gx and Gy are two images which at each point contain the horizontal and vertical derivative approximations respectively, the computations are as follows:[1]

where here denotes the 2-dimensional signal processing convolution operation.

In his text describing the origin of the operator,[1] Sobel shows different signs for these kernels. He defined the operators as neighborhood masks (i.e. correlation kernels), and therefore are mirrored from what described here as convolution kernels. He also assumed the vertical axis increasing upwards instead of downwards as is common in image processing nowadays, and hence the vertical kernel is flipped.

Since the Sobel kernels can be decomposed as the products of an averaging and a differentiation kernel, they compute the gradient with smoothing. For example, and can be written as

The x-coordinate is defined here as increasing in the "right"-direction, and the y-coordinate is defined as increasing in the "down"-direction. At each point in the image, the resulting gradient approximations can be combined to give the gradient magnitude, using Pythagorean addition:

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

where, for example, is 0 for a vertical edge which is lighter on the right side (for see atan2).

More formally

[edit]

Since the intensity function of a digital image is only known at discrete points, derivatives of this function cannot be defined unless we assume that there is an underlying differentiable intensity function that has been sampled at the image points. With some additional assumptions, the derivative of the continuous intensity function can be computed as a function on the sampled intensity function, i.e. the digital image. It turns out that the derivatives at any particular point are functions of the intensity values at virtually all image points. However, approximations of these derivative functions can be defined at lesser or larger degrees of accuracy.

The Sobel–Feldman operator represents a rather inaccurate approximation of the image gradient, but is still of sufficient quality to be of practical use in many applications. More precisely, it uses intensity values only in a 3×3 region around each image point to approximate the corresponding image gradient, and it uses only integer values for the coefficients which weight the image intensities to produce the gradient approximation.

Extension to other dimensions

[edit]

The Sobel–Feldman operator consists of two separable operations:[2]

  • Smoothing perpendicular to the derivative direction with a triangle filter:
  • Simple central difference in the derivative direction:

Sobel–Feldman filters for image derivatives in different dimensions with  :

1D:

2D:

2D:


3D:

3D:

4D:

Thus as an example the 3D Sobel–Feldman kernel in z-direction:

Technical details

[edit]

As a consequence of its definition, the Sobel operator can be implemented by simple means in both hardware and software: only eight image points around a point are needed to compute the corresponding result and only integer arithmetic is needed to compute the gradient vector approximation. Furthermore, the two discrete filters described above are both separable:

and the two derivatives Gx and Gy can therefore be computed as

In certain implementations, this separable computation may be advantageous since it implies fewer arithmetic computations for each image point.

Applying convolution K to pixel group P can be represented in pseudocode as:

where represents the new pixel matrix resulted after applying the convolution K to P; P being the original pixel matrix.

Example

[edit]

The result of the Sobel–Feldman operator is a 2-dimensional map of the gradient at each point. It can be processed and viewed as though it is itself an image, with the areas of high gradient (the likely edges) visible as white lines. The following images illustrate this, by showing the computation of the Sobel–Feldman operator on a simple image.

Grayscale test image of brick wall and bike rack
Normalized gradient magnitude from Sobel–Feldman operator
Normalized x-gradient from Sobel–Feldman operator
Normalized y-gradient from Sobel–Feldman operator

The images below illustrate the change in the direction of the gradient on a grayscale circle. When the sign of and are the same the gradient's angle is positive, and negative when different. In the example below the red and yellow colors on the edge of the circle indicate positive angles, and the blue and cyan colors indicate negative angles. The vertical edges on the left and right sides of the circle have an angle of 0 because there is no local change in . The horizontal edges at the top and bottom sides of the circle have angles of −π/2 and π/2 respectively because there is no local change in . The negative angle for top edge signifies the transition is from a bright to dark region, and the positive angle for the bottom edge signifies a transition from a dark to bright region. All other pixels are marked as black due to no local change in either or , and thus the angle is not defined. Since the angle is a function of the ratio of to pixels with small rates of change can still have a large angle response. As a result noise can have a large angle response which is typically undesired. When using gradient angle information for image processing applications effort should be made to remove image noise to reduce this false response.

Grayscale image of a black circle with a white background.
The direction of the Sobel operator's gradient.

Alternative operators

[edit]

The Sobel–Feldman operator, while reducing artifacts associated with a pure central differences operator, does not exhibit a good rotational symmetry (about 1° of error). Scharr looked into optimizing this property by producing kernels optimized for specific given numeric precision (integer, float…) and dimensionalities (1D, 2D, 3D).[3][4] Optimized 3D filter kernels up to a size of 5 x 5 x 5 have been presented there, but the most frequently used, with an error of about 0.2° is:

This factors similarly:

Scharr operators result from an optimization minimizing weighted mean squared angular error in the Fourier domain. This optimization is done under the condition that resulting filters are numerically consistent. Therefore they really are derivative kernels rather than merely keeping symmetry constraints. The optimal 8 bit integer valued 3x3 filter stemming from Scharr's theory is

A similar optimization strategy and resulting filters were also presented by Farid and Simoncelli.[5][6] They also investigate higher-order derivative schemes. In contrast to the work of Scharr, these filters are not enforced to be numerically consistent.

The problem of derivative filter design has been revisited e.g. by Kroon.[7]

Derivative filters based on arbitrary cubic splines were presented by Hast.[8] He showed how first and second order derivatives can be computed correctly using cubic or trigonometric splines by a double filtering approach giving filters of length 7.

Another similar operator that was originally generated from the Sobel operator is the Kayyali operator,[9] a perfect rotational symmetry based convolution filter 3x3.

Orientation-optimal derivative kernels drastically reduce systematic estimation errors in optical flow estimation. Larger schemes with even higher accuracy and optimized filter families for extended optical flow estimation have been presented in subsequent work by Scharr.[10] Second order derivative filter sets have been investigated for transparent motion estimation.[11] It has been observed that the larger the resulting kernels are, the better they approximate derivative-of-Gaussian filters.

Example comparisons

[edit]

Here, four different gradient operators are used to estimate the magnitude of the gradient of the test image.

Grayscale test image of brick wall and bike rack
Gradient magnitude from Sobel–Feldman operator
Gradient magnitude from Scharr operator
Gradient magnitude from Roberts Cross operator
Gradient magnitude from Prewitt operator

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The Sobel operator, also known as the Sobel–Feldman operator, is a discrete differentiation -based filter used in for detecting edges by approximating the first-order derivatives of the image intensity function. It employs two separate 3×3 convolution kernels—one for the horizontal (Gx) and one for the vertical (Gy)—to compute the rate of change in intensity along the x- and y-directions at each , with the overall edge strength derived from the magnitude √(Gx2 + Gy2) and direction from the arctangent of Gy/Gx. The horizontal kernel emphasizes vertical edges, while the vertical kernel highlights horizontal edges, and the operator's design incorporates central weighting to provide a measure of local smoothing, reducing noise sensitivity compared to simpler differencing methods. Developed by Irwin Sobel and Gary M. Feldman at the Stanford Artificial Intelligence Laboratory (), the operator was first presented in a 1968 internal talk titled "An Isotropic 3×3 Image Gradient Operator," marking an early contribution to computational techniques in . Although not formally published as a peer-reviewed at the time, it gained prominence through subsequent references in works like Pingle's 1969 edge-following and Duda and Hart's 1973 pattern classification book, establishing it as a foundational tool for approximation. The kernels, which separate the smoothing (via averaging) and differentiation steps, are defined as follows: Horizontal kernel (Gx):

[-1 0 1] [-2 0 2] [-1 0 1]

[-1 0 1] [-2 0 2] [-1 0 1]

Vertical kernel (Gy):

[-1 -2 -1] [ 0 0 0] [ 1 2 1]

[-1 -2 -1] [ 0 0 0] [ 1 2 1]

These are applied via , often normalized by dividing by 8 (though sometimes omitted for simplicity in discrete implementations), to yield the partial derivatives. The Sobel operator's simplicity, low computational cost, and ability to detect edges in multiple orientations make it widely implemented in libraries like and , serving as a baseline for more advanced detectors such as Canny. It excels in uniform lighting conditions but can produce thicker edges and be sensitive to noise without preprocessing like Gaussian smoothing, leading to its frequent combination with other filters in practical applications such as and . Despite the advent of sophisticated methods, its isotropic approximation of the remains influential in both educational contexts and real-time systems due to its balance of accuracy and efficiency.

Overview

Definition and Purpose

The Sobel operator is a discrete differentiation operator employed in image processing and to approximate the of an image's intensity function at each , thereby identifying edges as regions of rapid intensity variation. First described by Irwin Sobel and Gary M. Feldman in 1968, it utilizes two separate kernels: one to compute the horizontal component GxG_x and the other to compute the vertical component GyG_y. The primary purpose of the Sobel operator is to detect edges in digital images by emphasizing abrupt changes in intensity, which correspond to boundaries between distinct objects or regions; this makes it a foundational tool for feature extraction in pipelines, such as and segmentation tasks. In practice, it generates an edge strength map by combining the magnitudes of the horizontal and vertical gradients, typically through a vector magnitude computation that highlights the overall rate of intensity change regardless of direction. A key strength of the Sobel operator lies in its computational efficiency, achieved via the compact 3×3 kernel size and separable convolution that allows for optimized integer-based operations, enabling fast processing even on resource-constrained systems. Additionally, it exhibits greater tolerance than simpler first-derivative methods or higher-order operators, as the kernel's weighted design incorporates over neighboring pixels to suppress high-frequency while preserving edge information.

Historical Development

The Sobel operator was developed in 1968 by Irwin Sobel, then a PhD candidate, and Gary M. Feldman at the Stanford Artificial Intelligence Laboratory (SAIL), as a component of broader scene analysis systems aimed at . This work emerged amid the 1960s surge in research to enable automated visual interpretation of environments, including early explorations of and motion analysis techniques such as . Sobel and Feldman's contribution built on these foundations, introducing a simple yet effective method for gradient approximation tailored to discrete image data. The initial description of the operator appeared in a presentation titled A 3x3 Isotropic Operator for delivered at , which highlighted its role in enhancing edge responses while . Though the talk itself remained unpublished, the concept was documented in subsequent SAIL technical reports. By the 1970s, the operator gained prominence through its adoption in foundational algorithms for and scene understanding, marking a shift toward practical implementations in early digital vision systems. In the ensuing decades, the Sobel operator's simplicity and efficiency propelled its integration into prominent software frameworks, such as MATLAB's Image Processing Toolbox and OpenCV's core library, where it serves as a standard tool for gradient-based processing. Even with the rise of sophisticated alternatives like the Canny detector in the , the operator retains enduring relevance in resource-constrained real-time applications, such as embedded vision systems and hardware-accelerated on FPGAs, due to its low computational overhead and robustness to moderate noise.

Mathematical Formulation

Core Kernels

The Sobel operator employs two fundamental 3×3 convolution kernels to approximate the partial derivatives of the image intensity in the horizontal and vertical directions, respectively. These kernels were introduced in the original as a discrete to the for . The horizontal kernel GxG_x, designed to detect vertical edges by emphasizing intensity changes along the x-axis, takes the form: [101202101]\begin{bmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \end{bmatrix}
Add your contribution
Related Hubs
User Avatar
No comments yet.