Voronoi

This little project:

It's just a little challenge:

Examples

The original image followed by Voronoi colorization under L1 (manhattan), L2 (euclidean) and L3 norm:

.. image:: resources/imgs/parrots.png .. image:: resources/generated/voronoi500L1.png .. image:: resources/generated/voronoi500L2.png .. image:: resources/generated/voronoi500L3.png

Performance

The Voronoi transform above, with 500 pixels per patch on a small image, takes between 0.02s and 0.05s on my machine overall. This is mostly loading and saving of data and starting of the thread pool - without those, it takes 0.0075s or 133x per second. The stripped binary is 1.7mb.

Types

There are several considerations for type safety:

Difficulties:

The type safety and tests worked, in a way: the program immediately worked once it compiled and passed all tests. It did however take more than an order of magnitude longer to make than the slow and naive Python version.

How to use

To install:

cargo install voronoiify-image

The most simple use is voronoi my/img/path.png.

Several customization options can be found in voronoi --help.

Voronoiify Group image into voronoi-based patches and assign the average color to each patch

USAGE: voronoi [FLAGS] [OPTIONS]

FLAGS: -h, --help Prints help information -s, --show Show the generated image using EOG -V, --version Prints version information

OPTIONS: -o, --output Path to store the generated file -r, --seed Random seed between 0 and 2^64 (exclusive) -c, --patch_size Average number of pixels per group

ARGS: Input png file to voronoiify

The package is stable, but is not very rich in features. I.e. it is only tested with png images without alpha channels, and displaying the image is done with EOG. Pull requests are welcome!

Development use:

Random observations / hints: