Poisson Noise Added in Image denoising using Pytorch

I am researching image-denoising. At first, I used a random Gaussian noise(AWGN) interval within the specified range using the following code. However, I am now extending to add the Poisson noise and mixed noise within the range interval. The question is np. random.poisson () accepts one interval and the size according to this np.random.poisson(lam=1.0, size=None). How can I solve this problem?

stdn = np.random.uniform(args.noiseIntL[0], args.noiseIntL[1],
for nx in range(noise.size()[0]):
sizen = noise[0, :, :, :].size()
noise[nx, :, :, :] = torch.FloatTensor(sizen).normal_(mean=0, std=stdn[nx])
imgn_train = img_train + noise

I don’t quite understand the problem. You can generate any shape with random.poisson like this:

np.random.poisson(lam=5.0, size=(10,5))

Thank you for your suggestion and comment. My question is, while AWGN noise can be easily added using PyTorch tensors, adding Poisson noise can only be accomplished using NumPy. Do you have any suggestions for adding Poisson noise using PyTorch tensors?

either this way:

poisson_numpy = np.random.poisson(lam=5.0, size=(10,5))
poisson_torch = torch.from_numpy(poisson_numpy)

or this way ( i don’t know whether this is mathematically equivalent, but it seems to be)


btw: you can generate gaussian distributed tensors of arbitrary shape using:


if you want to have different standard deviations along your batch dimension you can do something like this:


Thank you for your comment. I have implemented Poisson noise according to the following code. I am uncertain whether the use of torch.ones for noise addition is appropriate or not. Additionally, some research papers suggest that Poisson noise is signal-dependent, and the addition of the noise to the original image may not be accurate. Please give me suggestions and comments for this point.

noise = torch.zeros(img_train.size())
stdn = np.random.uniform(args.noiseIntL[0], args.noiseIntL[1], size=noise.size()[0])
for nx in range(noise.size()[0]):
sizen = noise[0, :, :, :].size()
noise[nx, :, :, :] = torch.poisson(
torch.ones(sizen) * stdn[nx]) # Pass a tensor of the same shape as noise
imgn_train = img_train + noise

as far as I understand the documentation the argument of torch.poisson corresponds to the lamda parameter of np.random.poisson. You just have the option do define different lambdas for different dimensions. This is why


makes actually sense. In this case all dimensions have the same lambda parameter.
Additionally you multiply a standard deviation to your lambda. I don’t see any reason why you should do that. Gaussian Noise is parameterized by standard deviation, but poisson noise is not. Its solely defined by the lambda (even though you can calculate a standard deviation for the poisson distribution).

I have found different Information in the internet on whether poisson noise is additive or not. Some say it is, others say it isn’t (https://perso.esiee.fr/~talboth/articles/Mine/Efficient_Poisson_Denoising_ICIP_2009_0003881.pdf).

You should be aware that adding poisson distributed random values can only make your image brighter and never darker, because they are strictly positive

I originally used std = np.random.uniform() to create different noise ranges, like 0 to 70, during neural network training. Later, I changed the code to use lambdas = torch.randint(76, size=(noise.size()[0],)) .