Page 1 of 1

Evaluate Gaussian Noise

Posted: 2009-10-13T19:43:15-07:00
by anthony
I am having trouble with Evaluate Gaussian Noise.

Creating a 100x100 50% gray image and adding noise to it should get a pretty uniform histogram of the noise that was added.

For example...

Code: Select all

   convert -size 100x100 xc:gray50 -evaluate gaussian-noise 0.1 histogram:guassian_noise_0.1.gif
Image
shows a rather nice histogram of the gaussian noise that was generated. That is it follows a very nice an clear bell curve, though it is very narrow to what I need.

Increasing the noise factor and instead of a steadily increasing the value works but only until it reaches a value of 0.125, where it suddenly goes crazy!

Code: Select all

   convert -size 100x100 xc:gray50 -evaluate gaussian-noise 0.125 histogram:gaussian_noise_0.125.gif
Image
A valus of 0.124 produces a result similar to the previous example. But as you can see a value of 0.125 suddenly produces a result where most values are being clipped to the range limits (the sides of the above histogram). Almost like the value suddely becomes very very large!

Just to give you something to compare too. This is the histogram of purely random noise, without any clipping.

Code: Select all

convert -size 100x100 xc:gray50 +noise random histogram:random_noise.gif
Image

Something is not right with the handling of the value in -evaluate Gaussian-noise.

Re: Evaluate Gaussian Noise

Posted: 2009-10-13T19:55:34-07:00
by fmw42
it is a narrow gaussian, but could be correct as we only have control over the amplitude and not the width (rollo-off) ie sigma.

shows the same thing with

-attenuate 0.1 +noise Gaussian

Re: Evaluate Gaussian Noise

Posted: 2009-10-13T20:38:37-07:00
by anthony
But isn't the value adjusting the amount that is added/subtracted from the existing values? In that case the histogram should show the width changing. It doesn't.

The histogram of the image without any changes is a single value 'impulse' for the solid color that is present. Small gaussian values produce a small curve.

But then why the sudden change from a nice guassian curve to a clipped numbers (most number suddenly becomming maximum and minimum values) somewhere between 0.124 and 0.125 that does not make sense! gaussian is a smooth function so should smoothly change regardless of what the value is adjusting!

Re: Evaluate Gaussian Noise

Posted: 2009-10-21T19:17:33-07:00
by anthony
this bug has come up in a user discussion...
viewtopic.php?f=1&t=14850

Re: Evaluate Gaussian Noise

Posted: 2009-10-22T07:56:11-07:00
by magick
We can reproduce the problem you posted and will have a patch in the Subversion trunk by sometime tomorrow. Thanks.

Re: Evaluate Gaussian Noise

Posted: 2009-10-22T22:57:18-07:00
by anthony
With the fix now provided the 'small' gaussian values now produce a small gaussian distribution. VERY small. A value of 15 now produces a gaussian distribution with some pixels 'clipped' but covering the full range of values.

Code: Select all

convert -size 100x100 xc:gray50 \
     -evaluate gaussian-noise 15 histogram:gaussian_noise_fixed_15.gif
Image

And this is what a strong gaussian random image of looks like...

Code: Select all

convert -size 100x100 xc:gray50 \
     -evaluate gaussian-noise 5 gaussian_noise.png
Image

Note that the colors are all 'grayish' on average.

So the question is what does '15' mean? It does not seem to mean sigma in color distance, or perhaps it is a percentage of color range? That looks about right.

NOTE: you can get the same effect using +noise and -attenuate

Code: Select all

convert -size 100x100 xc:gray50 -attenuate 5 +noise gaussian gaussian_noise.png

Re: Evaluate Gaussian Noise

Posted: 2009-10-23T06:07:00-07:00
by magick
Gaussian noise requires 2 sigma values. Unfortunately the command line only accepts one so we default sigma1 to 4 and sigma2 to 20 and use the command line parameter as an attenuation factor. Use it to spread or narrow the gaussian distribution.