本系列代码托管于:https://github.com/chintsan-code/opencv4-tutorials

本篇使用的项目为:usm

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv) {
	Mat src = imread("../sample/lena512.bmp");
	if (src.empty()) {
		cout << "could not load image..." << endl;
		return -1;
	}
	namedWindow("input", WINDOW_AUTOSIZE);
	imshow("input", src);

	// Unsharpen mask filter
	Mat blur_image, dst;
	GaussianBlur(src, blur_image, Size(3, 3), 0);
	Laplacian(src, dst, -1, 1, 1.0, 0, BORDER_DEFAULT);
	imshow("laplacian demo", dst);
	Mat usm_image;
	addWeighted(blur_image, 1.0, dst, -1.0, 0, usm_image);
	imshow("usm filter", usm_image);

	waitKey(0);
	destroyAllWindows();
	return 0;
}

USM:Unsharp mask

$$blur – Laplacia$$

可以去除一些细小的干扰细节和噪声,比一般直接使用卷积锐化算子得到的图像锐化结果更加真实可信