pub fn sobel(
src: &impl GMatTraitConst,
ddepth: i32,
dx: i32,
dy: i32,
ksize: i32,
scale: f64,
delta: f64,
border_type: i32,
border_value: Scalar,
) -> Result<GMat>
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:
Note:
- Rounding to nearest even is procedeed if hardware supports it, if not - to nearest.
- Function textual ID is “org.opencv.imgproc.filters.sobel”
§Parameters
- src: input image.
- 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 odd.
- scale: optional scale factor for the computed derivative values; by default, no scaling is applied (see cv::getDerivKernels for details).
- delta: optional delta value that is added to the results prior to storing them in dst.
- borderType: pixel extrapolation method, see cv::BorderTypes
- borderValue: border value in case of constant border type
§See also
filter2D, gaussianBlur, cartToPolar
§C++ default parameters
- ksize: 3
- scale: 1
- delta: 0
- border_type: BORDER_DEFAULT
- border_value: Scalar(0)