Giter Site home page Giter Site logo

adyork / inkscape-centerline-trace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fablabnbg/inkscape-centerline-trace

0.0 0.0 0.0 3.11 MB

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

License: GNU General Public License v2.0

Makefile 0.87% Python 89.00% Shell 8.31% NSIS 1.81%

inkscape-centerline-trace's Introduction

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
      • Install autotrace MacOS.zip version 0.40.0 or later from e.g. https://github.com/jnweiger/autotrace/releases
      • open a command line shell to install the python-PIL module:
        • sudo easy_install install pip
        • sudo pip install pillow
      • open a command line shell to install the inkscape extension:
        • 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
      • Please report success in the github issues. As of 2018-08-31, MacOS Support is back, but highly experimental.
    • GNU/Linux
      • Install the autotrace DEB package version 0.40.0 or later from e.g. https://github.com/jnweiger/autotrace/releases
      • 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.