__Overview__

Buddhabrots are a different way of visualizing the Mandelbrot Set. They fall into the general catagory of an “orbit density” plot. The Buddhabrot was discovered by Melinda Green and named Buddhabrot because if you rotate the image 90 degrees clockwise it apparently resembles a sitting Buddha. Just another case of Pareidolia if you ask me.

Images based on orbit density plots had been explored before (see these examples from Linas Vepstas), but the Buddhabrot method was the first to ignore orbits that start within the Mandelbrot Set and only plot points outside the set. This unique discovery led to the Buddhabrot images.

To create a Buddhabrot image, you track the orbits of random starting points on the complex plane that are outside the Mandelbrot Set and count the number of times each on screen pixel is hit. These pixel hits accumulate and create the Buddhabrot image.

Click the following link to launch an applet by Claudio Gonzales that shows the orbits of starting points nicely.

http://www.openprocessing.org/visuals/iframe.php?visualID=3707&width=640&height=640&border=true

Moving the mouse sets the initial point and shows the orbit path the z=z^2+c iterations take.

For the Buddhabrot we are only interested in the starting points that are outside the Mandelbrot Set. These are the orbits colored red in the applet.

__Calculating the image__

Here is the basic idea

1. Pick a random starting point for complex C. A good range is between -0.5 and +2 for the real axis and -1.3 to +1.3 on the imaginary axis.

2. Iterate z=z^2+c in the usual Mandelbrot way until the iterations reach a specified maximum iterations limit or the magintude of z is greater than a bailout value.

3. If z did exceed the bailout, it is a point not in the set, so reiterate the initial random point and each pixel it hits on screen you increase the hit count.

4. Every so often use the hitcount buffer to build the image you plot to the screen.

5. Goto 1 as long as it takes until a smooth image is rendered.

__Speedups__

The above method will work and if you have a lot of patience you will slowly start to see a Buddhabrot image appear, but there are many ways to speed up the process of rendering Buddhabrots. Here are a few I found and implemented in the latest version of Visions Of Chaos.

1. When looking for a random starting point for each orbit, the main cardioid and smaller 2nd period bulb areas of the Mandelbrot set can be easily detected and instantly skipped (saving the time of waiting for the z=z^2+c iterations to reach the maximum iteration value).

2. Use a good random number generator. The default random number generators in most compilers have a fairly low period of values before they start repeating the same numbers again. For the Buddhabrot you need a random number function that can return a huge number of random values before they start repeating. A good (and fast) generator I use is the Mersenne Twister.

3. Take advantage of the symmetry of the Mandelbrot Set. Each time a point on the orbit is found, it has a mirror point around the imaginary axis. Checking for these is minimal code and if you are rendering the whole image or any area around the imaginary Y axis then this gives a nice 2x speedup (and also gives the renders a symmetric look).

4. Do NOT reiterate the initial point if a valid orbit is found. Create an array or list and store the points the orbit goes through while testing. If you find it is a valid orbit you can use the array of points to update the hitcount buffer without the overhead of going through the iteration again.

5. Periodocity checking. As you iterate each point do a quick check to see the point is going through the same set of points. Basics of this is you keep track of an oldz complex value. If the new z during the z=z^2+c matches the old one then you know you can stop iterating. You can set the oldz to z after each iteration but this only checks for single period orbits. The better method is Brent’s Method. Any time the iteration is a power of 2 you set the oldz to z.

Using the above simple speedups gave me a massive improvement in performance. Without those I had a long slow wait until the familiar buddhabrot image appeared. With the speedups leads to millions of pixles per second which gets the general image appearing in no time.

There are of course many more ways to speedup the code using tricks specific to your compiler of choice, but those 5 Buddhabrot specific methods will give orders of magnitude increases in speed with minimal effort.

__SQRT Coloring__

Once you have your buffer to keep track of how many times each pixel has been hit, you need a way of converting these hit values into an image.

The naive approach is to simply find the maximum hitcount across the image and get a color value by colval=hitcount/maxcount*255 and setting the pixel color to RGB(colval,colval,colval) or using the colval to map a color index in a 256 color palette. This works, but gives a result that hides a lot of the finer details.

A better approach is to use sqrt scaling. Calculate the colval by colval=trunc(255*sqrt(hitcount)/sqrt(maxcount)). This leads to images that are not washed out in the high end of the hitcount and also not too pixelated in the low end.

