Coder Social home page Coder Social logo

swirlyclouds / embroiderypatternscript Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 1.0 83.08 MB

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

License: MIT License

Python 100.00%
csv embroidery image-manipulation image-processing-python kmeans-clustering lab-color rgb-color command-line matplotlib-pyplot

embroiderypatternscript's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.