Approximates images in svg format.
input image | output svg (polygonal) |
---|---|
Use the recursive submodule option to clone the necessary submodules.
git clone --recurse-submodules https://github.com/loicland/img2svg
Otherwise, clone the following repo in the root:
- https://gitlab.com/1a7r0ch3/parallel-cut-pursuit
- https://gitlab.com/1a7r0ch3/multilabel-potrace
- https://gitlab.com/1a7r0ch3/grid-graph
You need numpy
, matplotlib
pip install numpy matplotlib
In a command prompt run:
python setup.py build_ext
Test with
python img2svg.py
python img2svg -f filename -r reg_strength -c contour_color -s stroke_width -o out_size -p output_path
With
- -f file : path to image
- -r reg_strength : how much simplification to do. Default = 1.0
- -c contour_color : color of the contour, if any. Default = '' (no contour). Exemple : 'red'
- -s stroke_width : width of the contour (only if contour_color != ''). Default = 2.0 (thick)
- -o out_size : size of the largest side of the image. Default = 500
- -p output_path : output path. Default = replace the image extension by `svg`
Bezier curves support.