__Nebulabrot Coloring__

This coloring idea was inspired from the way NASA colors their hubble images. Each of the RGB channels in an image is collected using different wavelengths and then when combined they make a multi-color image.

The same technique can be applied to Buddhabrot images. You need 3 arrays that keep track of the hitcount for the red, green and blue channels. Each RGB value has a starting and ending iteration range. For example, you iterate for a maximum of 1000 iterations over the image and red is set to the range of between 0 and 50 iterations, green is set to range of 50 to 200 iterations and blue is set to the range of 200 to 1000 iterations. If the iteration count of a certain pixel is 250 then only the blue hitcount buffer is updated. The buffers are then individually sqrt scaled and then combined into the final pixel RGB color. This gives images like the following;

__Metropolis-Hastings__

The main problem with using the Buddhabrot method to render images is when you zoom into them. The initial random points selected for each new orbit need to remain in the range between -0.5 and +2 for the real axis and -1.3 to +1.3 on the imaginary axis to give an accurate image without artifacts. But, the more you zoom into an image, the fewer of these random initial points will lead to an orbit that passes through the “visible area” you are zoomed into. Even at moderate zoom levels this leads to a few pixels hit per second and unless you are willing to leave your PC churning away for a week you are not going to get reasonable quality results from zoomed in images.

Alexander Boswell explains how to use the Metropolis-Hastings method to speed up zoomed in Buddhabrots on this page. This is a superb way to speed up zoomed in Buddhabrots.

The basic idea is that you look for good orbits and then try slight mutations of them. The reason being is that if one random starting point of an orbit goes through your visible zoomed in area, then other points close to it will too.

Here are few moderately zoomed in Buddhabrot images. These took minutes rather than weeks to render.

This first one is at 519 times magnification.

And this one is at 2,427 times magnification.

__Other helpful settings__

Contrast and brightness can help tease out finer details in Buddhabrot renders.

Allow a custom bailout value. Higher bailouts can lead to unique results.

~~Supersampling/Antialiasing. Store the hitcount array(s) in memory at a higher resolution and downsample when displaying. ie The hitcount array in memory is 3x the width and height of the onscreen image. When displaying, each image pixel is averaged from a set of 9 (3×3) hitcount values.~~ This is wrong. No need to supersample the hitcount array. Adding the points to the array “unsupersampled” has the exact same effect as supersampling. Thanks to mx7f for pointing out the obvious here.

Jason.

How use it in adobe photoshop?????????????

Try Richard Rosenman’s photoshop plugin.

http://www.richardrosenman.com/project/?cid=224

I can’t figure out the importance of antialiasing. I think that if point hits one larger pixel, result will be the same as if it hits one of these 9 subpixel, since they are put together anyway.

The result is not the same as each of the 9 “subpixels” can have different values, so once they are averaged out, you get a more accurate hitcount than using just a single value for that pixel.

It is similar to rendering a buddhabrot image 9 times larger and then shrinking it down using an image editing program when finished. The shrink process blurs and averages each single pixel color from the larger image 3×3 pixel areas.

Jason.

But if the downsampling is just doing an arithmetic mean of the 9 pixels to determine the downsampled pixel, that value absolutely will be identical to if the hitcounts were calculated at the lower resolution, except divided by 9. The only way it ends up different is if the hitcounts are averaged in a weird way (say by doing a geometric or harmonic mean).

Of course you are correct. Supersampling (at least when doing the simple averaging of the 9 pixels) has no benefit for buddhabrots. I updated the post. Thanks for ramming this home until it sunk in.

Pingback: Delphi Buddhabrot - Theoretische Frage - Delphi-PRAXiS

Hi, Jason!

I am writing to share with you my recent Buddhabrot-related work. Long story short, there are an infinite number of Buddhabrot-like pareidolic figures.

Here’s the article:

http://vixra.org/abs/1604.0392

My website has images, as well as the reference code and compiled win32 / win64 version of the program:

http://apeirography.com/en/projects/anthropobrots/

I’d appreciate your thoughts and comments!

Sincerely,

István

P.s.: Feel free to delete this comment after receipt. I am writing here chiefly because I could not find an email address by which to reach you.

Hi István,

I will take a closer look when I get some free time.

Regards,

Jason.