• February 27, 2021, 11:08:43 PM

Login with username, password and session length

Author Topic:  Cellular Coloring of Mandelbrot insides  (Read 2309 times)

0 Members and 1 Guest are viewing this topic.

Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Cellular Coloring of Mandelbrot insides
« on: January 09, 2020, 07:06:13 PM »
After a bit of encouragement, I'll spill the unexciting secrets of "Tron Bubble Coloring". This is a method to bring out structures in the inside of the Mandelbrot set, i.e. the non-escaping points.

The first half is the true and tested idea of an orbit trap. For each iterated point, you look at its orbit and keep track of the distance to an invariant trap position (TrapX, TrapY); we also remember the iteration of closest approach. The orbit trap can be chosen quite freely, but is supposed to be constant over all pixels of one image. The following code fragment actually tracks a closest distance and a second closest distance. The reason for the latter will be explained shortly.

Code: [Select]
void mandelMinI(double& IterMin, double& Min,  // returned values
const double Cx, const double Cy, const int maxIter,
const double TrapX, const double TrapY) {
  double Re = Cx;
  double Im = Cy;
  double Re2 = Re*Re;
  double Im2 = Im*Im;
  int iter = 1;   // start with iteration 1 to avoid (0, 0)
  int mIter = iter;  // remember iteration of closest approach
  double magnitude = Re2 + Im2;

  // distance to orbit trap
  double trap = (Re - TrapX)*(Re - TrapX) + (Im - TrapY)*(Im - TrapY);
  double min = trap;  // closest distance
  double min2 = 10000.0*min;  // 2nd closest distance

  while (((magnitude) < 10000.0) && (iter <= maxIter)) {
    Im = 2.0*Re*Im + Cy;
    Re = Re2 - Im2 + Cx;
    Re2 = Re*Re;
    Im2 = Im*Im;
    magnitude = Re2 + Im2;
    ++iter;

    // squared distance to orbit trap
    trap = (Re - TrapX)*(Re - TrapX) + (Im - TrapY)*(Im - TrapY);

    // sort current distance into our "list" of closest and 2nd closest
    if (trap < min) {
      min2 = min;
      min = trap;
      mIter = iter;
    } else if (trap < min2) {
      min2 = trap;
    }
  }
... handling of obtained values further below ...
}

So after that mostly standard Mandelbrot iteration loop, we know the iteration of closest approach, the smallest (squared) distance, and the 2nd smallest distance.

If we just use the iteration number, instead of the concentric "ribbons" of level sets, we get round-ish blobs of colors. With an orbit trap position of (0, 0), these are fairly symmetrical and usually centered around minibrots.



Linkback: https://fractalforums.org/programming/11/cellular-coloring-of-mandelbrot-insides/3264/
« Last Edit: January 09, 2020, 07:33:41 PM by hobold »

Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #1 on: January 09, 2020, 07:14:07 PM »
The iteration of closest approach can be used as an index into a color gradient. My default is rainbow colors. The distance to closest approach can be used to apply a bit of shading.

Code: [Select]
  const double halo = 1.0/(sqrt(min) + 1.0);  // central halo
  Min = halo;

This maps the center of each cell to 1.0, with values approaching zero as we approach the cell's boundaries. This was behind my Christmas image from a few years back.


Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #2 on: January 09, 2020, 07:20:06 PM »
And now for the second good ole' idea, this time from procedural texturing of computer generated imagery. If we divide the distance of closest approach by the distance of 2nd closest approach, we obtain values that are 1.0 at the cell boundaries, tending towards zero further inward. (The relevant buzzword here is "Voronoi cell", or "Voronoi cell texture".)

Code: [Select]
  const double bounds = min/min2;  // cell boundaries
  Min = bounds;

With the orbit trap position still at (0, 0), and the same Christmas colors, this results in the original Tron Bubble Coloring.
« Last Edit: January 09, 2020, 07:35:41 PM by hobold »

Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #3 on: January 09, 2020, 07:24:41 PM »
Then I moved the orbit trap position (and tweaked other parameters), and to my surprise, there appeared fine detail inside cardioids and disks. It's not fractal detail, but it's interesting enough.

