Project

Computational Knitting Patterns

Vera van de Seyp 

This project explores a few computational approaches to use the shape of a knitted garment as input for its pattern.

This experiment combines machine knitting techniques with digital tools, allowing for the creation of intricate and complex patterns that would be difficult or impossible to produce by hand. One of the challenges of such an approach is the need for specialized software to generate the patterns. This post documents the development of a tool that generates computational knitting patterns and can send them to a knitting machine.

Computational knitting

This tool is made for knitting machines, but in this case, I specifically used an electronic Brother KH-910 with a hardware modification. The machine was produced in 1980 when computer memory was comparatively limited. While the memory in this machine would allow the user to scan images that could then be knitted, the size of these images did not span the full range of the knitting bed and produced quite small unique patterns. In our machine, this limitation was circumvented by replacing the memory with an Arduino and an AYAB shield. This open-source shield and the accompanying software allow us to connect the knitting machine to any computer, manage the data storage from the computer, and thus print infinite unique patterns.

Textile production was one of the first processes that resembled computation: the Jacquard loom and its interchangeable punchcards even inspired the design of early computers. Also nowadays, textile production lends itself perfectly to the use of computation:  an effective approach to quickly generate intricate patterns for which the rules can be defined beforehand. With this experiment, the goal is to create patterns that adapt themselves to the cut or the shape of (parts of) a garment.

Some of the key features I wanted to include in the computational knitting pattern generator:

  • Displaying a selection of computational approaches that take the shape of a garment as input.
  • Customization of each computational approach, such as changing the intensity, inverting stitch types, and modifying it for any stitch count and row count.
  • Previewing the pattern in real-time, allowing the user to see the changes in the pattern as they adapt parameters.
  • The ability to create different stitches, such as knit, purl, and increasing or decreasing stitches.

    The last feature requires a part we have not yet obtained in our lab called a ribber: an additional knitting bed that can be attached to the main bed of the machine.

Mathematical experiments


Distance transformation 

Distance transformation is a representation of an image in which the distance to the closest dark pixel is calculated for each pixel.  This approach is is reminiscent of the nineties computer game Minesweeper. The result is a version of the image in which a gradient is formed towards the pixels that are the furthest removed from any black pixel.

In this project, we made a simple chessboard logic distance transform function, where each pixel compares the values of its 8 neighboring pixels and takes the lowest value based on that. This approach tends to create some sharp lines in more complex images but it worked well enough for our project.

The distance transform information can also be multiplied, to make a more repetitive pattern. We experimented with this multiplication to create different versions for the same shape. 

Medial axis transform (skeletonization)

Medial axis transform is an approach to take an input of a shape and find its 'skeleton': the inner line of the element. We used a simple form of medial axis transform to find the shape of the garments. We noticed a little bug where lines were drawn between the skeleton and curves in the shape, and decided to keep it for now.

Dithering

Now that a few different computational approaches were explored; I ran into a problem: the knitting machine can only knit two different yarns ( black and white pixels in the source image), and doesn’t know what to do with gray pixels. It cannot really combine two yarns in percentages to match the gray value of a pixel in the image! One way would be to threshold this, which works well for images without too much gray. 

Dithering is a process where a certain type of noise is used to simulate grayscale with black and white pixels only.  There are many approaches to dithering so I tested the most used ones in a knitted sample.

All of these scripts were programmed with javascript and p5.js, taking a grayscale image as input and rendering the same image in black and white only. We took inspiration from an online dithering tool called Dither Me This. In this test, we can see the following error-diffusion dithering types:

  • Burkes
  • (False) Floyd Steinberg
  • Jarvis
  • Sierra (1, 2, 4-A)
  • Stucki

Prototype

Now that we had a few approaches for the tool, it was time to start developing it, and to  make it accessible we preferred it to be a web tool. As the computation of patterns was approached with Javascript, we used the Javascript library p5.js to visualize the computation. 

An arbitrary user interface was created, with a functional design and an interface for all the modifiable parameters. The user interface should be intuitive and easy to use, allowing the user to create knitting patterns with minimal effort.

We made some features for the knitting notation too. Important to note is that stitches are not entirely square. This means that the image needs to be transformed somewhat to fit the ratio of the width and height of a set of stitches. On top of that, the gauge also depends mostly on the yarn. The features in the tool were limited to two-hundred stitches, which is the full length of the bed.

Once a prototype of the tool was developed, some debugging needed to be done. The tool was used to make some samples to identify any errors or issues.

Some elements that were tested during the process:

  • Creating different types of patterns to ensure that the tool is generating patterns correctly.
  • Testing the user interface to ensure that it is intuitive and easy to use.
  • Testing the performance of the tool to ensure that it can handle large formats as input.

Wrap up

The tool currently offers a few computational approached to the creation of patterns designed for the shape they are made on. More computational approaches could be added over time to offer a wider variety of patterns. A few approaches next in line to test are data sorting, matrix multiplications and visualizing data with binary code.

The practical implementation of this tool other than a formal experiement should be explored as well. A few examples of possible practical implementations are the decrease of waste material in the production process of patterned garments, creating foldable or other actuated forms of garments with actuated fibers,  or developing the creation of customized knitwear into a more automated process.

 Feel free to test it out here: https://knit.veravandeseyp.com/

Research Topics
#design #art #fashion