opncv学习-imgprocess- Laplacian算子

来源:互联网 发布:淘宝上活动技巧 编辑:程序博客网 时间:2024/06/05 03:01

Laplacian算子是求图像的二阶导,跟sobel算子很相似。代码如下

#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/highgui/highgui.hpp"#include <stdlib.h>#include <stdio.h>using namespace cv;/** @function main */int main( int argc, char** argv ){Mat src, src_gray, dst;int kernel_size = 3;int scale = 1;int delta = 0;int ddepth = CV_16S;char* window_name = "Laplace Demo";int c;/// Load an imagesrc = imread( argv[1] );if( !src.data ){ return -1; }/// Remove noise by blurring with a Gaussian filterGaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );/// Convert the image to grayscalecvtColor( src, src_gray, CV_RGB2GRAY );/// Create windownamedWindow( window_name, CV_WINDOW_AUTOSIZE );/// Apply Laplace functionMat abs_dst;Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );convertScaleAbs( dst, abs_dst );/// Show what you gotimshow( window_name, abs_dst );waitKey(0);return 0;}


原创粉丝点击