OpenCV Laplace 算子

 1 #include "opencv2/imgproc/imgproc.hpp"
 2 #include "opencv2/highgui/highgui.hpp"
 3 #include <stdlib.h>
 4 #include <stdio.h>
 5 
 6 using namespace cv;
 7 
 8 /** @函数 main */
 9 int main( int argc, char** argv )
10 {
11   Mat src, src_gray, dst;
12   int kernel_size = 3;
13   int scale = 1;
14   int delta = 0;
15   int ddepth = CV_16S;
16   char* window_name = "Laplace Demo";
17 
18   int c;
19 
20   /// 装载图像
21   src = imread( argv[1] );
22 
23   if( !src.data )
24     { return -1; }
25 
26   /// 使用高斯滤波消除噪声
27   GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
28 
29   /// 转换为灰度图
30   cvtColor( src, src_gray, CV_RGB2GRAY );
31 
32   /// 创建显示窗口
33   namedWindow( window_name, CV_WINDOW_AUTOSIZE );
34 
35   /// 使用Laplace函数
36   Mat abs_dst;
37 
38   Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
39   convertScaleAbs( dst, abs_dst );
40 
41   /// 显示结果
42   imshow( window_name, abs_dst );
43 
44   waitKey(0);
45 
46   return 0;
47   }
原文地址:https://www.cnblogs.com/ybqjymy/p/12170920.html