[][src]Function opencv::imgproc::sobel

pub fn sobel(
    src: &dyn ToInputArray,
    dst: &mut dyn ToOutputArray,
    ddepth: i32,
    dx: i32,
    dy: i32,
    ksize: i32,
    scale: f64,
    delta: f64,
    border_type: i32
) -> Result<()>

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

In all cases except one, the inline formula separable kernel is used to calculate the derivative. When inline formula, the inline formula or inline formula 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 = #CV_SCHARR (-1) that corresponds to the inline formula Scharr filter that may give more accurate results than the inline formula Sobel. The Scharr aperture is

block formula

for the x-derivative, or transposed for the y-derivative.

The function calculates an image derivative by convolving the image with the appropriate kernel:

block formula

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:

block formula

The second case corresponds to a kernel of:

block formula

Parameters

  • src: input image.
  • dst: output image of the same size and the same number of channels as src .
  • ddepth: output image depth, see @ref 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 #getDerivKernels for details).
  • delta: optional delta value that is added to the results prior to storing them in dst.
  • borderType: pixel extrapolation method, see #BorderTypes

See also

Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar

C++ default parameters

  • ksize: 3
  • scale: 1
  • delta: 0
  • border_type: BORDER_DEFAULT