MATLAB File Help: cv.Sobel | Index |
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator
dst = cv.Sobel(src)
dst = cv.Sobel(..., 'OptionName', optionValue, ...)
src
.dst
. default 0DDepth=-1
(default), the output image will have the same depth
as the source.In all cases except one, the KSize x KSize
separable kernel is used to
calculate the derivative. When KSize=1
, the 3x1
or 1x3
kernel is used
(that is, no Gaussian smoothing is done). KSize=1
can only be used for the
first or the second x- or y- derivatives.
There is also the special value KSize=-1
or KSize='Scharr'
that
corresponds to the 3x3
Scharr filter that may give more accurate results
than the 3x3
Sobel. The Scharr aperture is:
[-3 0 3; -10 0 10; -3 0 3]
for the x-derivative, or transposed for the y-derivative.
The function calculates an image derivative by convolving the image with the appropriate kernel:
partial^(XOrder+YOrder) src
dst = ---------------------------------------
partial x^(XOrder) partial y^(YOrder)
The Sobel operators combine Gaussian smoothing and differentiation, so the
result is more or less resistant to the noise. Most often, the function is
called with (XOrder = 1
, YOrder = 0
, KSize = 3
) or (XOrder = 0
,
YOrder = 1
, KSize = 3
) to calculate the first x- or y- image derivative.
The first case corresponds to a kernel of:
[-1 0 1; -2 0 2; -1 0 1]
The second case corresponds to a kernel of:
[-1 -2 -1; 0 0 0; 1 2 1]