OpenCV每日函数 图像过滤模块 (2) blur函数(归一化框滤波)

一、概述

        该函数使用内核平滑图像:

        调用blur函数

blur(src, dst, ksize, anchor, borderType)

        等价于调用boxFilter函数

boxFilter(src, dst, src.type(), ksize, anchor, true, borderType)

二、blur函数

1、函数原型

cv::blur (InputArray src, OutputArray dst, Size ksize, Point anchor=Point(-1,-1), int borderType=BORDER_DEFAULT)

2、参数详解 

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

三、OpenCV源码 

        由源码可知调用blur函数等价于调用boxFilter函数。

1、源码路径

opencv\modules\imgproc\src\box_filter.dispatch.cpp

2、源码代码

void blur(InputArray src, OutputArray dst,
          Size ksize, Point anchor, int borderType)
{
    CV_INSTRUMENT_REGION();

    boxFilter( src, dst, -1, ksize, anchor, true, borderType );
}

四、效果图像示例

原图
ksize = 5

ksize = 7

ksize = 11

猜你喜欢

转载自blog.csdn.net/bashendixie5/article/details/125234178