sobel函数、
主要对图像进行求x或者y方向上的导数
使用扩展 Sobel 算子计算一阶、二阶、三阶或混合图像差分
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 )
-
src
- 输入图像. dst
- 输出图像.
-
- int ddepth 输出图像的深度
-
xorder
- x 方向上的差分阶数 yorder
- y 方向上的差分阶数 ksize
- 扩展 Sobel 核的大小,必须是 1, 3, 5 或 7。 除了尺寸为 1, 其它情况下, aperture_size ×aperture_size 可分离内核将用来计算差分。对 aperture_size=1的情况, 使用 3x1 或 1x3 内核 (不进行高斯平滑操作)。这里有一个特殊变量 CV_SCHARR (=-1),对应 3x3 Scharr 滤波器,可以给出比 3x3 Sobel 滤波更精确的结果。
double scale=1, double delta=0, int borderType=BORDER_DEFAULT
分别表示图像放大的倍数,,图像像素增加的值,,以及图像边界的处理方式
opencv代码:
<span style="font-size:18px;">#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include<cv.h>
#include<stdlib.h>
using namespace cv;
using namespace std;
int main()
{
Mat src, dst;
src = imread("D:6.jpg");
/*Mat kx = (Mat_<float>(1, 3) << 0,-1,0);
Mat ky = (Mat_<float>(1, 3) << -1,0, -1);
sepFilter2D(src, dst, src.depth(),kx,ky,Point(-1,-1),0,BORDER_DEFAULT );*/
Sobel(src, dst, src.depth(), 1, 1, 3, 1, 0);
imshow("shiyan", dst);
waitKey(0);
return 0;
}</span>