Search code examples
pythonimage-processingnumpygaussiannoise

Adding RMS noise to an image


I have a two dimensional array representing an image. I have to add background gaussian noise of RMS 2 units to the image. I am unfamiliar with RMS measurement of noise and how to add it. Can you give me an insight on how to do this ?


Solution

  • The way I understand it, you want to add white noise following a Gaussian distribution at every pixel. That could be achieved by something like this

    from scipy import stats
    my_noise=stats.distributions.norm.rvs(0,2,size=your_array.shape)
    your_array+=my_noise
    

    Here, 0 is the mean and 2 the standard deviation of your distribution.