Close

Log 4 - Software

A project log for Automate the art

An automated version of Petros Vrellis's knit art

shlonkinshlonkin 08/16/2016 at 14:580 Comments

There are two distinct pieces of software, the image processing part that produces the line sequence, and the microcontroller part that turns the sequence into physical lines of thread. They can be found in the files section of this project, or in the git. They are both functional and awaiting the first threaded test run.

Image processing part -

The algorithm has been reproduced by many people ever since HaD featured the original art. Just look in the comments on that article. I also have to mention Christian Siegel who put his link in the comments here.

Here's an outline of what my version, written in Processing, does:

  1. An image is chosen and converted to grayscale.
  2. A circular region is chosen and a number of equally spaced pin locations are set around the circle.
  3. The sets of pixels along the paths between each pair of pins are found.
  4. Starting at one pin, the average darkness along each path* from that pin is computed.
  5. The path with maximal darkness is chosen and the pixels in its set are lightened by some amount. The pin at the other end of the path is the next starting point.
  6. Steps 4 and 5 are repeated a few thousand times.

*Note: The pins within some range of the starting pin, 20 or so, are not counted. This eliminates short lines around the border that do not contribute to the bulk of the image. An effect of this is a slightly darker ring some distance from the edge.

The user can adjust several parameters to get the image they want. Then the sequence can be saved in a simple file consisting of a two byte step count followed by one byte(the pin number) for each step. The file is put on an SD card to be handed to the next piece of software.

Microcontroller part -

I still haven't decided precisely what piece of hardware I'll be using for the controller, but for testing I'm using an Arduino with SD support provided by an ethernet shield. The final product may use a HaD trinket because I have one in front of me right now.

Anyway, the software does this:

  1. A sequence of pins is read from the SD card.
  2. The loom rotating motor is turned on.
  3. Loom position is measured by a photointerruptor that triggers an interrupt as each pin goes by.
  4. When a pin in the sequence is reached, a solenoid that moves the thread dispenser is turned on until the next pin arrives. This wraps the thread around that one pin.
  5. If the thread runs out, a simple sensor signals for everything to stop.
  6. When the end of the sequence is reached, everything stops.

Just today I tested both pieces of software from the image to the end of the sequence and everything worked fine. The only missing parts were the solenoid(I used an LED for testing) and the whole thread setup. I'm still waiting for the solenoid to arrive in the mail.

Discussions