opencv4学习总结-图像模糊

盒子模糊(normalize设置为true就相当于均值模糊,跟blur函数一样)

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

using namespace cv;
using namespace std;


int main()
{
    Mat src = imread("E:/opencv_source/opencv_tutorial_data-master/images/home.jpg");
    imshow("src", src);

    Mat dst;
    boxFilter(src, dst, -1, Size(10, 10), Point(-1, -1), true, BORDER_DEFAULT);
    imshow("dst", dst);

    waitKey(0);
    destroyAllWindows();

    return 0;
}

高斯滤波(核尺寸得是奇数)

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

using namespace cv;
using namespace std;


int main()
{
    Mat src = imread("E:/opencv_source/opencv_tutorial_data-master/images/home.jpg");
    imshow("src", src);

    Mat dst;
    GaussianBlur(src, dst, Size(11, 11), 0);
    imshow("dst", dst);

    waitKey(0);
    destroyAllWindows();

    return 0;
}