Pregunta

For every pixle of one image,I have its x(int),y(int) and pixel value(float number).

Now I need to add noise to the image.Is numpy.random.poisson appropriate?

I am worried about it because it is not like new pixle value=original value+noise,but like

new pixle value=numpy.random.poisson(original value,1) .And the new values are all integers.

My question is as the title.

My purpose is to get a photometry measurement error for a star.But I have only one iamge.So I do a simulation via adding poisson noise. Please check the figure got from the ccd image below.The source is the red feature.

enter image description here

¿Fue útil?

Solución

This is an old thread, but I know the answer to this, so here goes.

The answer is yes.

imageplusshotnoise = numpy.random.poisson(lam=<noiseless_simulated_image>, size=None)

This will produce a sample image from a Poisson distribution for each pixel of the original image. Poisson distributions have a special property where the mean and the variance are equal. This means that if the mean is say 100 counts that the variance will be 100; hence, the shot noise will have a standard deviation of 10 (variance is equal to the standard deviation squared).

Create a numpy image array with all the values equal to 100

>>> myimage = 100 * np.ones((100,100))
>>> np.mean(myimage)
100.0
>>> np.std(myimage)
0.0

Note that the mean is 100 and the standard deviation is 0 as expected

Now using this image as the lambda of a Poisson distribution will produce a sample from that distribution with the same size

>>> imageplusnoise = np.random.poisson(lam=myimage, size=None)
>>> imageplusnoise.shape
(100, 100)

The mean of the sample will have the same mean as the lambda, but the standard deviation will be equal to the sqrt of the variance, which in a Poisson distribution is equal to the mean.

>>> np.mean(imageplusnoise)
100.0474
>>> np.std(imageplusnoise)
10.015934965843179

To obtain only the shot noise, simple subtract lambda from it and now the mean will be close to zero (if the mean is small, the mean noise will start skewing further from zero), but it will always have the same standard deviation.

>>> noiseonlyimage = imageplusnoise - myimage
>>> np.mean(noiseonlyimage)
0.047399999999999998
>>> np.std(noiseonlyimage)
10.015934965843179

It should be pointed out here that the lam argument is the expectation value of the Poisson distribution and is noiseless. Your starting image looks like it already has noise, so I would start out by modeling the star response through your aperture to obtain the noiseless image say using some point spread function like an airy disk, sinc function or similar as the input to the numpy.random.poisson function.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top