Skip to content

Create art using randomly generated lines. 🎨

License

Notifications You must be signed in to change notification settings

erikkristiaan/Lines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lines 🎨

Lines is a generative art program which reproduces images by drawing random 2D lines to a blank canvas based on an input source image. Lines then compares each iteration, only keeping the lines which have a lower Root-mean-square deviation.

Installation

Dependencies

  • OpenCV
  • Cmake
  • GCC or Clang

Compiling Lines

Compile Lines on linux with:

git clone https://github.com/erikkristiaan/Lines.git
cd Lines
mkdir build
cd build
cmake ../
cmake --build .

Running Lines

You can then run Lines from the command-line using command:

./Lines [arguments]

Flags

--primitives, -p

  • Line size in pixels. For instance, -p 50 will render 50px lines to the canvas. (Default: 30)

--iterations, -i

  • Number of iterations to complete per frame. (Default: 20000000)

--frames, -x

  • Number of times to run the program. Useful for making short animated gifs ffmpeg. (Default: 1)

--antialiasing, -a

  • true - Lines are generated with anti-aliasing. Usually produces more pleasing images. (Default)
  • false- Lines are generated without anti-aliasing.

--palette, -c

  • 1 - Generates a random value from 0 - 255 for each RGB channel.
  • 2 - Samples random values from all pixels on the canvas of the input image. Colors tend toward the mean.
  • 3 - Samples random values from the unique colors of the input image. Sometimes produces images that are more color accurate. (Default)

--filename, -f

  • Location of the input file. Use with -f ~/location/to/file.jpg. (Default: ../examples/default.jpg)

Inspiration for Lines & How it works

Lines is a program I wrote a while back to tackle the following programming challenge. I finally got around to converting the program from python to C++ for performance reasons while also adding some new features.

- Load an image (source image).
- Generate a list of all the colors from the source image.
- Create 2 blank images (image1 and image2).
- Draw a random primitive on image1 using a random color from the source image.
- Compare image1 to the source image.
- If image1 is closer to the source image than image2, copy image1 to image2. If not, copy image2 to image1 and continue iterating.

Lines however utilizes some tricks to vastly speed up performance while more or less creating the same results. For instance, Lines only does comparisons on CV matricies with RGB values and will only check RGB values along the pixels that have changed.

./Lines -c 3 -a true -p 50 -i 10000000 ./Lines -c 3 -a true -p 50 -i 10000000

Example Gallery

About

Create art using randomly generated lines. 🎨

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published