Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate white noise image in C#

I need to be able to generate a white noise image in C# code. Is there an algorithm I can use to fill the image with white noise?

I have found the VB example of how to do it here, but I can't port it to .net myself.

like image 731
Maxim V. Pavlov Avatar asked Nov 02 '11 13:11

Maxim V. Pavlov


2 Answers

White Noise is not black or white (per definition). It contains also grayscales.

So we are already closer with:

foreach(var pixel in image) 
{
  //do that for all RGB (depending on Image format)
  pixel = rand() * 255;
} 

white noise

like image 153
fixagon Avatar answered Sep 28 '22 12:09

fixagon


Should be something very simple along these lines, no?

foreach(var pixel in image)
{
    pixel = rand()>0.5 ? white : black;
}
like image 21
asawyer Avatar answered Sep 28 '22 11:09

asawyer