Monday, December 15, 2008

Genetic Programming: Java

Edit: To add example image


The credit for the idea goes to Roger Alsin, you can take a look at his version over at http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/

Anyway, after seeing that I thought I'd give it a try, so I threw together a version in Java that seems to do the trick quite well (albeit a little slowly). I'll throw in some images at some point, but in the meantime you can take a look at the code, play with it, modify it, and suggest any improvements (God knows it needs them)

As promised, here is the algorithm in action, I've tried it on a few images, but here is my version of the mona-lisa. I'll post a few of the other ones at a later stage.

I see that Roger Alsin has subsequently released the code for his, I haven't taken a look yet so not sure how it compares.

You'll need the Java Advanced Image API to use this.

imageCompare.java
imageGenerate.java

My apologies for the sparse comments and inconsistency you might encounter. Simply compile the files and run imageGenerate with a command line of argument of the image you wish to generate.

As a side note: I put this blog together very quickly a few minutes ago so forgive it's bareness and default template.