Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
Sobel 算子是一种离散性差分算子, 用来计算图像像素值的一阶, 二阶, 三阶或混合梯度. 在图像的任何一点使用此算子, 将会产生对应的灰度矢量或是其法矢量.
- C++: void Sobel(InputArray src, OutputArray dst, int ddepth, int dx, int dy, int ksize=3, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
- C: void cvSobel(const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size=3 )
参数含义
src - 输入图像
dst - 输出结果, 与输入图像具有相同的尺寸和通道数
ddepth - 输出图像的数据类型. 支持以下数据类型组合
- src.depth() = CV_8U, ddepth = -1/CV_16S/CV_32F/CV_64F
- src.depth() = CV_16U/CV_16S, ddepth = -1/CV_32F/CV_64F
- src.depth() = CV_32F, ddepth = -1/CV_32F/CV_64F
- src.depth() = CV_64F, ddepth = -1/CV_64F
当 ddepth=-1 时, 输出与输入具有相同的数据类型. 当输入是 8 比特图像时, 输出结果将是截断的导数值 (in the case of 8-bit input images it will result in truncated derivatives).
xorder - x 方向求导阶数
yorder - y 方向求导阶数
ksize - 卷积核的大小, 只能是 1/3/5/7 之一 (it must be 1, 3, 5, or 7).
scale - 缩放尺度因子, 默认无缩放
delta - 存储之前加到上述结果上的偏移量.
borderType - 边界插值方法, 详见附录 A-1.
Scharr 算子
Calculates the first x- or y- image derivative using Scharr operator.
该算子参数和 Sobel 算子一致, 与 Sobel 区别在于, Scharr 仅作用于大小为 3 的内核. 具有和 sobel 算子一样的速度, 但结果更为精确.
C++: void Scharr(InputArray src, OutputArray dst, int ddepth, int dx, int dy, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )
参数含义
src - 输入图像
dst - 输出结果, 与输入图像具有相同的尺寸和通道数
ddepth - 输出图像的数据类型, 即矩阵中元素的一个通道的数据类型, 这个值和 type 是相关的. 例如 type 为 CV_16SC2, 一个 2 通道的 16 位的有符号整数, depth 是 CV_16S
dx - dx=1 表示求 x 方向的一阶梯度, dx=0 表示不求 x 方向
dy - 与上类似, dy=1 表示求 y 方向的一阶梯度, dy=0 表示不求 y 方向
scale - 求导得到的值的缩放尺度因子, 默认无缩放
delta - 在存储之前加到求导值上的数值, 可以用于将 0 以下的值调整到 0 以上. delta=0 时表示梯度为 0 处结果保存为 0;delta=m 时表示梯度为 0 处结果保存为 m
borderType - 表示图像四周像素外插值方法, 默认是 BORDER_DEFAULT, 该参数解释见附录 A-1.
来源: https://www.cnblogs.com/phillee/p/12374573.html