Robot算子,Soble算子,Scharr算子介绍:
一、 Robot算子:
代码演示:
//Robot 算子
Mat robot_x = (Mat_<int>(2, 2) << 1, 0, 0, -1);
Mat robot_y = (Mat_<int>(2, 2) << 0, 1, -1, 0);
Mat grad_x, grad_y,result;
filter2D(src, grad_x, CV_32F, robot_x, Point(-1, -1), 30, BORDER_DEFAULT);
filter2D(src, grad_y, CV_32F, robot_y, Point(-1, -1), 30, BORDER_DEFAULT);
convertScaleAbs(grad_x, grad_x);
convertScaleAbs(grad_y, grad_y);
add(grad_x, grad_y, result);
imshow("result", result);
二、Soble算子,
代码演示:
//Soble算子
Mat result2;
Scharr(src, grad_x, CV_32F, 1, 0);
Scharr(src, grad_x, CV_32F, 0, 1);
convertScaleAbs(grad_x, grad_x);
convertScaleAbs(grad_y, grad_y);
add(grad_x