Skip to main content

Longdin Noise


What is it?

Longdin Noise is a noise type that uses per-pixel vectors to propagate pixel values.

It is interesting in the fact that two different configurations can produce wildly different results. A high density with low iterations can produce a blocky, glitchy looking noise. A low density with high iterations can produce a sort of bubbly or brush-like noise.

Why was it made?

For no particular reason really. It's strange pattern makes it impractical for common examples in games (like landscapes for video game with Perlin Noise). It's definitely an example of more artistic noise - although, if you can find a genuinely practical use for this thing, please do let me know via my email!

It started off as a desperate wrestle with the boney hands of boredom. It's strange to think the wonders one's mind can produce when one is desperately in need of something to do - or, indeed, type. If you ever find yourself desperately bored with nothing to do, create a new python file and type the following:

class Universe:
    pass

There's something about the openness of an unimplemented class that allows the mind to wonder. It doesn't have to be Universe. It can really be anything - in my case it gradually morphed into _Noise. Although, the broad topic that is the entirety of existence is definitely effective.

The Inner-Workings

All three of the generator functions first instantiates a _Noise object. _Noise is an internal class and is not intended for use outside of the API.

Initialisation

When _Noise instantiates, it generates a 2D numpy array that takes on the shape (height, width, channels) where channels is either 1, 2, or 3. (more on that later!) These are the cell 'values'. It generates another array of the shape (height, width, 2) to store each cell's influence vector.

The density (a float bigger than 0 up to 1) is just the percentage of 'cells' that are active. The generator decides which cells should be inactive using this value and zeros out each of these inactive cells.

The Algorithm

Each iteration runs the same algorithm on the data that either the initialisation or last iterative pass produced.

First things first, it gets all active cells and shuffles that data's order. A cell is active if it has an influence vector and a value associated. The shuffle helps to mitigate undesired and unpleasant row artifacts produced by the parallelism used to speed up the algorithm.

The algorithm then loops through all active cells. For each cell, it does the following:

  • Get all cells within the radius of the active cell (excludes cells if the active cell is not pointing towards them within 90°)
  • Computes the distance from the origin (active cell) to each cell within its range (radius)
  • Uses the distance to compute the influence the active cell has on each cell
  • Each cell is then lerped towards the active cell's data using the calculated influence as the factor.

To finish off the iteration, the list of active cells is updated ready for the next iteration.

Installation

pip install longdin-noise

How to use it?

Here's a quick example of how one may use this library using PIL:

from longdin_noise import generate_mono
from PIL import Image
import numpy as np

result = generate_mono((512, 512), 42, 0.05, 10)

# result is a (512, 512) array of floats in the range 0..1
# multiply by 255 and convert to uint8 for PIL
image_data = (result * 255).astype(np.uint8)
img = Image.fromarray(image_data, mode="L")
img.save("mono_noise.png")

This will create you a lovely greyscale image using the longdin_noise python library:

Mono noise example

Parameters

Parameter Type Default Valid Range Description
size tuple[int, int] — Any positive ints Width and height of the output
seed int — Any int Random seed
density float — 0 < x ≤ 1 Proportion of initially active pixels
iterations int — ≥ 1 Number of diffusion passes
radius int 8 ≥ 1 Influence reach in pixels

Tweaking the Values

The effect the values have on the resulting noise can be obscure and difficult to figure out at first. Hopefully this short guide can help you to understand how to craft your desired effect.

The number of iterations — in short — just increases the amount of smearing in the noise. As the vectors' influences propagate outwards every iteration, the colours mix more and boundaries become less clear.

The density will basically dictate how noisy the image is. A really, really low density like 0.0005 - especially on a low number of iterations like 1 - 4 - scatters 'searchlights' across the image. I have yet to find a use for this but it's pretty cool. A high density creates a more tightly packed image where blending between colours occurs much sooner in the iterative process.

The radius is quite simple. It just affects how far each active cell can influence. I haven't had an opportunity to experiment with this much, but it should have an 'octaves' effect where higher values create simpler noise.

Example Images

Low density, high iterations (0.005 Density, 20 Iterations)

Mono Bi Tri

High density, low iterations (0.6 Density, 4 Iterations)

Mono Bi Tri

Dependencies

This module requires numpy and numba.

License

This is under the MIT license. Truly do whatever you want with this code and what it produces.

Metadata

Release files for longdin-noise 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for longdin-noise 0.1.1
File Size Uploaded Provenance Actions
longdin_noise-0.1.1.tar.gz 333.7 kB Without provenance Details for longdin_noise-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for longdin-noise 0.1.1
File Interpreter ABI Platform Actions
longdin_noise-0.1.1-py3-none-any.whl Python 3 none any Details for longdin_noise-0.1.1-py3-none-any.whl

Total release size: 340.4 kB

Release files / longdin_noise-0.1.1.tar.gz

Download URL longdin_noise-0.1.1.tar.gz
Size 333.7 kB
Tags Source
SHA-256 checksum
How to use checksums
310c6a483d90d0a73f96705228e6900f627d167bd9c762182f33c0ff8af5e768
BLAKE2b-256 checksum
How to use checksums
bad4eab8b53f9b69b74811d56f4e7ccf135bde1881dd27ceed9357f15a188dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / longdin_noise-0.1.1-py3-none-any.whl

Download URL longdin_noise-0.1.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7de4d09035c3c86655da45fb85708b5fa7d333cc1b2471fc0e126ddea2161d2e
BLAKE2b-256 checksum
How to use checksums
75822ffc120a5242e00e2e2061400c6012f762229fb7784c8bf8cfb08eaeacf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for longdin-noise 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page