0
点赞
收藏
分享

微信扫一扫

【OpenCV 完整例程】91. 高斯噪声、瑞利噪声、爱尔兰噪声

【OpenCV 完整例程】91. 高斯噪声、瑞利噪声、爱尔兰噪声


2. 噪声模型

数字图像中的噪声源主要来自图像获取和传输过程。在获取图像时,光照水平和传感器温度影响图像中的噪声。在传输图像时,传输信道中的干扰对图像产生污染。


2.1 高斯噪声(Gauss Noise)

高斯噪声中空间域和频率域中都很方便进行数学处理,因而得到了广泛的应用。

高斯噪声的概率密度函数为:
p ( z ) = 1 2 π σ e − ( z − z ˉ ) 2 / 2 σ 2 p(z) = \frac{1}{\sqrt{2\pi} \sigma} e^{-(z-\bar{z})^2/2\sigma ^2} p(z)=2π σ1e(zzˉ)2/2σ2

高斯噪声的均值为 z ˉ \bar{z} zˉ,标准差为: σ 2 \sigma ^2 σ2


例程 9.1:高斯噪声(Gauss Noise)

    # 9.1:高斯噪声 (GaussNoise)
    img = cv2.imread("../images/Fig0503.tif", 0)  # flags=0 读取为灰度图像
    # img = np.ones([256, 256]) * 128

    mu, sigma = 0.0, 20.0
    noiseGause = np.random.normal(mu, sigma, img.shape)
    imgGaussNoise = img + noiseGause
    imgGaussNoise = np.uint8(cv2.normalize(imgGaussNoise, None, 0, 255, cv2.NORM_MINMAX))  # 归一化为 [0,255]

    plt.figure(figsize=(9, 3))
    plt.subplot(131), plt.title("Origin"), plt.axis('off')
    plt.imshow(img, 'gray', vmin=0, vmax=255)
    plt.subplot(132), plt.title("GaussNoise"), plt.axis('off')
    plt.imshow(imgGaussNoise, 'gray')
    plt.subplot(133), plt.title("Gray Hist")
    histNP, bins = np.histogram(imgGaussNoise.flatten(), bins=255, range=[0, 255], density=True)
    plt.bar(bins[:-1], histNP[:])
    plt.tight_layout()
    plt.show()

在这里插入图片描述


2.2 瑞利噪声 (Rayleigh Noise)

瑞利噪声的概率密度函数为
p ( z ) = { 2 / b ∗ ( z − a ) e − ( z − a ) 2 / b , z ≥ a 0 , z < a p(z) = \begin{cases} 2/b * (z-a) e^{-(z-a)^2 /b} &, z \ge a\\ 0&, z < a \end{cases} p(z)={2/b(za)e(za)2/b0,za,z<a

瑞利噪声的均值和标准差为:
z ˉ = a + π b / 4 σ 2 = b ( 4 − π ) / 4 \bar{z} = a + \sqrt{\pi b/4} \\ \sigma ^2 = b(4-\pi)/4 zˉ=a+πb/4 σ2=b(4π)/4

瑞利噪声概率密度分布到原点的距离及密度的基本形状右偏,常用于倾斜形状直方图的建模。


例程 9.2:瑞利噪声 (Rayleigh Noise)

    # # 9.2:瑞利噪声  (RayleighNoise)
    img = cv2.imread("../images/Fig0503.tif", 0)  # flags=0 读取为灰度图像
    # img = np.ones([256, 256]) * 128

    a = 30.0
    noiseRayleigh = np.random.rayleigh(a, size=img.shape)
    imgRayleighNoise = img + noiseRayleigh
    imgRayleighNoise = np.uint8(cv2.normalize(imgRayleighNoise, None, 0, 255, cv2.NORM_MINMAX))  # 归一化为 [0,255]

    plt.figure(figsize=(9, 3))
    plt.subplot(131), plt.title("Origin"), plt.axis('off')
    plt.imshow(img, 'gray', vmin=0, vmax=255)
    plt.subplot(132), plt.title("RayleighNoise"), plt.axis('off')
    plt.imshow(imgRayleighNoise, 'gray')
    plt.subplot(133), plt.title("Gray Hist")
    histNP, bins = np.histogram(imgRayleighNoise.flatten(), bins=255, range=[0, 255], density=True)
    plt.bar(bins[:-1], histNP[:])
    plt.tight_layout()
    plt.show()

在这里插入图片描述


2.3 爱尔兰噪声 (Ireland Noise)

爱尔兰噪声的概率密度函数为
p ( z ) = { a b z b − 1 ( b − 1 ) ! e − a z , z ≥ 0 0 , z < 0 p(z) = \begin{cases} \frac{a^b z^{b-1}}{(b-1)!} e^{-az} &, z \ge 0\\ 0&, z < 0 \end{cases} p(z)={(b1)!abzb1eaz0,z0,z<0

爱尔兰噪声的均值和标准差为:
z ˉ = b / a σ 2 = b / a 2 \bar{z} = b/a \\ \sigma ^2 = b/a^2 zˉ=b/aσ2=b/a2

当标准差的分母 a 2 a^2 a2为伽马函数时,称为伽马噪声。


例程 9.3:伽马噪声 (Gamma Noise)

    # # 9.3:伽马噪声 (Gamma Noise)
    img = cv2.imread("../images/Fig0503.tif", 0)  # flags=0 读取为灰度图像
    # img = np.ones([256, 256]) * 128

    a, b = 10.0, 2.5
    noiseGamma = np.random.gamma(shape=b, scale=a, size=img.shape)
    imgGammaNoise = img + noiseGamma
    imgGammaNoise = np.uint8(cv2.normalize(imgGammaNoise, None, 0, 255, cv2.NORM_MINMAX))  # 归一化为 [0,255]

    plt.figure(figsize=(9, 3))
    plt.subplot(131), plt.title("Origin"), plt.axis('off')
    plt.imshow(img, 'gray', vmin=0, vmax=255)
    plt.subplot(132), plt.title("Gamma noise"), plt.axis('off')
    plt.imshow(imgGammaNoise, 'gray')
    plt.subplot(133), plt.title("Gray hist")
    histNP, bins = np.histogram(imgGammaNoise.flatten(), bins=255, range=[0, 255], density=True)
    plt.bar(bins[:-1], histNP[:])
    plt.tight_layout()
    plt.show()

在这里插入图片描述


(本节完)


版权声明:

youcans@xupt 原创作品,转载必须标注原文链接

Copyright 2021 youcans, XUPT

Crated:2022-2-1


举报

相关推荐

0 条评论