Code: [Select]
  theVista.trapX = 0.080026;
  theVista.trapY = 0.401725;


Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #4 on: January 09, 2020, 07:29:53 PM »
Of course, highlighting of boundary and of center can be combined. As the saying goes: the possibilities are infinite. :)


Offline Adam Majewski

  • Fractal Frogurt
  • ******
  • Posts: 452
Re: Cellular Coloring of Mandelbrot insides
« Reply #5 on: January 09, 2020, 07:55:55 PM »
« Last Edit: January 10, 2020, 06:26:43 PM by Adam Majewski, Reason: bof61 or atom domains »

Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #6 on: January 09, 2020, 11:34:37 PM »
Can you post the whole code ?
I am hesitant. Firstly, my code is shoddy. Secondly, the stuff outside the core loop is fairly standard: zooming and rotating the view, looping over pixels, anti-aliasing, spline animation paths, and so on. And thirdly, if I give you people just the raw numbers, you will turn them into colors in your own ways. I think there will be more variety if I don't present one specific way.

Offline claude

  • 3f
  • ******
  • Posts: 1784
    • mathr.co.uk
Re: Cellular Coloring of Mandelbrot insides
« Reply #7 on: January 09, 2020, 11:58:03 PM »
If we divide the distance of closest approach by the distance of 2nd closest approach, we obtain values that are 1.0 at the cell boundaries, tending towards zero further inward.
This is roughly the radial part of "atom domain coordinates" https://mathr.co.uk/blog/2017-11-21_atom_domain_coordinates.html (the angular part is harder due to overlaps)

Offline mrrudewords

  • Fractal Frogurt
  • ******
  • Posts: 470
  • Dat Mandel!
Re: Cellular Coloring of Mandelbrot insides
« Reply #8 on: January 10, 2020, 12:06:12 AM »
Very Nice! :thumbs:
Z = Z2 + C (obvs)

Offline gerrit

  • 3f
  • ******
  • Posts: 2333
Re: Cellular Coloring of Mandelbrot insides
« Reply #9 on: January 10, 2020, 12:37:46 AM »
Nice, here's an embedded Julia with that coloring + mini at center.

Offline 3DickUlus

  • Administrator
  • *******
  • Posts: 2050
    • Digilantism
Re: Cellular Coloring of Mandelbrot insides
« Reply #10 on: January 10, 2020, 02:30:01 AM »
Of late I have found the mandelbrot set quite boring,
probably because I'm usually looking at the outside,
but, as you, claude, gerrit and others present new views of the set, inside and out, it is becoming much more interesting again.  :yes:
( but zooms give me vertigo  :P )

Thank you very much for sharing.  :thumbs:

Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #11 on: January 10, 2020, 08:28:02 AM »
I find animating the position of the orbit trap quite striking. Swarms of fireflies taking off from the boundary of the main cardioid, swirling around, and landing again in another place of the cardioid.

I am still not done tweaking the raw values "halo" and "bounds" above in the code. Range rescaling, higher powers, roots, all still clamped in [0.0 .. 1.0], but tinkering with larger and smaller highlights. There doesn't seem to be a single "right" way that works well for all zoom depths.

Playing with gamma curves also makes a large difference in overall impression of these images, at least for the kind of high contrast palettes I use.


Edit: Even the outside at fairly low zoom level can look fresh and unusual when colored in this way.

Offline gerson

  • Fractal Frankfurter
  • *
  • Posts: 512
Re: Cellular Coloring of Mandelbrot insides
« Reply #12 on: January 10, 2020, 03:42:47 PM »
Oh! Where we are going...
Feel free about the code. If you decide to release your program let us know.

Offline mrrudewords

  • Fractal Frogurt
  • ******
  • Posts: 470
  • Dat Mandel!
Re: Cellular Coloring of Mandelbrot insides
« Reply #13 on: January 10, 2020, 05:36:29 PM »
Here's a Butterfly for you.

Used this colouring on Manowar Power 4 formula.

Offline hobold

  • Fractal Fluff
  • *****
  • Posts: 397
Re: Cellular Coloring of Mandelbrot insides
« Reply #14 on: January 10, 2020, 07:06:52 PM »
Here's a Butterfly for you.
Beautiful! I just knew I was depicting ugly worms. :)