Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Sobel operator
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Formulation== The operator uses two 3×3 kernels which are [[kernel (image processing)#Convolution|convolved]] with the original image to calculate approximations of the [[image derivative|derivatives]] β one for horizontal changes, and one for vertical. If we define '''A''' as the source image, and '''G'''<sub>''x''</sub> and '''G'''<sub>''y''</sub> are two images which at each point contain the horizontal and vertical derivative approximations respectively, the computations are as follows:<ref name="Sobel" /> :<math> \begin{aligned} \mathbf{G}_x &= \begin{bmatrix} -1 & 0 & +1 \\ -2 & 0 & +2 \\ -1 & 0 & +1 \end{bmatrix} * \mathbf{A} \\ \mathbf{G}_y &= \begin{bmatrix} -1 & -2 & -1\\ 0 & 0 & 0 \\ +1 & +2 & +1 \end{bmatrix} * \mathbf{A} \end{aligned} </math> where <math>*</math> here denotes the 2-dimensional signal processing [[kernel (image processing)#Convolution|convolution]] operation. In his text describing the origin of the operator,<ref name="Sobel" /> 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, <math>\mathbf{G}_x</math> and <math>\mathbf{G}_y</math> can be written as :<math> \begin{aligned} \mathbf{G}_x &= \begin{bmatrix} 1 \\ 2 \\ 1 \end{bmatrix} * \left ( \begin{bmatrix} 1 & 0 & -1 \end{bmatrix} * \mathbf{A} \right ) \\ \mathbf{G}_y &= \begin{bmatrix} +1 \\ 0 \\ -1 \end{bmatrix} * \left ( \begin{bmatrix} 1 & 2 & 1 \end{bmatrix} * \mathbf{A} \right ) \end{aligned} </math> 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]]: :<math>\mathbf{G} = \sqrt{ {\mathbf{G}_x}^2 + {\mathbf{G}_y}^2 }</math> Using this information, we can also calculate the gradient's direction: :<math>\mathbf{\Theta} = \operatorname{atan2}( \mathbf{G}_y , \mathbf{G}_x )</math> where, for example, <math>\mathbf{\Theta} </math> is 0 for a vertical edge which is lighter on the right side (for <math>\operatorname{atan2}</math> see [[atan2]]).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)