jiaxinwang / noisemaker

Algorithm for Infinite Deterministic Fractal Noise Generation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoiseMaker

Olsen Noise algorithm for infinite scoped deterministic fractal noise. The noise is deterministic so it's perfectly for tiling and returning to the same postion and having the same regenerated noise. The algorithm is infinite and scoped so only enough values as needed are generated.

Installing

pip install noisemaker

Dependencies: numpy

Example

from PIL import Image
from noisemaker import noise
Image.fromarray(noise((250, 100), (0, 0), transpose=True)).save("noise0.png")
Image.fromarray(noise((250, 100), (0, 100), transpose=True)).save("noise1.png")
Image.fromarray(noise((250, 100), (0, 200), transpose=True)).save("noise2.png")

The noise() algorithm requires only the first shape parameter. The transpose flag is to covert it into an image ready format.

def noise(shape, position=None, **kwargs):
    """
    Returns a block of noise within the specific parameters.

    :param shape: shape of the noise block
    :param position: requested position within the noise.
    :param kwargs:  'iteration'='0-7' number of iterations for the requested noise value.
                    'kernel'=GAUSSIAN, BOX use gaussian or box matrix.
                    'transpose'='True' transpose result.
    :return:
    """

Tiling

  • noise0
  • noise1
  • noise2

Note these are three different images. Simply adjacent in the requested space, so they stack.

Box Kernel (Default)

from noisemaker import noise
from PIL import Image
Image.fromarray(noise(500, 500, iteration=5)).save("noise-5.png")

noise-5

Gaussian Kernel

There is also a gaussian kernel availible, which is about a third the blur factor of the default box blur:

from noisemaker import noise, GAUSSIAN
from PIL import Image
Image.fromarray(noise((500, 500), iteration=5, kernel=GAUSSIAN)).save("noise-5g.png")

noise-5g

Contributing

The testing is pretty robust and impossible to pass without the algorithm working.

There are a number of speed advancements that could be made to the algorithm. If faster and still passing the tests any PRs will generally be accepted.

Other noise algorithms can be included or other interesting kernels.

About

Algorithm for Infinite Deterministic Fractal Noise Generation

License:MIT License


Languages

Language:Python 100.0%