blurymind / inkscape-centerline-trace

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. It uses 'autotrace -centerline' and an optimal threshold to vectorize a pixel image.

Home Page:https://github.com/fablabnbg/inkscape-centerline-trace/releases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inkscape-centerline-trace

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 ...

Installation hints

  • 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
    • MacOS
    • 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.

Algorithm

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.

About

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. It uses 'autotrace -centerline' and an optimal threshold to vectorize a pixel image.

https://github.com/fablabnbg/inkscape-centerline-trace/releases

License:GNU General Public License v2.0


Languages

Language:Python 98.0%Language:NSIS 1.7%Language:Shell 0.2%Language:Makefile 0.0%