The colours of fractals

 

  

Home Home page

It is necessary to colour fractals in order to visualize them. Colours are a major component of their artistic dimension. This question has greatly evolved these last years with the generalization of graphic cards which can display a high number of colours, and thanks to the imagination of several authors of programs generating fractals. A brief account appears in the sci.fractals FAQ. A significant part of the following text is inspired by a large exchange which has occurred in the "fractal art discussion list".

This page contains numerous links towards several sites and towards the page where I have collected the articles published in this discussion list.

A complex number can be depicted by a point in a plane where the x and y coordinates are the real and imaginary parts of the number (see also here). For the fractals produced by the iteration of complex polynomials each point of the part of the plane displayed on the screen is introduced in a function and the value of the function is monitored during the successive iterations. Each value can be represented by a new point having x1 y1, x2 y2… coordinates. The positions of these points showing the successive values of the function draw an orbit. For some values of the complex variable (= for some starting points of the plane) the orbit is enclosed in a limited region of the plane ; it can even fall in a cyclic trajectory. On the contrary in other cases the orbit escapes towards the infinite after some iterations ; in other terms the function diverges. Indeed an infinite number of iterations would be necessary to be certain of the behaviour of only one point during a mere calculation and no fractal could ever be drawn. The advantage of a good knowledge of maths is that for most of the points it is possible to detect if the function will diverge or not after only an acceptable number of iterations.

Classic methods

There are two ways if you want to show the result of a computation concerning a point. The first one is to use a third coordinate axis and you obtain a fractal relief. The other and most common one lies in the use of a scale of colours to display this value. The number of colours necessary to display adequately the result may be very varied. If you consider the classic case of Mandelbrot or Julia sets, the simplest result to display is the response to the following question : does the point belong to the set ? If yes you give it some colour, if no you give it an other one. Two colours only (black and white for example) are needed and this was compatible with the limitations of old computers.

But it was soon acknowledged that the calculations necessary to answer this simple question give other interesting pieces of information. One of the most classic is the answer to the question : after how many iterations can you see that the point does not belong to the set, ie the orbit tends towards the infinite ? You then get the most classic colouring technique, known as escape time method. If need be you can here again merely use black and white (one for even value, the other for odd ones) to get and idea of the distribution of the values, but results are more aesthetic with a polychrome display : after the 16 colours of the VGA mode of PCs, the 256 colours mode has imposed its standard and was popularized in particular by the famous Fractint program. It can be observed that the points are distributed into "concentric" zones around the area corresponding to the set itself. The zones are tighter and tighter as you go closer to the set. Before going farther pay attention to the fact that it is not the value reached by the function for the latest iteration which is displayed by this method, contrary to what you could think after the (necessary) explanation above concerning the orbits, but the number of iterations needed to see that the orbit escapes.

The classic colouring technique consists in building a palette of successive colours and to assign the colour #1 to the points where the divergence is observed at the first iteration, the colour #2 to the points where it is observed at the second iteration etc. The beauty of images relies on the choice of the colours of this palette. A brilliant lesson on the elaboration of artistic colour palettes is given by Linda Alison for Fractint, but it can inspire you for other programs based on the use of palettes.

Is the fact that colours are limited to 256 (236 for Windows programs, because 20 colours are retained for system display) a limitation ? The answer is both no and yes. No, because if the value to display is over 256 the program restarts with colour #1 (in other words colours are applied modulo 256). Yes, because this does not allow generally a smooth enough transition between adjacent colours. Indeed if it is desirable for many fractal images to have clear limits between some areas of different colours (for example an area of red shades and an area of green shades), it is also necessary to have smooth transitions between, for example, the lightest green shade and the deeper one of an area.

This ends up in two questions which are often confused, but which are distinct : how to suppress undesirable discontinuities in a colour palette ; how to use in the best way the aptitude of the present graphic cards to display a high number of colours ?

Notice indeed that, if you limit the number of colour sets to 2, 3 or 4 in a palette of 256 colours, smooth enough transitions can often be obtained in such a way that discontinuities may be barely visible or invisible (see some images of pages 10 to 12 of the album and this text). But it is obvious that the use of a higher number of colours will help.

True colour fractals

This leads to recent fractal programs which let us use the true colour display feature of the present graphic cards. The expression "16 millions of colours" may open the way to some important misinterpretations. It must be said first that an image cannot have more colours than pixels, that is to say 307 200 in 640x480 or 480 000 in 800x600. But this is not the most important, as you will see now.

If it is better, the expression "24 bits display" covers up a problem as well, because it would be more accurate to say "8x3 bits display". In this mode one byte is allocated to each of the basic colours : red, green and blue. This means that there are indeed 16 777 216 different combinations (2563), but this technique does not allow us to do anything as we like. For example let us imagine that a palette goes from pure red to black : we can only have 256 different colours because colours evolve by integer values between 0 (black) and 255 (pure red). And again if we want to have a palette going from white to black we are limited to 256 shades of grey. The problem will be different (and the number of colours may be greater) if we make a transition between two different colours, and not between two values of lightness of the same colour. But all the possible gradations are not always aesthetically pleasant because some of them give intermediate colours that are dull and muddy.

Moreover it is not enough to have a program handling colours with 24 bits to have smooth colour transitions : it is also necessary that the algorithm computing the fractal provides adequate values. In the classic escape time method it is obvious that it is impossible to have a number of colours greater than the maximum number of iterations chosen for the calculation. And yet the computation is generally limited to one or a few hundreds of iterations owing to the length of the process. It is an intrinsic feature of this algorithm to give discrete areas of colours. Fortunately the number of iterations necessary to detect the divergence is not the only result which can be used to fix the colour of a point. Every algorithm giving progressive fractional values is a good candidate for a true colour rendering.

Linas Vepstas has though up an interesting algorithm giving a progressive variation of colours by a modification of the escape time method. Basically its principle is to compute not only the number of iterations needed to detect the divergence, but moreover how distant the point is from the limit between two successive iterations (see a brief description here and a more comprehensive information at the Linas Vepstas’s site).

Other methods, known for longer may also be useful. For example we can use the angle made by the orbit with the x axis at the time when the divergence is detected. Or again we can use the potential calculated by the formula log |z|/2iterations, (read "log|z|/2^iterations" if your browser does not allow exponents), providing that a very high value is chosen to test the divergence.

From a more general point of view we have seen previously that the classic method uses the number of iterations and not the value of the function when the orbit escapes. But the value of the function or either value derived from it can be used to assign the colour : for example you can use the real part, the imaginary one or every composition of them. You can combine these values with the values of the preceding points of the orbit, or with the number of iterations… If you are not afraid of abstraction, Rich Thomson has developed an interesting formalism to summary a number of colouring methods.

Pay attention to the fact that in the preceding description I have spoken only about the colours of the points outside the set. All the points of the set are displayed with the same colour (blue in the default palette of Fractint, but it is only a matter of convention). But the points belonging to the set are not identical because the results of the iterations of the function draw an orbit restricted to a portion of the plane, but which is different for each of them. Therefore this numerical information can be used to allocate distinctive colours to these points and then to observe coloured structures into the area corresponding to the set itself.

Palette or algorithm ?

And now, how are the colours generated ? Palettes of 256 colours are generally "handmade". However to make a progressive transition into a colour subset it is only necessary to choose the start and the end colours. The palette editor built in the fractal program allows to generate in an automatic way the gradient spreading between these limits. Fractint has a very good palette editor as well as the Terry W. Gintz’s programs.

True colour programs can start from such a palette and interpolate the in-between colours. The flexibility in the choice of colours is retained by building a palette with a limited number of colours and yet the images have tens (hundreds) thousands of colours. The Stephen Ferguson’s programs use another approach : the user does not build the palette by choosing the colours himself, but by the setting of several parameters which make the three colours (R, G, B) to evolve independently in an algorithmic way according to a triangle wave function in previous programs and a sine/cosine one in the latest. The colours are more difficult to control than with a palette but very original effects can be obtained which explain why many fractal creators are interested at the present time by these programs.

But with programs lying on classic palettes as well as algorithmic palettes (like Stephen Ferguson’s ones) the principle is always the same : an index is calculated for each point and a colour corresponding to the index is allocated to the point. In other words a palette is a one dimension list of colours.

However because of the technique used to display colours on the screen, which lies on 3 basic colours (red, green, blue) it is theoretically possible to create colours in a 3 D space. A fractal algorithm can be designed to compute separately the values (in the 0-255 range) for each of the component R, G and B of the colour. Then we have a strictly algorithmic colouring scheme of the image which does not depend on any colour palette. Some authors of programs have used this idea to colour the fractals, either as the exclusive technique or to add nuances to colours obtained from a classic palette. The most advanced thoughts in this way are most probably those of Earl L. Hinrichs. He suggests, for example, to imagine that the fractal image is "lightened" by three independent light sources (R, V, B) and that the position and intensity of each of them can be set by the user of the program. The inventiveness of this author being well known it is not impossible of course that his thoughts are far away from this step. Obviously in most cases his images can hardly be compared to any other ones. Unfortunately Earl Hinrichts has never developed a stable enough program to be shared, but he has exposed his ideas in several circumstances, and this may allow other programmers to be inspired with them.

Now a last point : until now I have reasoned by assuming that the criterion used to colour the point was only determined by the detection of the divergence of the function. But some specialists of fractal images have imagined more subtle methods. For example Paul Carlson has played a decisive role by perfecting « orbit trap » algorithms. Phil Pickard also has greatly contributed to this with his personal algorithms and by sharing his program Fractal Orbits. This program was the first enabling non-programmers to create images using orbit trap techniques. More recently Paul Carlson has adapted these algorithms to Fractint and Ultra Fractal. The principle is to test, for example, if the orbit of the point falls into a circle, an annulus, a square… and to colour the point according to the distance between the point and the limit, or the centre of this figure. The images that are obtained show fractal structures made of spheres, annuli, cylinders, cones with a very characteristic "solid" appearance. To obtain good results it is necessary to use colour palettes with precise features. These techniques are incorporated now into several fractal generators.

As a matter of fact the distribution of colours cannot be separated from the drawing methods : the same function can give flat and boring images or on the contrary exhibit structures which would have been totally invisible with the standard escape time algorithm, or with a palette of colours using a progressive gradient. This is spectacular with the orbit trap algorithms because the number of visible structures (therefore the complexity of the image) is fully dependant of the number of colour sections which exist in the palette, but it is true also for all the fractal images. A page by Damien M. Jones explains how to build formulae for Fractint using non-conventional colouring methods. They need some math knowledge but their interest is to show the tight link existing between shapes and colours in the fractals.

Home Home page

email7a.gif (1115 octets)

Modified : 10.02.2003