Advertisement
jyun14

Laplace

Nov 24th, 2014
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  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/highgui/highgui.hpp"
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11.  
  12. using namespace cv;
  13.  
  14. /**
  15.  * @function main
  16.  */
  17. int main( int, char** argv )
  18. {
  19.  
  20.   Mat src, src_gray, dst;
  21.   int kernel_size = 3;
  22.   int scale = 1;
  23.   int delta = 0;
  24.   int ddepth = CV_16S;
  25.   const char* window_name = "Laplace Demo";
  26.  
  27.   /// Load an image
  28.   src = imread( argv[1] );
  29.  
  30.   if( !src.data )
  31.     { return -1; }
  32.  
  33.   /// Remove noise by blurring with a Gaussian filter
  34.   GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
  35.  
  36.   /// Convert the image to grayscale
  37.   cvtColor( src, src_gray, COLOR_RGB2GRAY );
  38.  
  39.   /// Create window
  40.   namedWindow( window_name, WINDOW_AUTOSIZE );
  41.  
  42.   /// Apply Laplace function
  43.   Mat abs_dst;
  44.  
  45.   Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
  46.   convertScaleAbs( dst, abs_dst );
  47.  
  48.   /// Show what you got
  49.   imshow( window_name, abs_dst );
  50.  
  51.   waitKey(0);
  52.  
  53.   return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement