目录
note
code
test
note
matx = (-1,0;1,0)
maty = (0,-1;1,0)
code
// 图像增强之图像锐化(边缘增强)之robot算子
void GetRobot(Mat& robotX, Mat& robotY) {robotX = (Mat_<int>(2,2) << -1,0,1,0);robotY = (Mat_<int>(2,2) << 0,-1,1,0);
}
void EdgeSharpenRobot(Mat&src, Mat& res) {Mat resX;Mat resY;Mat robotX;Mat robotY;GetRobot(robotX, robotY);filter2D(src, resX, src.type(), robotX); // 使用robot卷积得到x分量filter2D(src, resY, src.type(), robotY); // 使用robot卷积得到y分量add(resX,resY,res);
}
void EdgeSharpenRobotTest(void) {Mat src = imread("../source/lena.jpg", IMREAD_GRAYSCALE);if (src.empty()) {printf("src empty\n");return;}Mat res(src.rows, src.cols, src.type(), Scalar(0));namedWindow("src", WINDOW_NORMAL);namedWindow("res", WINDOW_NORMAL);EdgeSharpenRobot(src, res);imshow("src", src);imshow("res", res);MyWait();destroyAllWindows();
}
test