Smooth 1D Colors #10

fractal 21

Here is another method to generate smooth colors.

I first learned about the log-log smooth coloring method  Continuous_(smooth)_coloring in the mid-1990s on the alt.fractals or was it sci.fractals news group. I was afraid of this method because the log function is slow. Actually, log-log is very efficient. But my fear of taking a performance hit was enough that I continued to use a different method that I call accumulator colors. My method turns out to be slower, but it has other advantages.

I assume you have some basic knowledge about generating fractal images, so I will jump right into the middle

Suppose z_0 is the start point, z_i is the orbit, and R is the escape radius. Color banding, happens when z_i gets close to R. The fractal function is continuous, but a small change in the starting point, z_0 can result in z_i landing on the “other side” of R, and thus getting assigned a different color.

Think of escape counting as adding 1 to an accumulator in the inner loop. The accumulator, acc, is set to 0 at the start of the iteration, and inside the inner loop we have

if( |z| < R ) { acc = acc + 1 }

This should make it obvious how a small change in |z| near R, results in a big change +1 in the result.

Now use this instead:

if( |z| < R ) { acc = acc + 1 - |z| / R }

The added value is between 0 and 1, and it is close to 0 when |z| is close to R. The resulting color is continuous.

The derivative of the function is not continuous. Often the result has a different kind of banding, where the rate of color change varies between bands. If the value is squared then we get a continuous derivative:

if( |z| < R ) { acc = acc + (1 - |z| / R)^2 } has all the math details.

And has many example images

This method has a rich set of variations.

Today’s image required some parameter twiddling to get a color range similar to the first log-log smooth color image.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.