I am writing a code to augment the image by injecting noise in it. I got the code for Gaussian, Speckle, Salt and Pepper, etc but I could not find how to add Poisson noise? Some people use is at image + mask
but the thing is that I don't think it is additive in nature just like Gaussian noise. I think doing the thing below won't make any sense:
noise_mask = numpy.random.poisson(img)
noisy_img = img + noise_mask
But I can do the same for Gaussian
Noise where I can control the amount of noise by changing the Standard Deviation (Can I change Mean too?):
def gauss(img): # img is numpy array image
gauss = np.random.normal(0,1,img.size) # mean=0, std=1
gauss = gauss.reshape(img.shape[0],img.shape[1],img.shape[2])
return img + gauss
So I found a code for Poisson
which does this:
def poisson(img):
vals = len(np.unique(img))
vals = 2 ** np.ceil(np.log2(vals))
return np.random.poisson(img * vals) / float(vals)
- Is this the right approach?
- How can I control the amount of Noise here?