Skip to content

swirlyclouds/EmbroideryPatternScript

Repository files navigation

EmbroideryPatternScript

Takes an image, simplifies the colours, generates a list of DMC embroidery threads that could be used to make the image as an embroidered piece of fabric

How it works

Part 1: Simplyifying the image

The image is loaded into the script as an array of pixel values (R,G,B)

RGB is then converted into LAB colourspace. This is so that colours found during the next step are more perceptually similar to one another than would be the case if using RGB.

K-means Clustering is then used to simplify the image into just 16 unique colours.

Part 2: Finding the threads

Load the DMC thread data from the csv file into a list of custom classes.

Iterate through the colours in the image to find the closest thread using the euclidean distance of the colour values.

Currently done through RGB, will be changed to LAB for reasons stated above.

How to use:

$> python3 generate_pattern.py [-c number_of_colours] [-f filename]

default number of colours : 16

filename : "yosemite-valley.jpg"

Example Output:

image

About

Takes an image, simplifies the colours, generates a list of DMC embroidery threads that could be used to make the image as an embroidered piece of fabric

Topics

Resources

License

Stars

Watchers

Forks

Languages