Eternally bored, I made a fractal tree program. This particular fake tree has pseudorandom branch angles, and random length decreases per offshoot. It is a program that could best be described as "cute". The next thing I did was to include a list of offshoot angles and lengths to describe the tree. This could be considered analagous to a "genetic" code. I then made the program "grow" with 50 such arrays and breed/kill them to meet some simple criteria. This was fun, but absolutely useless. The idea was to have a simulator come up with an ideal shape, without being told specifically what particular shapes are good. This exercise led to the rest of the junk you will find on this page...

 

 

Im my next attempt to avoid boredom, I decided to try genetic image compression. My first attempt was pretty bleak. The genetic code describes the orientation and color of 50 rectangles. The simulation contained 50 such strands. Each strand was permuted and compared to a source image. The 50% of offspring most like the original image were bred together and the results replaced the worst 50%. This was repeated over and over. Six hours later...The pic on the left is the original test pattern, and the pic on the right is the genetic approximation. The number 53155 is the arithmetic diference between the two. A zero would indicate a perfect match. (it's not even close! : ) )

 

 

Needless to say, rectangles suck at approximating images! My next experiment used genes to describe a mesh of interlocking colored polygons. The mesh is contorted and recolored over and over to best match a source image. These meshes were then bred in much the same way as before, except I added some tricks to speed the process up. For example, an offsping inherrits the "best" polys from each parent, instead a random sampling from each. Then when the offspring is mutated, only the "worst" polys are changed. This demo is real fun to watch. You see this sea of colored shapes swarming around frantically. Some polys seem to "stick" in place like puzzle pieces. The image materializes very rapidly at first, setting every poly to something close to ideal, but then it gets slower... and slower, and s l o w e r. The previous example took all night to solidify to the state you see.

 

 

By popular demand, (ian and scott) I included a facility to import PCX files instead of those crappy test patterns. I tried running my genetic mesh on a picture of my friend Boon: After 24 hours, he still didn't get to looking much better than the example image. (The compression ratio is 32:1, but its obviously very lossy.) I spent a great deal of that day staring at my screen while the program tried for hours to put square pegs in round holes (bright green triangle on the forehead, devils horns, etc...) for what seemed like an eternity.

 

I got fed up with it, and genetic algorithms in general (for now anyway...) but I really liked the poly-mesh-image-compression idea. I decided to try to code it in a non-genetic way. Actually, it ended up being a fractal compression scheme. Here's how it did with that same picture of boon. ---->

The jist of it is simple. Split the source image up into four pieces. Then figure out the average color of each piece. Try to split it in such a way that each of the four average-colored pieces most closely matches the original image. Once youre satisfied with these four pieces... split each into four more pieces. repeat until you have the desired quality. This is cool because the polygon edges will line up with object edges in the image. It preserves form way better than rectangles.

 

 

Here are a few more examples using the same tequnique. (all are 25:1 compression, 8 BIT COLOR. The results would be MUCH nicer if I had 16 or 24 bit color for the poly mesh. Right now, it just uses the closest colors from the palette in the original image.)

.and thats where I am right now. <and done patting myself on the back. thanks.>
 
mailto:craig@sunnuclear.com

 

..