opencv sobel算子

#include
#include
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat src = imread("1.jpg");
imshow("yuantu",src);


Mat grad_x,grad_y;
Mat abs_grad_x,abs_grad_y,dst;


Sobel(src,grad_x,CV_16S,1,0,3);
convertScaleAbs(grad_x,abs_grad_x);
imshow("grad_x",abs_grad_x);


Sobel(src,grad_y,CV_16S,0,1,3);

convertScaleAbs(grad_y,abs_grad_y);
imshow("grad_y",abs_grad_y);


addWeighted(abs_grad_x,0.5,abs_grad_y,0.5,0,dst);
imshow("pic",dst);
waitKey(0);
return 0;


}


运行图如下


你可能感兴趣的:(opencv,opencv)