genetic algorithm for line drawings

These drawings were extracted from images using a combination of OpenCV and a genetic algorithm.

First, OpenCV is used to find contour lines and canny edges in the images. On the left are all the lines found this way (typically hundreds of lines) that have been post-processed a bit to smooth longer lines.

On the right are 20 lines selected by the genetic algorithm. The algorithm generates 100 drawings, each with a different set of lines from the drawing on the left. It then automatically evaluates the fitness of each drawing and creates a new generation of 100 drawing, selecting characteristics more often from the highest rated drawings and tossing in some random mutations.

The goal is to capture the essence of the original image in just a few vector lines so that a drawing robot can efficiently recreate it. Below are more examples.

More Genetic Algorithm Drawings

Some more sample results from a drawing app I am working on that uses a genetic algorithm to generate drawing (click for higher resolution):

great-form_individual

Above: face 1, Below: face 2 (same source image as face 1)

great-line_individual

mid_generation

Above: one generation of faces (same source as face 1 and 2)

keeper2

Above: face 3 (different source image), Below: landscape.

keeper