Generate string art from images using a greedy algorithm that simulates wrapping thread between nails on a circular board.
With the goal to generate such images:

Algorithm
-
Preprocess
- Resize image
- Convert to grayscale
-
Initialize
- Place
nail_amountnails on a circle - Set per-nail connection limit
- Place
-
Greedy Step
- For all valid nail pairs:
- Score line = sum of pixel intensities along line
- Pick best line
- Subtract intensity along that line
- Update nail connection counts
- For all valid nail pairs:
-
Repeat
- Run for
niterations or until constraints are hit
- Run for
Constraints
max_connections: max lines per nailthread_length: total available thread- Pixel values are reduced and clamped ≥ 0
