Sunday, July 20, 2014

Frequency-based CA visualization (using Single Rotataion as an example)

Single Rotation rule, color shows flashing rate. Note that different spaceships have different colors.

In the binary cellular automata, cells can have only 2 states: ON and OFF.
This, monochrome images are the most natural choice to visualize such automata.
While informative, this visualization method produces somewhat dull images, especially when spaceships don't have easily recognizable form. My first idea to make it a bit fancier was to add some motion blur, emphasizing spaceships, and it worked well:

Single Rotation rule, with motion blur

Motion blur is effectively a low-pass filter applied to the original BW image. The next idea was to use a combination of several filters to make image more colorful. In my final application, 3 filters were used:

Low-pass filter, detecting cells that are constantly ON. This filter was assigned to the red channel.

High-pass filter, detecting cells that are flashing with period 2 (ON-OFF-...). Green channel was used for this filter.

Band filter (2-nd order), detecting cells, flashing with period 4. If was used for blue.

Together, these 3 filters produce images like this:
Single Rotation rule, with 3 different frequency filters for each color channel.

The picture above shows the Single Rotation rule, where random reactions produce many different kinds of spaceships. Interestingly, this colorization scheme allows to distinguish different spaceships by their colors. Finally, by applying these filters to the animation, you'll get the video above. In this video, the field is initialized with random block at the center (at first it appears red because of high cell concentration), and a vertical bar of 2 cells. In the "Single Rotation" rule, such bar of cells is an example of indestructible still life. After the simulation is started, dense random block starts dissipating, emitting multiple spaceships of different kinds. Single Rotation rule supports a lot of them!

For those who prefer higher resolutions, a HD version is available. Full screen and "HD" quality are recommended.

This colorization algorithm can be applied to any other cellular automata too. For example, here is Conway's Life. Note how still lifes are colored in red, and p2 oscillators are green:

Conway's Life, colorized using the same algorithm. See also HD version.