GoLineArt — A Generative Art Project

Sistine Chapel Line Art
GoLineArt's output given Michelangelo's Sistine Chapel painting

The image you're looking at above is drawn with exactly 100,000 random black and white lines going across from one edge to the other. This is what the GLA project is about: generating line art from an image using randomness.

How It Works

Given an image as input, golineart first turns the image into grayscale. Then, it creates a white canvas the same size as the input image. The lines will be drawn on this canvas. Once the conversion and the canvas are ready, for each round, the best out of N random edge-to-edge lines is chosen and then drawn onto the canvas. After many rounds, the final output ends up resembling the original input drawn with only black and white lines.

Original Mona Lisa Painting
Original Mona Lisa
Mona Lisa GLA's output after 1,000 rounds.
1,000 rounds
Mona Lisa GLA's output after 10,000 rounds.
10,000 rounds
Mona Lisa GLA's output after 100,000 rounds.
100,000 rounds

100,000 rounds is a lot, and you might be wondering how long does it take for the program to generate this output. GoLineArt is configured to utilize the maximum amount of workers (goroutines) as possible on your system. I generated the Mona Lisa example using my MacBook Pro with the M1 Max chip and 32 GB of RAM and it took exactly one minute to generate the output.

How It's Made

I made this entire program using Go (and a few shell scripts to help build and batch generate images). Go has an amazing image package that allowed me to do everything I needed when it came to processing the image data.

The star of the show is the line drawing algorithm. I ended up using Bresenham's line drawing algorithm to find the pixel positions of a line from point a to b on the canvas. Once the line's pixel positions were found, all that was left to do write an algorithm to create many random lines and choose the best out of them all. To choose the best line out of them all, I used a square error algorithm.

I call the process of generating a line and calculating the difference in pixels between the line and the grayscale image a round. Once the process for one round was defined, all that was left to do was making it loop this process over and over again.

Take a Deeper Dive

There is a lot to go over, so if you'd like to take a deeper dive, or download and test the app for yourself, make sure to check out the GitHub repo for this project.

TL;DR

I made a program that makes line art out of images using random black and white lines. Check out the releases.

Additional Examples

Example 1
Example 2
Example 3
Example 4
Example 5
Example 6