【OpenCV】双边滤波

双边滤波(Bilateral filter)是一种非线性的滤波方法,是结合图像的空间邻近度和像素值相似度的一种折衷处理,同时考虑空域信息和灰度相似性,达到保边去噪的目的。具有简单、非迭代、局部的特点。
 
Bilateral Filtering for Gray and Color Images可以看看这里的解析,里面讲的很详细。
 
C++的函数原型:voidbilateralFilter(InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT)
 
C: void cvSmooth (const CvArr* src, CvArr* dst, int smoothtype=CV_GAUSSIAN, int param1=3, int param2=0, double param3=0, double param4=0 )

CV_BILATERAL bilateral filter with a \texttt{param1}\times\texttt{param1} square aperture, color sigma= param3 and spatial sigma= param4 . If param1=0 , the aperture square side is set to cvRound(param4*1.5)*2+1 .

 

这里面double sigmaColor, double sigmaSpace分别是像素值相似度和邻近相似度的方差,int d为滤波的直径。

   //中值滤波
     cvSmooth(pImg,pDst1,CV_BILATERAL,5,0,150,150);
    cvSmooth(pImg,pDst2,CV_BILATERAL,12,0,150,150);
    cvSmooth(pImg,pDst3,CV_BILATERAL,25,0,150,150);


滤波的结果:

原图:

原图

 

square aperture=5结果

square aperture=5

 

square aperture=12结果

square aperture=12

 

square aperture=25

square aperture=25

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值