Making an algorithm that can automate the fabrication and design of string-art
Project detail
The project is about making an algorithm that can automate the fabrication and design of string-art, see attached photo. Traditionally, nails are hammered according to a sketch, and strings are thereafter pulled between the nails by intuiton. I want to make a algorithm that accepts a RGB picture and gives an output with:
* A rendering of the string-art
* The route a variety of colored threads need to take in order to represent the picture with strings.
* The route should then be given to a CNC-machine for fabrication, alternatively as a rendering for the different colored strings, in pdf or some other format.
* It would be optimal if it is possible to tweak the picture, such as removing certain regions (for example background around a person), increase contrast, adjust thread width, “pixel”density.
I have several ideas for how to accomplish this:
Nail placement:
Using an algorithm called Superpixel to segment the picture into small homogeneous regions and put nails into where different regions meet. The algorithm is described here: https://www.epfl.ch/labs/ivrl/research/slic-superpixels/, with a library here: https://scikit-image.org/docs/dev/auto_examples/segmentation/plot_segmentations.html.
Using a canny edge detecotr: https://en.wikipedia.org/wiki/Canny_edge_detector with voronoi diagrams to fill empty areas.
variable density poisson disk sampling: http://www.cemyuksel.com/cyCodeBase/soln/poisson_disk_sampling.html
and use gradient magnitude to increase samples where the picture changes a lot.
String pathing:
Traveling salesman algorithm:https://www.johndcook.com/blog/2012/05/01/traveling-salesman-art/
overlapping strings: https://www.researchgate.net/publication/322766118_String_Art_Towards_Computational_Fabrication_of_String_Image
You could also pose it as an optimization problem. Simply generate a number of random string paths and see how much they decrease some “energy “that measures the deviation between the color you seek and the color you have. Then you pick the path from the set that is best and generate a new batch. After many many iterations you should have your thread plan. I also found a github for black and white that might be used: https://github.com/theveloped/ThreadTone, or this https://www.engadget.com/2019-09-12-ani-abakumova-thread-algorithms.html
Similar project, but only has black and white possibility: https://laarco.com/