目录

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

 

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