Newsgroups: sci.image.processing
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!newshost.marcam.com!zip.eecs.umich.edu!newsxfer.itd.umich.edu!gatech!howland.reston.ans.net!pipex!uunet!psinntp!newsserver.pixel.kodak.com!usenet
From: John D'Errico <derrico@pixel.kodak.com>
Subject: Re: Anyone has the src for generating Gaussian noise to an  image?
Message-ID: <CzBE81.G1t@newsserver.pixel.kodak.com>
X-Xxdate: Tue, 15 Nov 94 10:13:48 GMT
Sender: usenet@newsserver.pixel.kodak.com
Organization: Eastman Kodak Company
X-Useragent: Nuntius v1.1.1d11
References: <3a3l32$529@narnia.ccs.neu.edu>
Date: Tue, 15 Nov 1994 15:11:58 GMT
Lines: 50

In article <3a3l32$529@narnia.ccs.neu.edu> sibel z. tari,
sibel@ccs.neu.edu writes:
>Noise = (a+b+c-1.5)*2;  where a,b,c are random numbers in [0,1]
>                         Noise is a gaussian noise with 0 mean and
variance 1

Well, I hate to be picky, but this is not really gaussian noise, but
just a simple approximation. The law of large numbers says that if
we sum enough independent, identically distributed uniform random
numbers, then that sum will tend to a normal distribution. Sorry,
but 3 is not very large. If it were, then the 3 dollars in my pocket
would mean that I were independently wealthy.

My point is, that if you really want GAUSSIAN noise, then what you
get from this is actually quite a poor approximation in terms of its
tails. For example, the noise generated by this process will never
extend beyond +/- 1.5*sigma. (I do admit that within the region
[-1.5, 1.5] the approximation is not too bad.) Roughly 13% of true
gaussian noise will fall outside of that range however. Since the
question asks about adding noise to an image, the requestor will be
generating many thousands or millions of random deviates.

Finally, since the noise is to be added to an image, the noise will
be rounded to the nearest integer. Note that if you rounded the noise
from the generator given above, it would not have the same properties
as gaussian noise with standard deviation unity. The standard deviation
of the rounded noise would be roughly 4% larger than desired.

I would suggest that what the requestor might actually want is discrete
noise that is gaussian in shape with the desired distribution parameters.
This is doable quickly for an image by generating a single uniform random 
deviate, and then doing a table lookup to get the rounded "gaussian"
deviate. (I won't get into how to build such a table here.)

Another simple alternative is to use a sum of more than 3 uniform random
numbers. I'd suggest 12 as being close enough to infinity for this
purpose. 12 also eliminates any multiplication since the sum is already
appropriately scaled to have the correct variance. Thus, sum 12 uniform
[0,1] random numbers. Subtract 6. Thats all. Note that these deviates
can go as far as +/- 6 sigma. Only a few events in a million happen
which fall outside of that range.

-----------------------------------------------------
My opinions are only - my opinions. No more, no less.

John R. D'Errico
Senior Applied Mathematician
Eastman Kodak Company
derrico@pixel.kodak.com
-----------------------------------------------------
