📐 Convert images to Low-Poly art using Delaunay triangulation.
You need Python 3.6 or higher.
I strongly recommend to use virtual environment such as Anaconda. You can download Anaconda here.
Follow manual below to create python virtual environment for Triangler with the Anaconda.
$ conda create -n triangler python=3.8
$ activate triangler
(triangler)$ python -m pip install git+https://github.com/tdh8316/triangler/
(triangler)$ python -m triangler -h
usage: __main__.py [-h] [-o OUTPUT [OUTPUT ...]] [-s {POISSON_DISK,THRESHOLD}]
[-e {CANNY,ENTROPY,SOBEL}] [-b BLUR] [-c {MEAN,CENTROID}]
[-p POINTS] [-l REDUCE] [-v]
images [images ...]
positional arguments:
images Source files
optional arguments:
-h, --help show this help message and exit
-o OUTPUT [OUTPUT ...], --output OUTPUT [OUTPUT ...]
Destination file (default: None)
-s {POISSON_DISK,THRESHOLD}, --sample {POISSON_DISK,THRESHOLD}
Sampling method for candidate points. (default: THRESHOLD)
-e {CANNY,ENTROPY,SOBEL}, --edge {CANNY,ENTROPY,SOBEL}
Pre-processing method to use. (default: SOBEL)
-b BLUR, --blur BLUR Blur radius for approximate canny edge detector.
(default: 2)
-c {MEAN,CENTROID}, --color {MEAN,CENTROID}
Coloring method for rendering. (default: CENTROID)
-p POINTS, --points POINTS
Points threshold. (default: 1024)
-l, --reduce Apply pyramid reduce to result image (default: False)
-v, --verbose Set logger level as DEBUG (default: False)
The POISSON_DISK
sampling option is slow, while it can provide the best result.
You can see the results by options here.
It takes a minimum of 5 seconds (1000 points and threshold sampling) to a maximum of 2 minutes (10000 points and poisson disk sampling).
See example code:
import triangler
# Create Triangler instance
triangler_instance = triangler.Triangler(
# TODO: Customize these arguments
# edge_method=EdgeMethod.SOBEL,
# sample_method=SampleMethod.THRESHOLD,
# color_method=ColorMethod.CENTROID,
# points=1000,
# blur=2,
# pyramid_reduce=True,
)
# Convert and save as an image
triangler_instance.convert_and_save("INPUT_PATH", "OUTPUT_PATH")
Original | 5000 Points |
---|---|
2500 Points | 1000 Points |
Original | Processed |
---|---|
Licensed under the MIT License.
Copyright 2022 Donghyeok Tak
Some algorithms, including the Poisson disk sampling, are based on pmaldonado/PyTri.