Opencv拉普拉斯算子做图像增强

Opencv拉普拉斯算子——图像增强

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

using namespace std;
using namespace cv;

//拉普拉斯处理
cv::Mat laplaceMat(cv::Mat imgParam);

int main(int argc, char *argv[])
{
    Mat image = imread("D:\\images\\JK$DPF6315~A4G07~G{J4WI.jpg", 1);
    if (image.empty())
    {
        std::cout << "打开图片失败,请检查" << std::endl;
        return -1;
    }
    imshow("原图像", image);
    
    cv::Mat imageEnhance = laplaceMat(image);

    imshow("拉普拉斯算子图像增强效果", imageEnhance);
    waitKey();
    return 0;
}

//拉普拉斯处理
cv::Mat laplaceMat(cv::Mat imgParam)
{
    Mat imageEnhance;
    //Mat kernel = (Mat_<float>(3, 3) << 0, -1, 0, 0, 5, 0, 0, -1, 0);
    Mat kernel = (Mat_<float>(3, 3) << 0,-1,0,0,3,0,0,-1,0);

    filter2D(imgParam, imageEnhance, CV_8UC3, kernel);
    return imageEnhance;
}

 

posted @ 2019-10-28 20:09  西北逍遥  阅读(2130)  评论(0编辑  收藏  举报