Genetic Art

Kyrre Glette and I wrote a simple image generator using genetic programming for an artificial intelligence course. Here are some of the images it made.

The names are also random.

benedictor

avager

gol

amal

sheel

mement

enide

fruisit

cation

deplorencher

archfork

conds

lipse

habi

tavnit

messions

nicky

emorian

slimsy

crystalgic

courn

centranscription

conded

polytica

How it works

An image is generated by a mathematical expression that calculates a value for each pixel given its (x,y) coordinates. For instance, the simple formula x*y looks like this:

The coordinates range from -1 to 1. The bottom right corner, for instance, has coordinates (1,1), and thus gets the color 1*1 = 1, or white. Here's a typical expression:

The expression trees for the images at the top range from 40 to 1000 operations. These all need to be evaluated from scratch for each individual pixel.

To make the system fast enough for us to play with it in near real time, the expressions were compiled to x87 machine code on the fly.

The functions were all generated by randomly mutating graph nodes using a few simple mutations: Individual nodes in the expression tree would be replaced by similar nodes (often) or by new subtrees (more rarely). Also, two images could be cross-bred, merging the 'genes' of two good-looking images to generate offspring, hopefully combining the valuable parts of each parent image.

By adding looping constructs to the 'expression language', we were able to make the system invent fractal shapes.

Since the images are built from mathematical expressions and not pixels, they can be generated at any resolution. Rendering 50-megapixel images suitable for print is a matter of toggling a switch on the command line.

Animation

There are many numerical constants in the expressions. The overall structure and feel of an image comes from its structure, but the actual incarnation is determined by those constants. The image is only a single point in the 100-or-so-dimensional space of possible parameters. I hacked together a small script that would plot an ellipse through the many-dimensional space intersecting the point defining the original image. Here are some animations:

crystalgic
messions
archfork
amal

An interesting thing to do with this would be to generate the parameters in real time based on some external data source (from, say, running music through a frequency analyzer).

[Comment on this]

Posted 2002 or so
How to enumerate bits quickly using DeBruijn sequences.
GCC has some clever tricks up its sleeve for compiling the humble division operator.
Some simple bite-sized browser enhancements. Drag them to your bookmarks toolbar.
These little hacks were originally posted at the Medallia blog; since I no longer work there, I thought it would be more appropriate to keep them here.
More...
Nov 27 2008
15:18 ui\
15:18 wef
Nov 28 2008
22:08 cool, random art, right?
22:08 seen better, though
Nov 29 2008
19:35 wtf :)
Dec 1 2008
14:12 Kom til Trondheim da...
15:10 hi
Dec 3 2008
14:52 пп
Dec 4 2008
03:56 blabb
04:58 bleep
Dec 5 2008
06:10 yah!
Dec 11 2008
02:38 irc+code
Dec 12 2008
15:22 Not a search box, sorry. And the WAP IRC is gone forever.
Dec 28 2008
20:02 shit
Dec 31 2008
23:09 test - bb
Jan 3 2009
17:11 nice site

My CSS-fu is weak; please use a recent browser.

Some rights reserved.