Giter Club home page Giter Club logo

stringart's Introduction

StringArt

Project for algorithmics course 2020. Also submitted to DeltaX 2021. Recreate art by connecting nails with strings.

For a quick overview of the project, look at the project's poster.

Project goal
Recreate images by looping a continuous string around nails. The nails are fixed on the border of a canvas (e.g. on a circle’s or rectangle’s perimeter).

Project result
A software tool that can be used from the command line ("generate.py") to create string art and get instructions to replicate the result.

Core of the project
Input: nail positions, reference image.
Output: a string art version of the reference image; and the order of nails around which to loop the continuous string to get the output image.

The algorithm:

  1. Evaluate the goodness of every possible string pull from the current nail.*¹
  2. Pull the string to the best found nail.
  3. Set the new nail as the current nail.
  4. Repeat the algorithm.*²

*¹ To evaluate the goodness of a string pull, evaluate pixel by pixel, how much better or worse does the pull make the picture. Distance of two pixels is the square difference. The best line is the one with most cumulative improvement.
*² The number of iterations can be set manually or the algorithm can be set to repeat until it fails to find string pulls that improve the total result.

Run from cmd

“$python generate.py -i <input.png> -o <output.png>”

Possible flags:

  • “-d ” output file dimensions (default is 300); if output dimens are scaled up, then string strength should also be<;br>
  • “-l ” number of iterations (default will run until no improvement);
  • “-r “ number of random nails to pick from when choosing the next nail to speed up the algorithm at the cost of quality (default looks at all possible nails every iteration; good value for this is ~50);
  • “-n ” step between nails (default is 4). The smaller the step, the more nails there will be. The larger the step, the less nails. Minimum possible value is 1;
  • “-s <float 0..1>” string strength for output (default is 0.1);
  • “--rgb” for colored output (default is black string on white canvas). In case of RGB, pull order isn't returned as it might not match the real life result (additive blending);
  • “--wb” for white string on a black canvas;
  • “--rect” to put nails in a square around the picture (default is circle).

Nails are placed evenly around the perimeter. For circles the first nail is placed at 9 o'clock and the order goes clockwise. For squares, the first nail is placed at the top left corner and the order goes clockwise.

Examples

Ex1

Ex2

Ex3

Ex4

stringart's People

Contributors

kaspar98 avatar

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.