Laplance operator

Laplance operator is to find the second derivative of the image

 

 

Code:

 

#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...\n");
        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;
}

 

result:

Artwork

 

 

 Grayscale:

 

 

 Laplance:

 

Guess you like

Origin www.cnblogs.com/Jack-Elvis/p/11444942.html