ddxxdds
ddxxdds

Reputation: 393

Adding poisson noise to an image with specific mean.

How do I add Poisson noise with a specific mean of Poisson distribution in Matlab? The code below gives me a completely white image.

img = im2double(phantom(512));
figure; imshow(img)
mean = 1e9;
R = poissrnd(mean, [512, 512]);
J = img + R;
figure; imshow(J);

Upvotes: 2

Views: 4153

Answers (2)

Cris Luengo
Cris Luengo

Reputation: 60494

Typically, when adding Poisson noise to an image, you want to use the pixel's value as the mean (after scaling appropriately). This more closely would match Poisson noise in image acquisition.

For example, say your image, which is in the range 0-1 after im2double, was acquired in a photon-limited microscope. And let's say that the scaling is such that 1e9 photons on one pixel are represented as a pixel value of 1. To simulate the photon noise here, this one pixel with a (noiseless) value of 1 will have a (noisy) value of poissrnd(1e9)/1e9. Another pixel with a value of 0.5 will have a value of poissrnd(1e9*0.5)/1e9.

In the Image Processing Toolbox there is a function imnoise that does exactly this when called as follows:

img = imnoise(img,'poisson');

This function uses a scaling of 1e12. You wanted a scaling of 1e9, so you'll have to divide your image by 1e3:

img = imnoise(img/1e3,'poisson')*1e3;

Upvotes: 4

Ander Biguri
Ander Biguri

Reputation: 35525

The way you are doing it is good. Your mean is 1000000000 therefore the numbers are very very big.

However to show an image with auto-scaled colormap, do:

img = im2double(phantom(512));
figure; imshow(img,[])
mean = 1e9;
R = poissrnd(mean, [512, 512]);
J = img + R;
figure; imshow(J,[]);

Note the square brakets.

Upvotes: 2

Related Questions