OPENCV对图像进行简单平滑处理BLUR

参考来源:https://docs.opencv.org/3.4/dc/dd3/tutorial_gausian_median_blur_bilateral_filter.html

switch(SMOOTH_METHOD)
    {
      case NO_BLUR: img2 = img; break;
      case HOMO_BLUR: cv::blur(img, img2, cv::Size(KERNEL_LENGTH, KERNEL_LENGTH), cv::Point(-1,-1) ); break;
      case GAUSS_BLUR: cv::GaussianBlur(img, img2, cv::Size(KERNEL_LENGTH, KERNEL_LENGTH), 0, 0 ); break;
      case MEDIAN_BLUR: cv::medianBlur(img, img2, KERNEL_LENGTH); break;
      case BILATERAL_BLUR: cv::bilateralFilter(img, img2, KERNEL_LENGTH, KERNEL_LENGTH*2, KERNEL_LENGTH/2); break;
      default: return;
    }

Normalized Box Filter

  • This filter is the simplest of all! Each output pixel is the mean of its kernel neighbors ( all of them contribute with equal weights)

 简单均值滤波器

  • src: Source image
  • dst: Destination image
  • Size( w, h ): Defines the size of the kernel to be used ( of width w pixels and height h pixels)
  • Point(-1, -1): Indicates where the anchor point (the pixel evaluated) is located with respect to the neighborhood. If there is a negative value, then the center of the kernel is considered the anchor point. 

Gaussian Filter 

  • Probably the most useful filter (although not the fastest). Gaussian filtering is done by convolving each point in the input array with a Gaussian kernel and then summing them all to produce the output array.
  • src: Source image
  • dst: Destination image
  • Size(w, h): The size of the kernel to be used (the neighbors to be considered). w and h have to be odd and positive numbers otherwise the size will be calculated using the σx and σy arguments.
  • σx: The standard deviation in x. Writing 0 implies that σx is calculated using kernel size.
  • σy: The standard deviation in y. Writing 0 implies that σy is calculated using kernel size.

高斯滤波器:最常用但也比较耗时

Median Filter

  • The median filter run through each element of the signal (in this case the image) and replace each pixel with the median of its neighboring pixels (located in a square neighborhood around the evaluated pixel).
  • src: Source image
  • dst: Destination image, must be the same type as src
  • i: Size of the kernel (only one because we use a square window). Must be odd.奇数

中值滤波器:去周围元素的中值 

Bilateral Filter

  • So far, we have explained some filters which main goal is to smooth an input image. However, sometimes the filters do not only dissolve the noise, but also smooth away the edges. To avoid this (at certain extent at least), we can use a bilateral filter.
  • In an analogous way as the Gaussian filter, the bilateral filter also considers the neighboring pixels with weights assigned to each of them. These weights have two components, the first of which is the same weighting used by the Gaussian filter. The second component takes into account the difference in intensity between the neighboring pixels and the evaluated one.
  • src: Source image
  • dst: Destination image
  • d: The diameter of each pixel neighborhood.
  • σColor: Standard deviation in the color space.
  • σSpace: Standard deviation in the coordinate space (in pixel terms)

 双边滤波器:表面一定程度上边缘模糊。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值