Generate white noise image in C#

前端 未结 2 1581
礼貌的吻别
礼貌的吻别 2021-02-15 12:18

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

相关标签:
2条回答
  • 2021-02-15 12:49

    Should be something very simple along these lines, no?

    foreach(var pixel in image)
    {
        pixel = rand()>0.5 ? white : black;
    }
    
    0 讨论(0)
  • 2021-02-15 12:49

    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

    0 讨论(0)
提交回复
热议问题