Genetic Algorithm with Darwin's Face: Dynamic SVG
In a previous post I described how I've implemented a genetic algorithm finding the best set of colored triangles to re-create an image. I've just changed the output of the program: it now saves the output as a dynamic SVG picture. Watch the creation of the picture here:
scrolling="auto" frameborder="1">
[Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
http://yokofakun.googlepages.com/img26660.svg]
(yes I know, this is a colored image whereas the original image was in B&W. This is because my program automatically converted the colors of the triangles to a 8bit-gray-levels image)
[Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
http://yokofakun.googlepages.com/img26660.svg]
(yes I know, this is a colored image whereas the original image was in B&W. This is because my program automatically converted the colors of the triangles to a 8bit-gray-levels image)
The current iteration on Friday:
Pierre
5 comments:
cool!
what is your criterium (objective function) for the best set of colored triangles?
fitness=0;
for(x -> width)
for(y->height)
fitness += abs( diffRed(x,y) )
fitness += abs( diffGreen(x,y) )
fitness += abs( diffBlue(x,y) )
return fitness
With how many triangles did you start? It seems logical to increase this during the run, but likely with some penalty on the number of triangles... maybe an parabolic term for that? Not too few, not too many...
And, are the triangles transparent? I think they should be...
That is really cool!
@Egon: there is between 50 and 250 triangle in each solution (see the parameters maxTrianglePerSolution and inTrianglePerSolution in the source http://code.google.com/p/lindenb/source/browse/trunk/proj/tinytools/src/org/lindenb/tinytools/GAMonaLisa.java
And yes the triangles are transparents: see the 'alpha' field in the internal class Triangle
Post a Comment