• OpenCV 去噪函数 fastNlMeansDenoising


    CV2.fastNlMeansDenoising(非局部平均去噪)
      L-Means的全称是:Non-Local Means,直译过来是非局部平均,在2005年由Baudes提出,该算法使用自然图像中普遍存在的冗余信息来去噪声。与常用的双线性滤波、中值滤波等利用图像局部信息来滤波不同的是,它利用了整幅图像来进行去噪,以图像块为单位在图像中寻找相似区域,再对这些区域求平均,能够比较好地去掉图像中存在的高斯噪声。与我们以前学习的平滑技术相比这种算法要消耗更多的时间,但是结果很好。对于彩色图像,要先转换到 CIELAB 颜色空间,然后对 L 和 AB 成分分别去噪。

    1 cv2.fastNlMeansDenoising() - 使用单个灰度图像
    2 cv2.fastNlMeansDenoisingColored() - 使用彩色图像。
    3 cv2.fastNlMeansDenoisingMulti() - 用于在短时间内捕获的图像序列(灰度图像)
    4 cv2.fastNlMeansDenoisingColoredMulti() - 与上面相同,但用于彩色图像。
    1 fastNlMeansDenoisingColored( InputArray src, OutputArray dst,
    2                                                float h = 3, float hColor = 3,
    3                                                int templateWindowSize = 7, int searchWindowSize = 21)

    共同参数有:
    • h : 决定过滤器强度。h 值高可以很好的去除噪声,但也会把图像的细节抹去。(取 10 的效果不错)
    • hForColorComponents : 与 h 相同,但使用与彩色图像。(与 h 相同,10)
    • templateWindowSize : 奇数。(推荐值为 7)
    • searchWindowSize : 奇数。(推荐值为 21)

     1 import numpy as np
     2 import cv2
     3 import matplotlib.pyplot as plt
     4 filePath = r'F:\主题一:遥感图像场景分类\val\val\水田\paddy-field_00076.jpg'
     5 img = cv2.imdecode(np.fromfile(filePath,dtype=np.uint8),-1)
     6 dst = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 21)
     7 
     8 plt.subplot(121), plt.imshow(img)
     9 plt.subplot(122), plt.imshow(dst)
    10 plt.show()

  • 相关阅读:
    vue2.0是不支持通过下标来更改数组的,无法做到响应式
    C# 深拷贝 Bitmap对象示例
    vscode终端中文乱码
    TkbmMemTable使用总结
    openssl 证书概念介绍
    openssl源码介绍
    python变量赋值特性
    openssl安装
    github开源协议选择
    NLP 多分类神经网络
  • 原文地址:https://www.cnblogs.com/ybqjymy/p/15936057.html
Copyright © 2020-2023  润新知