GithubHelp home page GithubHelp logo

grey_lines's Introduction

what

Draw a photo using lines with opacity.

Computational String-Art resources: https://www.youtube.com/watch?v=WGccIFf6MF8 https://en.wikipedia.org/wiki/String_art

how

Each line contributes some intensity to each pixel, and each pixel is from the input image. This can be treated as a constrained linear problem. Assume there are n lines and m pixels to fit. The equation should be like:

$$\arg \underset{x}{\mathop{min}} |Ax - b|โ‚‚, \text{s.t. } x \geq 0$$

In this equation, x is a vector and x_i means intensity for the i-th line, A is the line to pixel contribution matrix, and b is the vector of input image intensity.

input

The input is an image and canvas configuration. In this code, there is a rectangle and circle canvas for easy use. The canvas contains dots between which lines can be drawn, and the image area indicates where the input image should be placed. You should be able to customize a canvas layout.

limit

Ignore the non-negative constraint to improve solve speed. If problem is too large, speed is not very fast.

build

poetry shell
pyinstaller --onefile grey_lines/main.py --name linedraw

how to use

In your python>=3.11 env (venv or other), run

poetry install
linedraw --help
linedraw in.png out.svg

in out out out2 out2

grey_lines's People

Stargazers

 avatar

Watchers

 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.