1 /**
2 * @file Laplace_Demo.cpp
3 * @brief Sample code showing how to detect edges using the Laplace operator
4 * @author OpenCV team
5 */
6
7 #include "opencv2/imgproc/imgproc.hpp"
8 #include "opencv2/imgcodecs.hpp"
9 #include "opencv2/highgui/highgui.hpp"
10 #include <stdlib.h>
11 #include <stdio.h>
12
13 using namespace cv;
14
15 /**
16 * @function main
17 */
main(int,char ** argv)18 int main( int, char** argv )
19 {
20
21 Mat src, src_gray, dst;
22 int kernel_size = 3;
23 int scale = 1;
24 int delta = 0;
25 int ddepth = CV_16S;
26 const char* window_name = "Laplace Demo";
27
28 /// Load an image
29 src = imread( argv[1] );
30
31 if( src.empty() )
32 { return -1; }
33
34 /// Remove noise by blurring with a Gaussian filter
35 GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
36
37 /// Convert the image to grayscale
38 cvtColor( src, src_gray, COLOR_RGB2GRAY );
39
40 /// Create window
41 namedWindow( window_name, WINDOW_AUTOSIZE );
42
43 /// Apply Laplace function
44 Mat abs_dst;
45
46 Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
47 convertScaleAbs( dst, abs_dst );
48
49 /// Show what you got
50 imshow( window_name, abs_dst );
51
52 waitKey(0);
53
54 return 0;
55 }
56