Opencv C++成长之路(五):高斯滤波

版权声明:——转载请留言询问—— https://blog.csdn.net/weixin_44344462/article/details/88742738

高斯滤波结果

原图像
在这里插入图片描述
高斯滤波结果
在这里插入图片描述

Show me the code

#include <iostream>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <string>
#include <cmath>

using namespace std;

int main() {
    // 图像路径
    const string fileName = "xxx.jpg";
    
    // 读入图片
    cv::Mat origin = cv::imread(fileName);
    
    // 创建结果存放位置
    cv::Mat result;
    
    // 设置滤波sigma
    const float sigma = 5;
    
    // 高斯滤波
    cv::GaussianBlur(origin,
                     result,
                     cv::Size(0, 0),
                     sigma);
    
    // 显示原图
    cv::imshow("Origin Image", origin);
    
    // 显示高斯滤波后的图像
    cv::imshow("Result", result);
    
    cv::waitKey(0);
}

猜你喜欢

转载自blog.csdn.net/weixin_44344462/article/details/88742738
今日推荐