### 2D Coloring

• 10 Replies
• 306 Views

0 Members and 1 Guest are viewing this topic.

#### Spyke

• Strange Attractor
• Posts: 98

#### 2D Coloring

« on: April 12, 2019, 09:48:46 PM »
The attached image is a test image and default starting point for my fractal program. When I get lost in the weeds, I reset to this recipe and head off again. It is only 30 iterations deep. I post it here only to start a discussion of 2D coloring.

Back in the day I used to talk about 2D colors a lot. Fractal coloring theory has moved way beyond since then. I am working on a detailed article for my web site. I am lazy and a champion procrastinator, it is taking a very long time. So, for today, I offer a vague promise of more details, somewhere, some future time, maybe.

In a nutshell, most fractal coloring is one dimensional. Escape time, distance estimate, escape angle etc. produce one real number from the fractal pixel calculation. That number is used to index into a "palette". The palette is not necessarily just a list of colors, it can be a calculation with many parameters. But, no matter the sophistication of the pixel calculation, or the coloring method, the hand-off between them is a single real-valued number. [TODO: list common coloring techniques, and try to determine a dimension for each.]

2D coloring means simply passing two real values between the fractal calculation and the coloring method. Obviously this requires changes on both sides. I find that calculations that produce complex numbers work best. The real and imaginary parts tend to have comparable size, and the result "makes sense" for the fractal. [TODO: document some of these calculations.] On the coloring side, I create a virtual 2D palette.

I bring this up today because of the wonderful images Bill Tavis has been posting on another thread https://fractalforums.org/image-threads/25/mandelbrot-set-rendered-with-nasa-image-textures/2741.

He extracts two values from the fractal calculation, the potential and the external angle, and then uses them to as coordinated to look up a color in a jpg of a NASA image.
Earl Hinrichs, offering free opinions on everything.

• 3f
• Posts: 1666

#### Re: 2D Coloring

« Reply #1 on: April 13, 2019, 12:49:16 AM »
All images I posted in the Newton-Hines thread use a 2D colormap.
The angle of the final iterate is most naturally mapped to hue, which has the matching topology of a circle, and the number of iterations is mapped to saturation and value (colorspace is 3D,  at least for most humans).

• 3e
• Posts: 1142

#### Re: 2D Coloring

« Reply #2 on: April 13, 2019, 07:42:04 PM »
I find this one most appealing... http://iquilezles.org/www/articles/mset_smooth/mset_smooth.htm

modified a little to suit my fractal...

Code: [Select]
 float co = IterationCountAtEscape - log(log(length(Z))/log(Escape))/log(3.); co = sqrt(co/3.); color = vec3( .5+.5*cos(6.2831*co + vec3(0.0,0.6,1.0)) );
I regret that I can't give an in-depth description of what's going on mathematically (IQ does at the link above) very nice 1D?, I'm just an artist and I like this colour scheme

edit: oops forgot the 2D bit... replacing length(Z) and Escape with z.real and z.imaginary reveals interesting topology
« Last Edit: April 14, 2019, 01:47:21 AM by 3DickUlus, Reason: 2D? »
Resistance is fertile... you will be illuminated!

https://en.wikibooks.org/wiki/Fractals/fragmentarium

#### Spyke

• Strange Attractor
• Posts: 98

#### Re: 2D Coloring

« Reply #3 on: April 14, 2019, 09:47:39 PM »
gerrit: Thanks, I knew I saw two threads with 2D colorings, which motivated me to start this thread. But then I could only find one

Those are very nice examples, I like how the white looks like a shiny reflection when (apparently) that is not light source / reflection etc. calculations on a 3D object.

3Dickulus: Looks interesting, I need some time to digest that. Be back later...

• 3f
• Posts: 1172

#### Re: 2D Coloring

« Reply #4 on: April 14, 2019, 11:09:16 PM »
My spacefilling ones commonly use 2d coloring of a sort -- much of the time, the W-Sum Imag and W-Sum Real of elliptic harlequin coloring being the two dimensions used.

#### Spyke

• Strange Attractor
• Posts: 98

#### Re: 2D Coloring

« Reply #5 on: April 15, 2019, 01:38:30 AM »
3dickulus: The article you reference is similar to the Wikipedia  smooth color article https://en.wikipedia.org/wiki/Mandelbrot_set#Continuous_.28smooth.29_coloring. It is nice that Inigo emphasizes that the usual method only works for second degree polynomials and that it must be adjusted for higher degree polynomials. These methods still work for polynomials only. Since they require the f(z) = zd approximation for large z.

Here is a smooth color technique I think you will like. For now I will present a 1D version, in another post I will add some easy 2D extensions. The math is very easy, nothing deep. The motivation is purely artistic, this is not based on any mathematical property of the fractal. Also, it works for any fractal formula. I think I talked about this in the old alt.fractal newsgroup. However I was unable to find any reference to the few articles I checked on coloring techniques.

