Posted by: Tobias | December 10, 2008

Evolving the Mona Lisa

Yesterday a link to a guy who had created a pretty good replica of the Mona Lisa out of semi-transparent, colored polygons using an evolutionary algorithm made the rounds on the interweb.

An evolutionary algorithm mimics the Darwinian mechanisms of random mutation and natural selection. You start with some sort of hereditary material, in this case a virtual DNA specifying the vertices, colors and transparency of the polygons, and then start mutating this hereditary material by randomly changing around the values of any of these three attributes. After the mutation has occurred, the algorithm decides whether the mutation has been beneficial by checking if the new image looks more or less like the Mona Lisa. Technically, this is done by evaluating a ‘fitness function’ which is the sum of the differences in RGB values for all pixels between the original image and the replica. If the mutation decreases the value of the fitness function (a closer match with the original), the mutation is kept, if the value increases the mutation is selected against and discarded.

Mona Lisa Evolved

In the beginning, the results do not look at all very interesting or useful. But after a while, you’ll be amazed at how close you can get to the original image with this incredibly simple and, really, quite stupid algorithm. In fact, five the algorithm enough time and enough polygons to toy with and it will eventually produce an exact replica of the original image. This is exactly what Richard Dawkins means when he says that the theory of evolution answers the questions about the origins of the complexity in all living things with nothing but stunningly elegant simplicity. Intelligent Design my ass.

In case you want to play around with this a bit and have a browser of sufficiently recent vintage (Firefox 3.x or a recent Webkit nightly will do), do check out this implementation of the same idea that popped up today. It allows you to let the evolutionary algorithm work on any image of your choice in the confines of your browser, using nothing but a few lines of JavaScript to manipulate a CANVAS element. Brilliant!

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: