twice two . com

Color Growth

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

(Click to start the growth. Press 'b' to add 3D highlights (like impasto), press any other key to clear.)

Jeremy Awon came up with this clever effect that generates lovely random "painterly" images. The effect is simple to describe:

  1. Start with a blank image, and call all the pixels "dead".
  2. Set one pixel to a random color, and mark it "alive".
  3. For every dead pixel which has a least one living neighbor (a "boundary" pixel), bring it to life, and set its color to that of one of its living neighbors (chosen at random), but slightly mutated. (Mutating the color causes the "painterly" strokes effect.) Continue until all pixels are alive.

My version uses a slightly different method, where boundary pixels are colored with the average of the colors of their living neighbors, slightly mutated. This adds a bit of blurring, softening the edges of the strokes. I've also added bump-mapping, which gives a nice "thick paint" effect.

I've been experimenting with a couple of variations on this technique.

  • My version processes the boundary pixels by processing all the pixels in random order, and then ignoring those that are not on a boundary. It is possible to influence the "speed" of the growth, by adjusting the probability that a given pixel will be processed. For example, one could use a texture to make the growth go slower in specific parts of the image. Because the speed of the growth influences the shape and direction of the "strokes", this provides a measure of control over the generated image.
  • Another easy trick is to change the color mutation rate, per-pixel. This version uses the number of living neighbors to set the mutation rate; there wasn't a particular reason for doing this, it just looks nice.

I've also been experimenting with using this effect to create painterly versions of existing images (original image). This works by mixing in the color from the source image, along with the averaged, mutated color. A fixed mixing factor doesn't work very well, so this image was generated by using the edges of the source image to control the mix. Areas with a low rate of change have a lower mix, while sharp edges have a high mix. Unfortunately, Processing doesn't have a built-in edge-detect filter, so there's no source for this version yet.