opencv3计算拉普拉斯变换-Laplacian函数

时间:2021-09-05 20:05:16
</pre><pre name="code" class="cpp">#include<opencv2/opencv.hpp>
#include<iostream>
#include<vector>

using namespace cv;
using namespace std;

int g_nValue = 0;

int main()
{
	Mat srcImage = imread("tiger.jpg");
	imshow("【原图】", srcImage);

	Mat grayImage;
	cvtColor(srcImage, grayImage, CV_BGR2GRAY);
	Mat dstImage;
	dstImage.create(grayImage.size(), grayImage.type());

	GaussianBlur(srcImage, srcImage, Size(3, 3), 0, 0);
	GaussianBlur(grayImage, grayImage, Size(3, 3), 0, 0);

	namedWindow("【处理后】", 0);
	createTrackbar("Value", "【处理后】", &g_nValue, 15, 0);

	char key;
	while (1)
	{
		Laplacian(grayImage, dstImage, CV_16S, 2  * g_nValue + 1);
		convertScaleAbs(dstImage, dstImage);
		imshow("【处理后】", dstImage);

		key = waitKey(10);
		if (key == 27)
			break;
	}
}

opencv3计算拉普拉斯变换-Laplacian函数