A bitmap vectorizer that can trace along the centerline of a stroke. The builtin inkscape 'trace bitmap' can only trace edges, thus resulting in double lines for most basic use cases.
Download Source code and Debian/Ubuntu package
Written with python-Pillow. It uses 'autotrace -centerline' and an optimal threshold to vectorize a pixel image. See centerline-tracing.svg for an illustration of the idea.
In inkscape it shows up under Extensions -> Images -> Centerline Trace ...
- Install the extension (all operating systems)
- the extension requires the installation of autotrace and python-pil (see below)
- download the zip file of inkscape-centerline-trace and unpack it
- copy the files centerline-trace.inx, centerline-trace.py to your Inkscape User extensions folder (see Edit > Preferences > System: System info: User extensions)
- Install autotrace / python-pil
- Windows
- Instructions for Inkscape 0.92.2 and higher:
- download the autotrace binary from autotrace-win64-binaries github repo.
- copy the downloaded autotrace.exe to Inkscape's User extensions folder
- Instructions for Inkscape 0.92: https://inkscape.org/en/gallery/item/10567/centerline_NIH0Rhk.pdf
- Instructions for Inkscape 0.92.2 and higher:
- MacOS
- autotrace is no longer available: http://macappstore.org/autotrace/ . Please see fablabnbg#13
- GNU/Linux
- The autotrace dependency may or may not be available for your distribution. On Ubuntu (and derivatives) <= 16.04, you can install it with
sudo apt-get install autotrace
. Please read fablabnbg#13 before you install it. Autotrace may become available again, due to the work of Peter Lemenkov. - if you do not have pillow/pil installed, the extension will output an error message prompting you to install it. On Ubuntu and derivatives, run
sudo apt-get install python-pil
to install.
- The autotrace dependency may or may not be available for your distribution. On Ubuntu (and derivatives) <= 16.04, you can install it with
- Windows
The input image is converted to a graymap and histogram normalized with PIL.ImageOps.autocontrast. Optional preprocessing: equal illumination, median denoise filter.
Autotrace needs a bi-level bitmap. In order to find the best threshold value, we can run autotrace at multiple thresholds and evaluate the result candidates.
We count the number of line segments produced and measure the total path length drawn. The svg that has the longest path but the least number of segments is returned.