/LineArtist

Generate continuous line art from an image

Primary LanguagePythonMIT LicenseMIT

Line Artist

Ever stumbled upon these awesome drawings made with only a single continuous line? This is an attempt to generate drawings in this style from arbitrary images.

Line Art Example

How is it done?

The approach consists of the following steps:

  1. Get edge points by applying the Canny edge detector
  2. Find an ordering which approximates the TSP (currently, NN is used)
  3. Fit a B-spline through the points in order
  4. Sample the spline and colour pixels on the output image

Possible improvements

  • The TSP approximation with NN is still naively implemented (brute force) and thus incredibly slow. Alternative approaches are being tested (help welcome!). Possible alternatives:
  • NN greedily selects points which are suitable in the beginning, but the few remaining scattered points that remain at the end lead to some unnatural lines through the drawing when attempting to connect them
  • The visualization of the B-spline in the output image is very limited (resulting images cannot easily modified). An alternative idea is to generate SVG paths. However, these are Bézier curves, so a conversion from B-splines is needed (Boehm's algorithm).

License

This project is licensed under the MIT License - see the LICENSE.txt file for details