• 二十九、图像的高斯双边模糊操作


    项目功能实现:对一张图片进行高斯双边模糊操作
    按照之前的博文结构来,这里就不在赘述了

    高斯双边模糊考虑的是图像的x、y方向和RGB方向,两个边

    python版本可参考博文:八、边缘保留滤波(EPF)

    一、头文件

    bilateral_blur.h

    #pragma once
    
    #include
    
    using namespace cv;
    
    class Bilateral_Blur{
    public:
    	void bilateral_blur(Mat& image);
    };
    
    #pragma once
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    二、函数实现

    bilateral_blur.cpp

    bilateralFilter(image, result,0,100,10);
    参数一:要处理的图片对象
    参数二:返回结果存储对象
    参数三:邻域的直径,如果是小于等于 0,则由sigmaSpace系统计算得到
    参数四:颜色空间滤波器的标准差,值越大表示邻域中有更多的颜色被混合
    参数五:空域滤波器的标准差,值越大代表越大范围内的像素(颜色相近)会被相互影响

    #include"bilateral_blur.h"
    #include
    #include
    
    void Bilateral_Blur::bilateral_blur(Mat& image) {
    	Mat result;
    	GaussianBlur(image, result, Size(0, 0), 5, 5);
    	imshow("GaussianBlur", result);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    三、主函数

    yy_main.cpp

    #include 
    #include 
    #include"bilateral_blur.h"
    using namespace cv;
    using namespace std;
    
    int main(int argc, char** argv) {
    	Mat src = cv::imread("E:/C++_workspace/beyond.jpg", IMREAD_COLOR);
    
    	if (src.empty()) {
    		printf("load image is false...\n");
    		return -1;
    	}
    
    	namedWindow("yanyu", WINDOW_FREERATIO);
    	imshow("yanyu", src);
    
    	Bilateral_Blur yy;
    	yy.bilateral_blur(src);
    
    	waitKey(0);
    	destroyAllWindows();
    
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    项目结果如下:
    在这里插入图片描述

    运行结果如下:
    在这里插入图片描述

  • 相关阅读:
    如何解决.NET8 类库Debug时,Debug文件夹中不包含Packages中引入的文件
    17【redux】
    计算机跨考现状,两极分化现象很严重
    2022.8.2 模拟赛
    python SO3 & so3 BCH近似计算
    leetcode:575. 分糖果(python3解法)
    基于技能优化算法的函数寻优算法
    分布式文件系统
    leetcode刷题日记之做菜顺序
    VS Code 配置Latex
  • 原文地址:https://blog.csdn.net/qq_41264055/article/details/136257948