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.
- OpenCV
- Cmake
- GCC or Clang
Compile Lines on linux with:
git clone https://github.com/erikkristiaan/Lines.git
cd Lines
mkdir build
cd build
cmake ../
cmake --build .
You can then run Lines from the command-line using command:
./Lines [arguments]
- Line size in pixels. For instance,
-p 50
will render 50px lines to the canvas. (Default: 30)
- Number of iterations to complete per frame. (Default: 20000000)
- Number of times to run the program. Useful for making short animated gifs ffmpeg. (Default: 1)
true
- Lines are generated with anti-aliasing. Usually produces more pleasing images. (Default)false
- Lines are generated without anti-aliasing.
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)
- Location of the input file. Use with
-f ~/location/to/file.jpg
. (Default: ../examples/default.jpg)
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