Opencv 名词解释_GaussianBlur函数_高斯滤波

函数原型:

    void GaussianBlur(InputArray src, OutputArray dst, Size ksize, double sigmaX, double sigmaY=0, int borderType=BORDER_DEFAULT);

参数详解:

  1. src,输入图像,即源图像,填Mat类的对象即可。它可以是单独的任意通道数的图片,但需要注意,图片深度应该为CV_8U,CV_16U, CV_16S, CV_32F 以及 CV_64F之一。
  2. dst,即目标图像,需要和源图片有一样的尺寸和类型。比如可以用Mat::Clone,以源图片为模板,来初始化得到如假包换的目标图
  3. ksize,高斯内核的大小。其中ksize.width和ksize.height可以不同,但他们都必须为正数和奇数(并不能理解)。或者,它们可以是零的,它们都是由sigma计算而来。
  4. sigmaX,表示高斯核函数在X方向的的标准偏差。
  5. sigmaY,表示高斯核函数在Y方向的的标准偏差。若sigmaY为零,就将它设为sigmaX,如果sigmaX和sigmaY都是0,那么就由ksize.width和ksize.height计算出来。(为了结果的正确性着想,最好是把第三个参数Size,第四个参数sigmaX和第五个参数sigmaY全部指定到。)
  6. borderType,用于推断图像外部像素的某种边界模式。注意它有默认值BORDER_DEFAULT。

ps:
高斯核函数:自己找找看,其实看上去就是普通的正态分布函数形式。
我猜ksize是模糊半径的意思,水平方向和竖直方向的半径不一样,需要指定。
标准偏差就是标准偏差……

英文:
Parameters:
src – input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
dst – output image of the same size and type as src.
ksize – Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero’s and then they are computed from sigma* .
sigmaX – Gaussian kernel standard deviation in X direction.
sigmaY – Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height , respectively (see getGaussianKernel() for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.
borderType – pixel extrapolation method (see borderInterpolate() for details).

Demo:
#include “cv.h”
#include “highgui.h”
using namespace cv;

int main(int argc, char** argv) {
Mat img, gray, edges;
img = imread(argv[1]);
cvtColor(img, gray, CV_BGR2GRAY);
GaussianBlur(gray, gray, Size(13, 13), 2, 2);
imshow(“gray”, gray);
waitKey(0);
return 0;
}

运行方法:

g++ test.cpp -o test `pkg-config --cflags --libs opencv`
./test1.png

结果:
当ksize:(5, 5) -> (13, 13) ->(23,23)时,后两者差别已经很小了。
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
当sigmaX, sigmaY由(1, 1) -> (2, 2) -> (3, 3)时,明显会变化很多
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值