OpenCV3(滤波篇) ---- blur模糊函数

blur使用归一化框过滤器模糊图像,是一种简单的模糊函数,是计算每个像素中对应核的平均值。

效果:
在这里插入图片描述
函数原型:

CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
                        Size ksize, Point anchor = Point(-1,-1),
                        int borderType = BORDER_DEFAULT );

src:输入图像;它可以有任意数量的通道,这些通道是独立处理的,但是深度应该是CV_8U, CV_16U, CV_16S, CV_32F或CV_64F。
dst:输出与src相同大小和类型的图像。
ksize:模糊核的大小。
anchor :锚点;默认值点(-1,-1)表示锚点在内核中心。
borderType :边界模式用于外推像素的图像

代码:

void example()
{
    
    
    cv::Mat input = cv::imread("C:\\Users\\chuan\\Desktop\\picture\\test.jpg"), output;
    cv::namedWindow("example");
    int size = 1, anchor_test = -1, anchor = -1;
    cv::createTrackbar("Size", "example", &size, 20);
    cv::createTrackbar("anchor", "example", &anchor_test, 20);
    for(;;)
    {
    
    
        anchor = anchor_test;
        if(anchor_test >= size)
            anchor = size-1;

        cv::blur(input, output, cv::Size(size,size) , cv::Point(anchor,anchor));
        cv::imshow("example", output);
        if(cv::waitKey(100) == 27)
            break;
    }

}

猜你喜欢

转载自blog.csdn.net/qq_42401265/article/details/107781501