Reputation: 5417
I'm having a little bit of trouble using numpy.random.normal. At the bottom of this link (http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.normal.html) there's a graph which shows standard deviations. I'm a little confused about this, because it doesn't look like 0.1, 0.2, 0.3 etc. standard deviations. It also doesn't look like 1, 2, or 3 standard deviations.
What I'm trying to do is to add noise to an image at specific standard deviations. However, the results I get are honestly pretty weird. My code (in Python) is shown below:
poisson = float((raw_input("Noise standard deviation: ")))
.
.
.
name = t+'PHOTO'+s+str(i)+'.fits'
im = pf.open(name)
isinstance(im,list)
im0 = im[0]
poissonNoise = np.random.normal(0,poisson/1000, im0.data.shape).astype(float)
test = im0.data + poissonNoise
im0.data = test
stringee = 'NOISE'
pf.writeto(stringee+str(poisson)+name, data=test, clobber=True, header=im0.header)
print poisson
If you notice, I divide "poisson" by 1000 in order to get meaningful results. So what is the real value of the standard deviation, and how do I use it? All I want to do is to be able to input 1, 2, 3, etc. standard deviations and create that much noise.
Upvotes: 0
Views: 377
Reputation: 8400
It seems you're mixing things together. On the figure of discussion in the question
X
axis is just X
values not Standard Deviations
. Remember that, for one distribution (here, Normal
) there is only one single value standard deviation which can be computed easily, numpy.std
.
BTW, your code is not quiet Python
code. What is this: isinstance(im,list)
for? Also remember that, indentation is heart of Python.
Upvotes: 2