less_retarded_wiki

main page, file list (598), source, all in md+txt+html+pdf, commit RSS feed, report abuse, stats, random article, consoomer version

Noise

Noise in general is an undesirable signal that's mixed in with useful signal and which we usually try to filter out, even though it can also be useful, especially e.g. in procedural generation. Typical example of noise is flickering or static in video and audio signals, but it can also take a form of e.g. random errors in transferred texts, irrelevant links in web search results or imperfections in measuring of economic data. In measurements we often talk about signal to noise ratio (SNR) -- the ratio that tells us how much noise there is in our data. While in engineering and scientific measurements noise is almost always something that's burdening us (e.g. cosmic microwave background, the noise left over from the Big Bang, may interfere with our radio communication), in some fields such as computer graphics (and other computer art) or cryptography we sometimes try to purposefully generate artificial noise -- e.g. in procedural generation noise is used to generate naturally looking terrain, clouds, textures etc.

##### ####   # ## ####   # # # #  ## ### #   ## #
#  ####  ### # # ### # # ###    ##  #   # ##
#  ##  ##  #######    #   ## #  # ## ##    # # ##
 #  # # ##  ## # ###     #   # # # ##    # ## #
    # # ### #  ####      ## #    ### #   #  ######
# ## #    # ## #######    # #        #    # # #  #
# #     ##   # ## ## #  #  # ###    # # # ##     #
   #    ## ##### ## # # #  ## ##### ##### ## #####
  #   # #### # # #  #   ##       #    # ##  #####
#   ## # ## ##     ####     #     ##  ##    # ##
#### ####  #  ##    # ##  #    ##  ##  # ### ###
  #  #   #    # #  ####  #  #   # ## ### ## #   #
   #  # # # #  ##  ##  #    #   # # #### #### # ##
## ## #  #    ## ## ##   #      ###   #   # #
 # #  ##   ### #  ####  # # ## # #    # #   ##  #
 ##  # # # # # # # # # ### #####   ## ##   #######
### ##   ## ## ##  #### # # ## ## ####### ### #
# # ##    # # #  ##  #  # #   #  ####  # ### #   #
     # ### #### ###  # #  ## # ###   # #   ##  ##
#  #    #####    #     ##      ## ### #  ###  ##
  ## ## ## ## ### #      ### #    #   #### #####
 #  ##     # ####  #   #     #    ## ##   ###  # #
   #  ###    ###   ### # # # # ##  ##  # #  #  #
     #  #####  #  #####  ### ###  # #    ## ### #
 #  # ### #####    #  #   #  # ##   ######## ###

2D binary white noise

Artificial Noise

In computer science, especially e.g. in computer graphics or audio generation, we often want to generate artificial noise that looks like real noise, in order to be able to generate data that look like real world data. Noise may serve as a basis (first step, random initial state) for generating something or it may be used to distort or modulate other data, for example when drawing geometrical shapes we may want them to look as if written by hand in which case we want to make them imperfect, add a bit of noise to an otherwise perfect shape a computer would create. Adding noise can help make rendered pictures look more natural, it can help us model human speech that arises from noise created by our vocal cords, it can help AI train itself to filter out real life noise etc.

Normally we don't want our noise to be completely random but rather pseudorandom so that our programs stay deterministic. Imagine for example we are generating terrain heightmap based on a 2D noise -- if such function was truly random, the terrain in a certain place would be different every time we returned to that place again, but if the noise is pseudorandom (seeded by the position coordinates), the terrain generated at any given coordinate will be always the same.

There are different types of noise characterized by their properties such as number of dimensions, frequencies they contain, probability distribution of the values they contain etc. Basic division of noises may be this:

           ..----..
        .''        ''.
    ..''              '.                      ..... 
''''                    '                 ..''     '''--..
                         '.            .''                ''..
                           '.       ..'                       '''
                             ''...''

                             octave1
                                +
       ....                                    ...
..--'''    ''.        ..'''...              .''   ''-..    ..--''
              ''---'''        '''''---...-''           ''''

                             octave2
                                +

''-....----'''-...-'''-...-'''''''-----...-'''--..-'''-....---'''

                             octave3
                                =
           ..
        .''  '.
      -'       ''.-'-.
... ..                '                      -'''--...
   '                   ''                   '         .
                         '-.              -'           -.. ..  .'
                            -.          -'                '  ''
                              '...-.--''

                           fractal noise


1D fractal noise composed of 3 octaves

Code

A super simple "poor man's noise" that can be of use sometimes is coin flip noise which works simply like this: start with value 0, in each step output current value and randomly change it by +1 or -1. It's basically a random walk, a next best thing to the simplest white noise, so watch out, it will only work for most basic things, generalizing to a 2D noise will be awkward, you won't know how high or low the values will actually go, also the frequency properties probably won't be ideal. { Not sure actually what spectrum to expect, have to check that out, TODO. ~drummyfish } You may at least try to play around with changing the value even by more than one using e.g. normal probability distribution.

TODO: code for the above, maybe even a one liner for white noise

TODO: actual Perlin noise etc., also some nice noise that's just adding some random sine waves in a fractal fashion, like a one line formula


Powered by nothing. All content available under CC0 1.0 (public domain). Send comments and corrections to drummyfish at disroot dot org.