scikit-image provides a function random_noise
which is similar to imnoise
in MATLAB.
skimage.util.random_noise(image, mode='gaussian', seed=None, clip=True, **kwargs)
It supports the following modes:
‘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.
‘s&p’ Replaces random pixels with 0 or 1.
‘speckle’ Multiplicative noise using out = image + n*image, where
n is uniform noise with specified mean & variance.
Note that one difference from imnoise
in MATLAB is that the output of this function would always be a floating-point image.
If the input image is a uint8
grayscale image for instance, it would be converted to float at first, but the output image wouldn't be converted to the same class as the input image.
Therefore if you care about the class of image, you should convert the output by yourself, for example using skimage.img_as_ubyte
.