图像边缘检测 拉普拉斯算子

#include <opencv2/opencv.hpp>
#include <iostream>
#include <math.h>
using namespace cv;
using namespace std;

Mat src, dst,dst2,gray_src;
char* INPUT_WIN = "input image";
char* OUTPUT_WIN = "binary image";
int threshold_value = 127;
int threshold_max = 255;
int type_value = 2;
int type_max = 4;


int main()
{

    src = imread(".//pic//kate.png");

    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);

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

    threshold(edge_image, edge_image, 0, 255, THRESH_OTSU | THRESH_BINARY);
     
    imshow(OUTPUT_WIN, edge_image);

    waitKey(0);
    return 0; 
}
原文地址:https://www.cnblogs.com/xiaochi/p/12010671.html