图像增强之加噪

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/char_QwQ/article/details/83825171

参考博客:Python-图像加噪实现(Gaussian noise+salt and pepper noise)

高斯噪声

高斯噪声(Gaussian noise)是指它的概率密度函数服从高斯分布的一类噪声。

如果一个噪声,它的幅度分布服从高斯分布,而它的功率谱密度又是均匀分布的,则称它为高斯白噪声。

高斯噪声是指噪声的概率密度函数服从高斯分布,白噪声是指噪声的任意两个采样样本之间不相关,两者描述的角度不同。


使用Python中的skimage库对图像进行增强

from skimage.util import random_noise
image =  random_noise(img, mode='gaussian', seed=13, clip=True)*255
输入:
        img:图像
        mode:噪声模式
        seed:噪声随机种子
        clip:切掉超出的像素值
输出:
        加噪后的图像

mode可选参数:

‘gaussian’ Gaussian-distributed additive noise.
‘localvar’ Gaussian-distributed additive noise, with specified local variance at each point of image
‘poisson’ Poisson-distributed noise generated from the data.
‘salt’ Replaces random pixels with 1.
‘pepper’ Replaces random pixels with 0 (for unsigned images) or -1 (for signed images).
‘s&p’ Replaces random pixels with either 1 or low_val, where low_val is 0 for unsigned images or -1 for signedimages.
‘speckle’ Multiplicative noise using out = image + n*image, where n is uniform noise with specified mean & variance.

注意事项:

Peckle, Poisson, Localvar, and Gaussian noise 加上噪声后,值可能为负值,也可能超过255;默认情况下,clip参数值为True,将会clip掉这些超过区间的点,如果clip设置为False,就要注意有可能包含一些超过区间的点。

Skimage读取图像是RGB,而Opencv是BGR

Skimage读取图像后是(height, width, channel)

加噪效果:

原始图像:                                                                                         

高斯噪声:

  

盐噪声:                                                                                            椒噪声:

                       


                          啊啊啊我女神加了噪声也那么好看!!!

猜你喜欢

转载自blog.csdn.net/char_QwQ/article/details/83825171