views:

189

answers:

5

I'm sure many people have already seen demos of using genetic algorithms to generate an image that matches a sample image. You start off with noise, and gradually it comes to resemble the target image more and more closely, until you have a more-or-less exact duplicate.

All of the examples I've seen, however, use a fairly straightforward pixel-by-pixel comparison, resulting in a fairly predictable 'fade in' of the final image. What I'm looking for is something more novel: A fitness measure that comes closer to what we see as 'similar' than the naive approach.

I don't have a specific result in mind - I'm just looking for something more 'interesting' than the default. Suggestions?

A: 

I haven't seen such a demo (perhaps you could link one). But a couple proto-ideas from your desription that may trigger an interesting one:

  • Three different algorithms running in parallel, perhaps RGB or HSV.
  • Move, rotate, or otherwise change the target image slightly during the run.
  • Fitness based on contrast/value differences between pixels, but without knowing the actual colour.
  • ...then "prime" a single pixel with the correct colour?
Chris Thornhill
A: 

It sounds like you want a rule that identifies structures in an image and attempts to create them. You could look into pattern recognition: wikipedia

Nash0
+1  A: 

A fitness measure that comes closer to what we see as 'similar' than the naive approach.

Implementing such a measure in software is definitely nontrivial. Google 'Human vision model', 'perceptual error metric' for some starting points. You can sidestep the issue - just present the candidate images to a human for selecting the best ones, although it might be a bit boring for the human.

Rafał Dowgird
That's why I said 'closer', not 'identical'. There's got to be something that's better than per-pixel comparison, but easier than implementing an AI. :)
Nick Johnson
Using a human isn't such a bad idea, either, but humans do rather poorly at comparing two different random-noise images.
Nick Johnson
This depends on how you generate the images. I've seen an article about an evolutionary algorithm approximating an image with a limited number of transparent closed bezier curves.
Rafał Dowgird
See, now that's what I'm interested in. :)
Nick Johnson
Do you have a link? I'm positive I've seen that before, but I can't recall where, and I can't find it.
Nick Johnson
You're probably looking for this: http://alteredqualia.com/visualization/evolve/
Mark Renouf
A: 

I would agree with other contributors that this is non-trivial. I'd also add that it would be very valuable commercially - for example, companies who wish to protect their visual IP would be extremely happy to be able to trawl the internet looking for similar images to their logos.

My naïve approach to this would be to train a pattern recognizer on a number of images, each generated from the target image with one or more transforms applied to it: e.g. rotated a few degrees either way; a translation a few pixels either way; different scales of the same image; various blurs and effects (convolution masks are good here). I would also add some randomness noise to the each of the images. The more samples the better.

The training can all be done off-line, so shouldn't cause a problem with runtime performance.

Once you've got a pattern recognizer trained, you can point it at the the GA population images, and get some scalar score out of the recognizers.

Personally, I like Radial Basis Networks. Quick to train. I'd start with far too many inputs, and whittle them down with principle component analysis (IIRC). The outputs could just be a similiarity measure and dissimilarity measure.

One last thing; whatever approach you go for - could you blog about it, publish the demo, whatever; let us know how you got on.

jamesh
+3  A: 

I assume you're talking about something like Roger Alsing's program.

I implemented a version of this, so I'm also interested in alternative fitness functions, though I'm coming at it from the perspective of improving performance rather than aesthetics. I expect there will always be some element of "fade-in" due to the nature of the evolutionary process (though tweaking the evolutionary operators may affect how this looks).

A pixel-by-pixel comparison can be expensive for anything but small images. For example, the 200x200 pixel image I use has 40,000 pixels. With three values per pixel (R, G and B), that's 120,000 values that have to be incorporated into the fitness calculation for a single image. In my implementation I scale the image down before doing the comparison so that there are fewer pixels. The trade-off is slightly reduced accuracy of the evolved image.

In investigating alternative fitness functions I came across some suggestions to use the YUV colour space instead of RGB since this is more closely aligned with human perception.

Another idea that I had was to compare only a randomly selected sample of pixels. I'm not sure how well this would work without trying it. Since the pixels compared would be different for each evaluation it would have the effect of maintaining diversity within the population.

Beyond that, you are in the realms of computer vision. I expect that these techniques, which rely on feature extraction, would be more expensive per image, but they may be faster overall if they result in fewer generations being required to achieve an acceptable result. You might want to investigate the PerceptualDiff library. Also, this page shows some Java code that can be used to compare images for similarity based on features rather than pixels.

Dan Dyer
Aha, that was the one! Thanks!
Nick Johnson