Buddhabrot Fractals


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.

Buddhabrot Fractal

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.
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.


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.

Buddhabrot Fractal

To add a gamma value to sqrt coloring you can use colval=trunc(255*power(hitcount/maxcount,1/gamma)) with a gamma value between 1 and 10. Gamma 2 is equal to the usual sqrt coloring. Thanks to Stefan (see comments) for this tip.

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;

Nebulabrot Fractal

Nebulabrot Fractal


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.

Nebulabrot Fractal

And this one is at 2,427 times magnification.

Nebulabrot Fractal

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.


11 responses to “Buddhabrot Fractals

  1. 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.


      • 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.

  2. Pingback: Delphi Buddhabrot - Theoretische Frage - Delphi-PRAXiS

  3. 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:

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

    I’d appreciate your thoughts and comments!


    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.

  4. Hi Jason,

    one note to the sqrt scaling method:

    colval = 255 * sqrt(hitcount) / sqrt(maxcount)

    should be the same as

    colval = 255 * sqrt(hitcount / maxcount)

    which is equivalent to

    colval = 255 * (hitcount/maxcount)^(1/2)

    With a variable ‘gamma’ instead of the fixed value 2, you get

    colval = 255 * (hitcount/maxcount)^(1/gamma)

    If you let the user determine gamma by a slider control (with gamma >0 … 10), the linearity of the color scaling can be adjusted for an optimized visibility of the details. I have implemented this technique in my JavaScript application


    amongst various other methods to alter the linearity of the color gradient.

    Kind regards,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s