Genetic Algorithms and the Mona Lisa

Last modified date

Comments: 0

Way back when I was at university (way, way, waaay back) I did some Artificial Intelligence stuff; genetic algorithms, neural networks, and the like. Honestly, though, I really don’t remember much (any!) of it, though I do remember enjoying the genetic algorithms side of things.

I haven’t thought about that kind of thing for quite some time, but the other day while look for something else entirely, I came across a program called EvoLisa. It was written in 2008, but it intrigued me. The program was trying to create a version of the Mona Lisa using a genetic algorithm to ‘evolve’ polygons so that they become fitter and therefor look more like the Mona Lisa. It was written in .Net, but I liked the look of it and wanted to see if I could convert it to run using Javascript and the canvas tag to show the image.

The code

I converted the program and also added using quadratic and bezier curves in order to try to smooth out the image a bit, and I think the results are quite good. I’ve put my code up on GitHub, so feel free to fork and improve!

example output

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.