Skip to content

Open source python based string art repository. Fast numba compiled string art generator | optimal image preprocessing with importance mask & background removal | accurate renders | nail templates.

License

Notifications You must be signed in to change notification settings

StringBoardUK/string-art-open

Repository files navigation

Author: Will Taylor
Learn more: stringboard.co.uk

An Open Source Python Based String Art Generation Repository
* fast: 1-2s generation with numba compiler
* accurate: previews correlated to real string art 
* optimal: importance weighting, robust image preprocessing including background removal, optimal greedy algorithm

SETUP AND DEPENDENCIES
git clone https://github.com/StringBoardUK/string-art-open.git
cd string-art-open
pip install -r requirements.txt
(or just use VS code quick create virtual environment)

===========================================================================================
CONTENTS

main.py: main script for converting an image into string art sequence and rendering a result

StringArtEngine has the core logic for string art generation
    * image preprocessing pipeline
    * numba compiled sequence generator, compatible with importance weighting
    * result renderer - accurate and well parameterised 

StringArtUtils has useful functions:
    * making nail templates
    * generating line profiles (anti aliased line coordinates)
    * UI for importance weighting

number_reader: simple UI for reading sequence (helpful for actually stringing)

assets
    - line_porfiles_500.npy: pre computed anti-aliased line profiles (rows,cols,vals), 150Mb
    (will be created on the first generation, then reused)
    - nail_template_circle.png: full size nail template
    - nail_template_circle_sliced.pdf: sliced for 50cm board diameter
    (same for square for 50cm side length)
    - template_easel.png: high res template for rendering results (you can use your own too!)

========================================================================================================
Technical details and usage:

* To make new nail templates, uncomment relevant block in main.py, then slice them to your desired size 
at rasterbator.net with 10mm margin and 5mm overlap (final size is with margins cut away)

* This string art generator has been developed by correlating physical results to model parameters, 
the best thread type: 0.1mm nylon monofilament. With this thread you should aim for 3.5-4.5k lines for 50cm board

* You can use a different thread type, but it will not be correlated so results might not be accurate

* Resolution of input image to generator does not need to be above 500x500px. String art
cannot achieve higher than 200-300px resolution, so input doesn't need to be more

* Lines are drawn 1px thick (+anti aliasing), and line strength is calculated as follows:
line_strength = kNylon * resolution/500 * 480/board_diameter_mm
kNylon - 0.1mm nylon thread constant, and then adjusted for resolution and board diameter (nominal 1)
e.g. if you wanted to use a different thread change kNylon to a new weighting parameter

* Once sequence is generated, the code will render the final string art into a high resolution (1000x1000px) png image. 
This can then be pasted onto a template image with known centre and diameter coordinates
(I've provided template_wall, but you can use your own). Lighting can be simulated by adjusting brightness and tint

* To add a new template image for rendering
- in StringArtEngine load_templates, load in new template image
- in StringArtEngine render_all_previews, add the new template coords, lighting setup and add to previews dictionary

* Use the importance UI tool to highlight details in the string art. Can adjust the strength of this in StringArtUtils

* Do not change folder structure (it will break stuff!)

About

Open source python based string art repository. Fast numba compiled string art generator | optimal image preprocessing with importance mask & background removal | accurate renders | nail templates.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages