README
This is a tiny image processing library to convert your images to Voronoi mosaic or Warhol effect images. We used k-means clustering algorithms to determine the position of Voronoi sites and pixel groups of Warhol effect.
How to use
pip install imgrit
The library depends on Pillow, NumPy, and SciPy.
If you have scikit-learn, the library uses the faster k-means. You can install it together with pip install "imgrit[sklearn]".
The following is the input image.
from PIL import Image
import imgrit
my_image = Image.open("../images/original.jpg")
voronoi_mosaic = imgrit.voronoi_mosaic(my_image, 250)
voronoi_mosaic.save("voronoi-mosaic.png")
warhol_effect = imgrit.warhol_effect(my_image, 10)
warhol_effect.save("warhol-effect.png")
Performance
Rough execution times by image size. voronoi_mosaic fits k-means on a random subsample of pixels (200 pixels per region, at least 10,000 pixels), so the number of regions has little effect on the time up to a few hundred regions. For large images, most of the time is spent on pixel-wise processing, which grows with the number of pixels.
With scikit-learn (pip install "imgrit[sklearn]"):
| Image size | voronoi_mosaic20 regions (default) |
voronoi_mosaic250 regions |
voronoi_mosaic1000 regions |
warhol_effect5 colors (default) |
warhol_effect10 colors |
|---|---|---|---|---|---|
| 0.5 MP (800×600) | 0.6 s | 1.0 s | 8.7 s | 0.4 s | 0.5 s |
| 1.9 MP (1600×1200) | 2.5 s | 3.0 s | 10 s | 1.6 s | 2.1 s |
| 7.7 MP (3200×2400) | 9.7 s | 10 s | 18 s | 6.0 s | 7.4 s |
| 12.2 MP (4032×3024) | 16 s | 17 s | 25 s | 9.9 s | 12 s |
Without scikit-learn (SciPy's k-means is used):
| Image size | voronoi_mosaic20 regions (default) |
voronoi_mosaic250 regions |
voronoi_mosaic1000 regions |
warhol_effect5 colors (default) |
warhol_effect10 colors |
|---|---|---|---|---|---|
| 0.5 MP (800×600) | 0.6 s | 2.8 s | 147 s | 0.4 s | 0.5 s |
| 1.9 MP (1600×1200) | 2.5 s | 5.0 s | 149 s | 1.7 s | 2.0 s |
| 7.7 MP (3200×2400) | 10 s | 13 s | 163 s | 7.1 s | 8.3 s |
| 12.2 MP (4032×3024) | 16 s | 18 s | 163 s | 11 s | 13 s |
SciPy's k-means becomes very slow with many regions, so installing scikit-learn is recommended if you use more than a few hundred regions. Peak memory usage was about 4 GB for a 12 MP image.
Measurement environment: Mac mini (Apple M4, 10 cores, 24 GB memory), macOS 15.7, Python 3.14.7, NumPy 2.5.3, SciPy 1.18.1, Pillow 12.3.0, scikit-learn 1.9.1. Each value is a single run on images/original.jpg resized to the given size. Times vary with your machine and the input image, so please use them as a rough guide.
OpenSea
If you'd like to see more images, please visit Asakura Gallery Digital at OpenSea.
Citations
A novel method for Voronoi mosaic effect using k-means clustering
Metadata
Release files for imgrit 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| imgrit-0.2.2.tar.gz | 180.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| imgrit-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 189.7 kB
Release files / imgrit-0.2.2.tar.gz
| Download URL | imgrit-0.2.2.tar.gz |
|---|---|
| Size | 180.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3726968136135f9b3c7f3f094d7917969fc62a1aea19483762c82b1b7ce0e759
|
|
BLAKE2b-256 checksum How to use checksums |
c816f8db29ea5a116892c259086509d45790a1ea840c1d93c4c03dcdd1aa39eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency logRelease files / imgrit-0.2.2-py3-none-any.whl
| Download URL | imgrit-0.2.2-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c7056262d0b6b57766946ede06992d9f33e9bf0d97e8d6f7030f3bb60bddae6
|
|
BLAKE2b-256 checksum How to use checksums |
182bbbf2a14aa2edcbab70b431c0abf2e97e6f0c066bbf364a7504b89a76acee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency log