In this post we explore generation of natural cloud-like images using Julia sets. We first discuss fractal properties of clouds in general and then introduce Julia sets and how they could be applied to cloud rendering. Finally we arrive in one particular Julia set and work it further until we have a nice, white, cloud-like fractal floating in blue sky.

**Natural clouds are fractals.** When you look at a cloud, the surface might appear bumpy but smooth. But when you inspect it closer, for example by zooming with your camera to an edge of a cloud, you see finer details, smaller bumps, and shapes you were unable to recognise from afar. Were you still moving or zooming closer, finer details again appear. You would never arrive to a truly smooth surface between the blue sky and the white vapour, save for the molecular level. This hints the clouds exhibit the fractal property: finer and similarly structured details appear indefinitely regardless how close you look.

Many naturally occurring shapes carry the same fractal property, at least in scale ranges perceptible for humans. Sea shores provide a popular example and exhibit the coastline paradox: the measured length of a coastline depends highly on the length of the measuring stick. If you half the length of your measurement stick and measure the shoreline again, then your total has increased substantially. Half the stick length again, measure and the total has grown larger still. In effect, the fractal nature of sea shores do not have one absolute length but the length always depends on the resolution of the measuring instrument. Surfaces of clouds are no different: they have nearly infinite surface area regardless of their finite volume.

**Thus, I wanted to try the other way: if a natural cloud behaves like a fractal, can I find a mathematical fractal that resembles a cloud?**

To answer the question, I begun exploring Julia sets for which I had built an explorer recently. Julia sets, named after the mathematician Gaston Julia, are sets of two-dimensional points in which a relatively simple function, when called repeatedly, converges to a some single value instead of growing without limits. The function takes in a complex number and outputs a complex number, and in the case of Julia sets, it consists of a multiplication of the input and an addition of a constant.

For example, one of the most common Julia sets can be constructed with the function where we multiply the input with itself and add the imaginary unit to the result.

**How to convert the function to an image?** Let us render the set as an image, 400×300 pixels in size. For each pixel, we first normalise the pixel coordinates about the centre and then assign the coordinates to a complex variable *z*. Then we call the function above iteratively until the value has grown over some predefined escape threshold or been iterated a maximum number of iterations. If the latter was the case, the function converges and we consider the point to belong to this Julia set. If the former was the case, the function diverges and we consider the point not belong to the set. To make the result more informative, it is a common practice to use shades of grey or other colours to represent the number of iterations it took the function to grow over the escape threshold. After we have iterated the function and attained the grey level for each pixel, we get the result below:

**Figure:** a Julia set where points are coloured according how hard it was for the complex function value to escape. We can see that the structure has fine details that repeat in large and small scale. Therefore this set forms a fractal.

**Searching for clouds.** There are infinite number of Julia sets. By adjusting the function exponent, or the added complex constant, we can always find new Julia sets. Sometimes a tiny change can have dramatic impact on the appearance of the resulting fractal. We can also map the greys to colour gradients for visual appeal and use smoothing techniques to blur the colour steps. Therefore, for finding a set that resembles a cloud, at least there are lots of combinations to explore!

After a couple of days of casual exploring and after a many interesting but not so cloud-like results, certain combination of parameters caught my eye. See the function and its rendering below.

**We found it!** Something in the proportions and shapes of those particular parameter values makes me think of clouds. Maybe it is the spiral shape that resembles a hurricane. Or maybe it is the small bumps between the large ones. I do not know. There is something very cloud-like.

The next step was to pick a good colour map to simulate sky on a nice summer day. After various attempts I landed on a suitable gradient colour sequence, now implemented in the Julia explorer with the palette name *clouds*. The outcome with the selected Julia set was just wonderful.

**It is time for final composition.** My eye was not yet fully pleased. The perfect point-symmetry is non-existent in the real sky. Therefore to further improve the illusion of a natural cloud, I cropped the image to single quadrant and arrived to the final piece, displayed below in reasonable resolution.

**Conclusion.** Although beautiful in all its symmetry, like fractals often tend to be, likely the result is not realistic enough to trick human viewer to take this for a real cloud. It is too perfect. Maybe in future endeavours we could spice it up with a hint of random jitter. Still, I wonder if the current result already resembles some real cloud type?