1.源码实现
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
string file = "./1.jpg";
Mat img = imread(file.c_str(), -1);
pyrDown(img, img, Size(img.cols/2, img.rows/2));
Mat gray, laplaci, final;
//高斯模糊
GaussianBlur(img, img, Size(5,5), 0, 0);
//转灰度图
cvtColor(img, gray, CV_BGR2GRAY);
//拉普拉斯处理
Laplacian(gray, laplaci, CV_16S, 3, 1, 0);
//绝对值处理
convertScaleAbs(laplaci, laplaci);
imwrite("laplaci.jpg", laplaci);
return 0;
}
2.编译源码
$ g++ -o test test.cpp -std=c++11 -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -Wl,-rpath=/usr/local/lib
3.运行结果
1.jpglaplaci.jpg
网友评论