Laplance算子

Laplance算子就是对图像求二阶导

 

代码:

#include <opencv2/opencv.hpp>
#include <iostream>
#include <math.h>

using namespace cv;
int main(int argc, char** argv) {
    Mat src, dst;
    src = imread("L:/5.jpg");
    if (!src.data) {
        printf("could not load image...
");
        return -1;
    }

    char INPUT_WIN[] = "input image";
    char OUTPUT_WIN[] = "Laplance Result";
    namedWindow(INPUT_WIN, CV_WINDOW_AUTOSIZE);
    namedWindow(OUTPUT_WIN, CV_WINDOW_AUTOSIZE);
    imshow(INPUT_WIN, src);

    Mat gray_src,edge_image;
    GaussianBlur(src, dst, Size(3, 3), 0, 0);  //高斯平滑,高斯滤波
    cvtColor(dst, gray_src, CV_BGR2GRAY);
    imshow("gray",gray_src);

    Laplacian(gray_src, edge_image, CV_16S, 3);
    convertScaleAbs(edge_image, edge_image);

    imshow(OUTPUT_WIN, edge_image);

    

    waitKey(0);
    return 0;
}

结果:

原图

 灰度图:

 Laplance:

原文地址:https://www.cnblogs.com/Jack-Elvis/p/11444942.html