RSS/Atom feed Twitter
Site is read-only, email is disabled

Genetic Python plugin - faster draw and fill

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

4 of 4 messages available
Toggle history

Please log in to manage your subscriptions.

Genetic Python plugin - faster draw and fill Freddy 19 Jun 11:25
  Genetic Python plugin - faster draw and fill Alec Burgess 19 Jun 11:45
   Genetic Python plugin - faster draw and fill Freddy 19 Jun 18:27
    Genetic Python plugin - faster draw and fill Omari Stephens 20 Jun 09:22
Freddy
2009-06-19 11:25:12 UTC (over 15 years ago)

Genetic Python plugin - faster draw and fill

Hi,

maybe you have read about Roger Alsings "Evolution of Mona Lisa" ( http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/ ). I am trying to write a plugin (script) for GIMP that does something like this. The plugin should create a lot (maybe 500000 to 1000000) generations of new images and try to resemble the original image as much as possible using only polygons(each generation consists of 1 to 10 images, and "dies" as soon as a new generation is born, so I dont plan on having a million images open at the same time ;).

Basically its working like I want - I can create new images, create a selection based on evolved points using gimp_free_select and fill the selection in the right color and opacity. And in the end I get something that looks like Roger Alsings Mona Lisa. ( http://sanguis-lunae.de/Uni/ml5-10000.bmp is what I get after 10000 generations)

But its slow. It takes 30 minutes for only 20000 generations. There are so many ways of doing this I cant try them all. So thats my question: What is a good ( the best?) way to draw about 50 shapes, each with 3 - 10 points (I only use polygons, but I might try circles, brush strokes or something else later) over and over again and then compare it to a given image?

My ideas so far: Simple but slow:
create new image
gimp_free_select to make a selection from a list of points set_foreground to choose a color
edit_bucket_fill to fill selection
copy "goal" image to new layer in this image set layer to DIFFERENCE mode
merge
read mean value from histogram (this indicates how similar the two layers were ( zero would be perfect) mutate a copy of the polygon image (slightly alter one of the polygons, all other stay the same) and repeat

or a second idea: my algorithm only changes one polygon in each new image, so I often draw the same shapes over and over again: create a new layer for each shape
bucketfill shapes on their layers
merge all 50 layers
reuse layers for next generations
and so on
problem: merging takes a lot of time and the original 50 layers are lost if I dont copy them to a new image before merging, so its just as fast as my first idea

And I thought of using path objects for my polygons, but these have to be converted to selections anyway, as they cant be bucketfilled?

But maybe there is a much better way?

Frederik

Alec Burgess
2009-06-19 11:45:34 UTC (over 15 years ago)

Genetic Python plugin - faster draw and fill

Freddy (bigbadwolf21@gmx.de) wrote (in part) (on 2009-06-19 at 05:25):

maybe you have read about Roger Alsings "Evolution of Mona Lisa" (

http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/

). I am trying to write a plugin (script) for GIMP that does something like this. The plugin should create a lot (maybe 500000 to 1000000) generations of new images and try to resemble the original image as much as possible using only polygons(each generation consists of 1 to 10 images, and "dies" as soon as a new generation is born, so I dont plan on having a million images open at the same time ;) .

Have you considered ImageMagik? I'm not well-qualified at either scripting Gimp nor anything but simplest tasks in ImageMagik (just lurk on the IM-list) but the tasks you describe *might* be possible in it and possibly somewhat quicker?

Basically its working like I want - I can create new images, create a selection based on evolved points using gimp_free_select and fill the selection in the right color and opacity. And in the end I get something that looks like Roger Alsings Mona Lisa. ( http://sanguis-lunae.de/Uni/ml5-10000.bmp is what I get after 10000 generations)

btw: the image link you gave and the upper level of your URL both fail to load. Are they working?

Freddy
2009-06-19 18:27:10 UTC (over 15 years ago)

Genetic Python plugin - faster draw and fill

Alec Burgess (buralex@gmail.com) wrote (in part) (on 2009-06-19 at 05:45): Have you considered ImageMagik? I'm not well-qualified at either scripting Gimp nor anything but simplest tasks in ImageMagik (just lurk on the IM-list) but the tasks you describe *might* be possible in it and possibly somewhat quicker?

Thanks, ImageMagick looks interesting, I guess I could use it for my project. But I found several similar projects that are stand-alone, online Flash-based or JavaScript. I want to try something new, and so far nobody made a script or plugin for GIMP / Photoshop or any other image editing software that uses genetic algorithms to approximate an image. At least I could not find any. If I dont get it to work with GIMP, ImageMagick will be the next thing I am going to try.

btw: the image link you gave and the upper level of your URL both fail to load. Are they working?

They should. If it still does not work: It looks like one of Roger Alsings images at about 10000 generations, look at his 10415.jpg.

Frederik

Omari Stephens
2009-06-20 09:22:22 UTC (over 15 years ago)

Genetic Python plugin - faster draw and fill

Freddy wrote:

Alec Burgess (buralex@gmail.com) wrote (in part) (on 2009-06-19 at 05:45): Have you considered ImageMagik? I'm not well-qualified at either scripting Gimp nor anything but simplest tasks in ImageMagik (just lurk on the IM-list) but the tasks you describe *might* be possible in it and possibly somewhat quicker?

Thanks, ImageMagick looks interesting, I guess I could use it for my project. But I found several similar projects that are stand-alone, online Flash-based or JavaScript. I want to try something new, and so far nobody made a script or plugin for GIMP / Photoshop or any other image editing software that uses genetic algorithms to approximate an image. At least I could not find any. If I dont get it to work with GIMP, ImageMagick will be the next thing I am going to try.

You might want to look at Inkscape. Polygon manipulation is more of a vector than a raster process, and Inkscape already has useful functionality that you can likely build off of. For instance, potrace (which is built into Inkscape), could save you a lot of trouble in implementing a quantitative, deterministic fitness measure (which you could subsequently fiddle with, of course). While gimp might tell you whether pixels are close, a traced image may be better able to tell you if the _shapes_ are close.

http://www.inkscape.org/doc/tracing/tutorial-tracing.html

--xsdg