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.
The approach consists of the following steps:
- Get edge points by applying the Canny edge detector
- Find an ordering which approximates the TSP (currently, NN is used)
- Fit a B-spline through the points in order
- Sample the spline and colour pixels on the output image
- The TSP approximation with NN is still naively implemented (brute force) and thus incredibly slow. Alternative approaches are being tested (help welcome!). Possible alternatives:
- Some kind of space partitioning should speed things up significantly.
- Identifying clusters and solving TSP between them, while using NN within the clusters
- Another approximation algorithm?
- Ant colony optimization sounds cool
- 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).
This project is licensed under the MIT License - see the LICENSE.txt file for details