Friday 27 February 2009

Flame fractal generator


If you have an interest in computer science or mathematics you have probably already heard of fractals. Well, flame fractals are strictly speaking not fractals. They are generated through an algorithm called Iterated Function Systems, which simply consists in iteratively transforming a point in the plane a certain number of times and tracing the historigram of where that point landed (using one of n predefined transformations in the plane at random for each step). There are a few pictures at the bottom of this article.
The main particularity of flame fractals is that they use non-linear functions for the iteration, which results in much more varied forms. The colouring is a little bit more subtle, if you want an idea of how it is done, I would advise you to read this excellent paper written by Scott Draves.

The program is technically interesting to write, since smooth, aesthetically pleasing pictures are usually difficult to compute without using either lots of computing time or memory space. This is mainly because of rendering techniques such as super-sampling (rendering the picture in high resolutions and scaling it down to obtain smoother pictures, very effective but very costly) and High Dynamic Range processing. Also, many millions or even up to a billion iterations are necessary to avoid getting a pixelated picture.

The program here isn't exactly the most user-friendly, but has a small GUI to play with a few parameters, and a binary historigram showing a preview of the final image. Usually to render my flame fractals, I modify the arguments directly in the code which is much quicker. A few shortcomings of this GUI are that you can only specify 2 transformations, you can not specify which color to associate with each transformation and a few other parameters such as output image resolution (set to 1000x1000 for memory space reasons) and number of iterations (10 million for the output image, 10 000 for the preview image). Here's a list of the different transformations I have implemented :
1. Linear (if you want to create "conventional" fractals like Sierpinski's gasket)
2. Spherical (Usually helps the system being contractive, i.e. helps to keep the point inside the screen)
3. Horseshoe
4. Ex
5. Fisheye (usually get good pictures with this one)
6. Heart

Since the program can still be improved in many ways and is my favourite personal project so far, it is far from being abandoned. Also a very recommended project for programmers.

Written in : February 2008
Link for the application : Here (Important note : Before using this program create a C:\Java\pic\ folder or else the fractal won't render)
Skills used : GUI making, Input/Output handling, Memory/Complexity optimization.

Note : All my programs are applications, not applets. Post a comment or contact me if you're interested in a source code.

Examples :

1 comment:

  1. The link is apparently broken. Do you have a new link for your application?

    ReplyDelete