Function Repository Resource:

VoronoiNoise

Source Notebook

Create an image based on Voronoi noise

Contributed by: Sander Huisman

ResourceFunction["VoronoiNoise"][s]

creates an image of dimensions s×s.

ResourceFunction["VoronoiNoise"][{w,h}]

creates an image of dimensions w×h.

ResourceFunction["VoronoiNoise"][{w,h},d]

creates an image of dimensions w×h with feature size d.

Details

Voronoi noise is also known as Worley noise or cellular noise.
If d is not given, it is set to 10% of the diagonal of the image size.
To create an image, the domain is divided in blocks of d×d, then in each block a single random point is generated. Using these seed points the DistanceTransform is applied, and the image intensity is adjusted to be in the range 0—1.
To create better border behavior, the initial points are generated 2 blocks wider on all sides. In the last step the image is cropped.

Examples

Basic Examples (3) 

Create a square image:

In[1]:=
ResourceFunction["VoronoiNoise"][200]
Out[1]=

Create a rectangular image:

In[2]:=
ResourceFunction["VoronoiNoise"][{200, 100}]
Out[2]=

Change the feature size:

In[3]:=
ResourceFunction["VoronoiNoise"][200, 8]
Out[3]=

Scope (1) 

Create a long image:

In[4]:=
ResourceFunction["VoronoiNoise"][{1000, 50}, 8]
Out[4]=

Possible Issues (2) 

The feature size should be positive:

In[5]:=
ResourceFunction["VoronoiNoise"][100, -4]
Out[5]=

The feature size should be an integer:

In[6]:=
ResourceFunction["VoronoiNoise"][100, 5.5]
Out[6]=

Neat Examples (3) 

Create a RGB color noise image:

In[7]:=
ColorCombine[Table[ResourceFunction["VoronoiNoise"][200], {3}]]
Out[7]=

Create a CMYK color noise image:

In[8]:=
ColorCombine[
 Table[ResourceFunction["VoronoiNoise"][200], {4}], "CMYK"]
Out[8]=

Average several noise images:

In[9]:=
((ResourceFunction["VoronoiNoise"][400] + ResourceFunction["VoronoiNoise"][400])/2)
Out[9]=

Publisher

SHuisman

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 27 September 2024

Related Resources

License Information