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
NOTE: This is python2 code. It was developed and tested with inkscape-0.92.3 -- It probably does not run with inkscape 1.0.1 and should not be needed. Inkscape 1.0.1 has the feature built-in under Path -> Trace Bitmap -> Centerline tracing (autotrace)
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)
Install autotrace / python-pil
sudo easy_install install pip
sudo pip install pillow
cd ~/.config/inkscape/extensions
curl https://raw.githubusercontent.com/fablabnbg/inkscape-centerline-trace/master/centerline-trace.py -o centerline-trace.py
curl https://raw.githubusercontent.com/fablabnbg/inkscape-centerline-trace/master/centerline-trace.inx -o centerline-trace.inx
sudo apt-get install python-pil
to install.Finally, restart inkscape, and find CenterlineTrace in the Extensions -> Images
menue.
Since Inkscape 1.0 the Autotrace library including the CenterlineTrace feature is integrated. That should obsolete this extension. Find an entry in the new Path -> Trace Bitmap
dialog.
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.