图像处理滤波器(二)——中值滤波器(Median Filter)

描述:中值滤波器也是为了减少噪声,跟均值滤波器差不多,但是它比均值滤波器保留更多的细节。


什么是中值滤波器?


中值滤波器也是模板滤波器,不过此处的模板只是一个模板,里面没有数字而已。就想入下图所示:



此处展示的是一个3*3的模板,由图上可以看出中值滤波器就是取模板覆盖区域的排序之后的中间值作为该模板区域内中心的像素值。


Code:


  /**
   * Takes a 2D input image array and a kernel and a pixel location and 
   * calculates the new pixel value by calculating the median of its 
   * neighbours.
   *
   * @param input the 2D image array
   * @param kernel the kernel array
   * @param w the width of the input image
   * @param h the height of the input image
   * @param x the x coordinate of the pixel at the centre of the neighbourhood
   * @param y the y coordinate of the pixel at the centre of the neighbourhood
   * 
  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值