OpenCV 4.1.1 图像模糊(C++)

图像模糊有均值模糊和高斯模糊两种

均值模糊:blur(Mat src,Mat dst, size(xradius, yradius),Point(-1,-1));
高斯模糊:GaussianBlur(Mat src,Mat dst, size(11,11), sigmax, sigmay); 其中size ( x,y ) ,x,y必须是正数而且是奇数
#include<opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;

int main()
{
    
    
    Mat src, dst,dst2;
    src = imread("C:/Users/Lenovo/Desktop/新建文件夹/ConsoleApplication3/lly.jpg");
    if (!src.data)
    {
    
    
        cout << "image could not load..." << endl;
        return -1;
    }
    string int_put_window = "intput";
    string out_put_window = "blur_output";
    string out_put_window2 = "gaussianblur_output";
    blur(src, dst, Size(5, 5), Point(-1, -1));
    GaussianBlur(src, dst2, Size(5, 5), 11, 11);

    namedWindow(out_put_window, WINDOW_AUTOSIZE);
    namedWindow(int_put_window, WINDOW_AUTOSIZE);
    namedWindow(out_put_window2, WINDOW_AUTOSIZE);
    imshow(int_put_window, src);
    imshow(out_put_window, dst);
    imshow(out_put_window2, dst2);

    waitKey(0);
    return 0;
}
正常图片和均值模糊对比

在这里插入图片描述

均值模糊和高斯模糊对比

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Huo6666/article/details/107581009