Jump to content
  • Advertisement
Sign in to follow this  
Chris_F

Gaussian white noise (randon numbers)

This topic is 2084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What's the correct way to go about simulating Gaussian white noise in an image? For example, the type that might be added by thermal noise in an image sensor or the fuzz of an analog TV signal. I'm using C++11 which already has RNGs with normal distributions available, so I am not asking how to implement a Gaussian RNG, simply how to use it correctly.

Share this post


Link to post
Share on other sites
Advertisement

Create a random number engine for the source of randomness and a distribution to shape the random numbers, then call the distribution object with the engine object to obtain a random number with the given distribution.

std::default_random_engine engine;
std::normal_distribution<double> dist(mean, deviation);

double value = dist(engine);

Share this post


Link to post
Share on other sites

I did the T.V. noise effect in opengl (for a screensaver) simply by using a texture four time smaller than the viewport, then i just filled the texture each frame with normal random values and let opengl filter the texture for me, giving a very reallistic effect imo.

Edited by Vortez

Share this post


Link to post
Share on other sites

So, should I use a Gaussian distribution with a mean of 0 and then use the stddev to control the amount of noise? At that point I simply add the noise to the image and clamp to [0, 1]? But if I clamp, wouldn't that mean that 0 and 1 will become more probable?

Share this post


Link to post
Share on other sites

So, should I use a Gaussian distribution with a mean of 0 and then use the stddev to control the amount of noise? At that point I simply add the noise to the image and clamp to [0, 1]? But if I clamp, wouldn't that mean that 0 and 1 will become more probable?

Don't clamp (otherwise you'll most likely get 1 all the time). Whatever noise function you use, be sure to map it to [0, 1] before applying it.

Share this post


Link to post
Share on other sites

Yes, that's what happens when you clamp a Gaussian distribution. But then you're talking about more theoretical rather than practical cases, and in theory the noise/static in a TV-image is not Gaussian because the noise is limited to the dynamic range of the display but Gaussian random values can attain values between positive and negative infinity.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!