C++ opencv 锐化、高斯平滑、

完整演示:

卷积运算

#include 
#include 
#include 

using namespace cv;

int main(int argc, char** argv)
{   
    // 原图(图一)
	Mat src_image = imread("./media/dog.jpg");
	Mat temp_image;
	resize(src_image, temp_image, cv::Size(int(src_image.cols * 0.3), int(src_image.rows * 0.3)));

    // 锐化(图二)
	Mat out_iamge1;
	//边缘锐化卷积核
	Mat kernal_mat1 = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
	filter2D(temp_image, out_iamge1, -1, kernal_mat1);

    // 平滑(图三)
	Mat out_iamge2;
	//高斯平滑卷积核
	Mat kernal_mat2 = (Mat_<float>(3, 3) <<
		1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
		2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
		1 / 16.0f, 2 / 16.0f, 1 / 16.0f);
	filter2D(temp_image, out_iamge2, -1, kernal_mat2);

    // 显示
	imshow("原图", temp_image);
	imshow("filter2D边缘锐化", out_iamge1);
	imshow("filter2D高斯平滑", out_iamge2);

    waitKey(0); 

    return 0;
}

参考:https://blog.csdn.net/gongjianbo1992/article/details/108431322

你可能感兴趣的:(C++,opencv,学习笔记,opencv,c++,计算机视觉)