Now I am going to make this look very mathematical, but that is just for fun, it really is extremely simple. Skip to the TL;DR if you want.
There are two obvious prerequisites, the underlying formula, f(z) must be continuous, and the escape radius, R, must be large enough. But even then, the discontinuity in the colors shows the discontinuity in the function, and/or the chopped off non-escaping orbits due to small R as it should.

Let f(z,c) be our fractal formula, it is continuous in both z and c. For the mandelbrot treatment, set z0 as the starting point and let fi(c) be the ith iteration of f. f0=z0, fi(c) = f(fi-1(c),c). Each iteration function is continuous as it is a composition of continuous functions. For Julia sets the iteration is defined slightly differently, but pretty much any way of defining the iteration if you start with a continuous function then each iteration is continuous.

Let me drop the functional notation where it is convenient and set zi = fi(c).

Let R be a proper escape radius. That is $(|z_i| \geq R) \text{ & } (j > i) \Rightarrow |z_j| \geq R$

Now define
$g(z) = \begin{cases} R - |z| & \text{if} |z| < R \\ 0 & \text{if} |z| \geq R \end{cases}$
This is a continuous function from complex numbers to non-negative reals. It is defined piece-wise from two continuous functions. You only need to verify that the two pieces agree on the seam, for |z|=R both cases are = 0.

Now set a(c) = $$\sum_{i=0}^{N}g(f^i(c)$$. a is a sum of a composition of continuous functions, so a is a continuous function of c.

For most values of c you cannot compute a(c) directly. The intermediate value will overflow from iterating f too many times. But the definition for proper escape radius ensures that $(|z_i| \geq R) \text{ & } (j \geq i) \Rightarrow g(z_j) = 0$ So after we hit the escape radius are we are just adding zeros in the summation. Thus a(c) is a continuous function of the pixel variable suitable for smooth 1D coloring

TL;DR:
If you build a sum of R-|z| while doing the fractal calculation, the result will a continuous value suitable for smooth 1D coloring.

« Last Edit: April 15, 2019, 02:34:45 AM by Spyke »

#### Spyke

• Strange Attractor
• Posts: 98

#### Re: 2D Coloring

« Reply #6 on: April 15, 2019, 01:46:15 AM »
Paul: Can you point me to a reference for elliptic harlequin coloring? I tried to google it and got a non-serious condition found in new born babies. You mention W-Sum is that something like the 1D smooth coloring using summation I described in the in-between post?

• 3f
• Posts: 1172

#### Re: 2D Coloring

« Reply #7 on: April 15, 2019, 03:08:29 AM »
It likely is. I'm referring to the coloring found in akl-m-math.ucl in the Public folder of UF's formulae. To get a 2D coloring from this I typically combine two layers, using two different summations over the orbit, and blending with HSL Addition. It often makes the spacefillers more vibrant and varied, and helps (with some tweaking) to make more of the details (such as Julia set patterns) stand out with sufficient contrast in the image.

#### kosalos

• Fractal Phenom
• Posts: 45

#### Re: 2D Coloring

« Reply #8 on: April 15, 2019, 07:24:45 AM »
Thanks for the algorithm, 3DickUlus.
It also works for 3D ray marching:
IterationCountAtEscape = #iterations until distance to object is very small (or abort).
Z = final position as float3.
Escape = last distance hop.

#### kosalos

• Fractal Phenom
• Posts: 45

#### Re: 2D Coloring

« Reply #9 on: April 15, 2019, 08:23:12 AM »
more examples

#### kosalos

• Fractal Phenom
• Posts: 45

#### Re: 2D Coloring

« Reply #10 on: April 15, 2019, 04:40:12 PM »
Works better if Escape is the weighted average of the distance hops in the marching loop:
Escape = (Escape + lastDistanceHop * 15)  / 16

### Similar Topics

###### coloring tab

Started by mclarekin on Color Snippets

1 Replies
79 Views
June 07, 2019, 05:23:20 PM
by Sabine62
###### Smooth 1D coloring

Started by Spyke on Fractal Mathematics And New Theories

9 Replies
414 Views
June 11, 2019, 06:09:48 PM
by Spyke
###### Smooth 1D coloring

Started by Spyke on Image Threads

17 Replies
363 Views
April 20, 2019, 12:49:06 AM
by Spyke
###### Entropy mandelbrot coloring

Started by gerrit on Fractal Mathematics And New Theories

33 Replies
1960 Views
January 23, 2019, 10:54:05 AM
by FractalDave
###### Coloring of zoom movies

Started by Fraktalist on Kalles Fraktaler

3 Replies
219 Views
June 12, 2019, 12:05:20 PM
by Fraktalist