String Art Algorithm and Machine

Short Version:

I, along with a group of 4 others, created a machine that takes an image input and dispenses string across a circular board with pegs along its side.

Technologies Involved: Python, OpenCV image processing, Arduino

Long Version:

(If you want the really long version, check out our website!)

The Stringomatic was a capstone project that we created for an open-ended class called Principles of Engineering.

For this project, I created a greedy algorithm that converted images into a series of polar coordinates, that would allow the machine to transpose the image into string.

The image processing algorithm takes an image as an input and returns a path for the string to follow in the form of a list of pegs. The pegs are identified by index n, n = 0 1 2 … (number of pegs on the board).

Our image processing is a calculated with a greedy algorithm, which means that every line drawn by the string is the most optimal at that given time. It does not take into consideration what the end picture will look like. For each step, the algorithm draws the line across the board that covers the most "dark" values in the picture.

Notice how the pathing algorithm works on an inverted grayscale picture. This is done so that the pathing always looks for the line that covers the highest sum of grayscale values, as lighter colors correspond to higher numbers.

After each step, the image compares the current string drawn picture to the original picture and calculates the error by finding the squared-error sum per each pixel value.

The algorithm stops pathing the string once the error is at a minimum. We see below that the algorithm creates the best result at 1400 ft of string.