pub fn sobel(
src: &impl ToInputArray,
dst: &mut impl ToOutputArray,
ddepth: i32,
dx: i32,
dy: i32,
ksize: i32,
scale: f64,
delta: f64,
border_type: i32
) -> Result<()>
Expand description
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
In all cases except one, the separable kernel is used to
calculate the derivative. When
, the
or
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 = [FILTER_SCHARR] (-1)
that corresponds to the Scharr
filter that may give more accurate results than the
Sobel. The Scharr aperture is
for the x-derivative, or transposed for the y-derivative.
The function calculates an image derivative by convolving the image with the appropriate kernel:
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:
The second case corresponds to a kernel of:
§Parameters
- src: input image.
- dst: output image of the same size and the same number of channels as src .
- ddepth: output image depth, see [filter_depths] “combinations”; in the case of 8-bit input images it will result in truncated derivatives.
- dx: order of the derivative x.
- dy: order of the derivative y.
- ksize: size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
- scale: optional scale factor for the computed derivative values; by default, no scaling is applied (see get_deriv_kernels for details).
- delta: optional delta value that is added to the results prior to storing them in dst.
- borderType: pixel extrapolation method, see #BorderTypes. [BORDER_WRAP] is not supported.
§See also
Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
§C++ default parameters
- ksize: 3
- scale: 1
- delta: 0
- border_type: BORDER_DEFAULT