How to add Gaussian noise to an image?

2019-05-10 09:20发布

问题:

How to add a certain amount of Gaussian noise to the image in python? Do I need to convert somehow the values of the image to double type or something else?

Also, I have doubts about measuring the level of noise in the image. One adds it according to the dB (decibels) while other considers the variance. How it is related and how should I measure the noise level?

回答1:

You can use the random_noise function in scikit-image. It goes something like this:

skimage.util.random_noise(image, mode='gaussian', seed=None, clip=True, **kwargs)

You can read more about it here: http://scikit-image.org/docs/stable/api/skimage.util.html#random-noise



回答2:

I'm assuming you mean applying a Gaussian blur. Pillow (a Python Image Library fork) supports a lot of image processing methods, including Gaussian blur. The ImageFilter module in particular implements this.

As for how to measure the level of noise--that's a somewhat complicated question. The concepts of radius and variance are mostly related (this post discusses it to some degree). In practicality, for picking the right parameter here for image processing, theory is all well and good but I've found guess and try to be the best way here.

dB is generally related to Gaussian filters (at least on the topic of "Gaussian" things that can act on input signals), as in digital signal processing (DSP). Gaussian blur/filter are similar concepts as convolutions on input signals, but discussed in different domains. When talking about signals in DSP, it's a bit more natural to talk about dB for the filter response... as well as just comparing signals generally. I'm assuming this is not what you're talking about.