{"id":15672473,"url":"https://github.com/healeycodes/embroidery-vision","last_synced_at":"2025-09-12T13:43:15.174Z","repository":{"id":112378052,"uuid":"352437815","full_name":"healeycodes/embroidery-vision","owner":"healeycodes","description":"🧵 Identify which DMC threads are used in embroidery hoop images.","archived":false,"fork":false,"pushed_at":"2021-05-13T16:47:19.000Z","size":3104,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T03:06:04.628Z","etag":null,"topics":["colorpalette","dmc-color","embroidery","hough-transform","opencv"],"latest_commit_sha":null,"homepage":"https://healeycodes.com/computer-vision-and-embroidery/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/healeycodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-28T21:02:15.000Z","updated_at":"2024-12-10T06:28:47.000Z","dependencies_parsed_at":"2023-05-14T04:00:33.711Z","dependency_job_id":null,"html_url":"https://github.com/healeycodes/embroidery-vision","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fembroidery-vision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fembroidery-vision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fembroidery-vision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fembroidery-vision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/healeycodes","download_url":"https://codeload.github.com/healeycodes/embroidery-vision/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252770469,"owners_count":21801545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colorpalette","dmc-color","embroidery","hough-transform","opencv"],"created_at":"2024-10-03T15:26:55.197Z","updated_at":"2025-05-06T21:24:30.931Z","avatar_url":"https://github.com/healeycodes.png","language":"Python","readme":"[![End to end image tests](https://github.com/healeycodes/embroidery-vision/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/healeycodes/embroidery-vision/actions/workflows/python-app.yml)\n\n# 🧵 embroidery-vision\n\n\u003e My blog post: [Computer Vision and Embroidery](https://healeycodes.com/computer-vision-and-embroidery/)\n\n\u003cbr\u003e\n\nA CLI for finding the approximate embroidery floss colours from an image of an embroidery hoop.\n\nOpenCV is used to locate the hoop area then the color space is reduced and matched to the limited set of DMC colors (see `dmc.csv`). A color palette is generated with the DMC identification number attached to each color.\n\n\u003cimg src=\"https://github.com/healeycodes/embroidery-vision/blob/main/examples/example_out.jpg\" height=\"400\"\u003e\n\nIn order to find the hoop area, a series of destructive filters are used — the image is converted to gray and then the following are applied: `GaussianBlur`, `medianBlur`, `adaptiveThreshold`, `erode`, `dilate`. As we see below, this makes the hoop more identifiable to the circle Hough transform.\n\n\u003cimg src=\"https://github.com/healeycodes/embroidery-vision/blob/main/examples/example_destructive_filters.jpg\"\u003e\n\nUsually, multiple circles are found but the largest and most central one is chosen. This logic was chosen after reviewing ~100 of the latest posts to r/embroidery.\n\nTo find the colors, the area is quantized and then the nearest color is looked up in a cached k-d tree of DMC colors. The lower occuring colors are filtered out from the palette.\n\n## Usage\n\nTested with Python 3.8.\n\n`pip install -r requirements.txt`\n\n`pip install -r requirements-dev.txt`\n\n```\n$ python cli.py  -h\nusage: cli.py [-h] [--output file.jpg] [--debug] file.jpg\n\nGet a DMC color palette for an image of an embroidery hoop.\n\npositional arguments:\n  file.jpg           an input file.\n\noptional arguments:\n  -h, --help         show this help message and exit\n  --output file.jpg  an output file.\n  --debug            set debug mode. Saves debug files to current directory.\n```\n\n## Limitations\n\nThis program doesn't take lighting conditions into account and doesn't filter out the base material (it thinks the background is another thread) so the accuracy is low.\n\n## Tests\n\n`python -m unittest discover test/`\n\n`mypy .`\n\n## License\n\nMIT.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhealeycodes%2Fembroidery-vision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhealeycodes%2Fembroidery-vision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhealeycodes%2Fembroidery-vision/lists"}