Enhancement of the Fractal Flame Algorithm
László Simon
Budapest University of Technology and Economics
Abstract
In this article a visually appealing IFS rendering method is presented, that is based on the fractal flame
algorithm, introducing new features to increase quality and variability. First of all, the set of iterating
functions is extended. As the next step, the effect of interpolating between iteration loops is discussed. Finally
the adaptive filtering technique used for rendering is described. During the development the elaboration of
such methods were emphasized that allow the incorporation of new, spectacular effects into the visualization
of iterated function systems.
Categories and Subject Descriptors (according to ACM CCS): I.3.7 [Computer Graphics]: Fractals
1. Introduction The dimensions of IFS fractals are not fixed, but they
are typically generated in two dimensions. The fractal
Fractals form one of the major areas of artistic image itself is a recursive solution of a set of equations and is
generation. One of their three classes is the increasingly formed as the union of its self-mapped copies. All copies
researched iterated function systems. There are two are transformed by a function. This is where the term
utilization areas of this class: image compression and function system has originated. [Bar87]
image generation. In the field of image compression an
IFS system is retrieved based on the image, while in the Formally the formula of an IFS fractal is the following:
other case images can be generated based on IFS systems. S=
This article focuses on the field of image generation. f ( S ) , where
0≤ i < n
i S ∈ ℜ 2 ; fi : ℜ 2 → ℜ 2 .
First the general description of iterated function The functions of a general IFS fractal fi(S) are linear,
systems is overviewed, then a visualization algorithm, the practically describing affine transformations. Their
so called chaos game procedure and its advanced version formula in an n-dimensional form is as follows:
the fractal flame algorithm is explained, finally an
enhancement of the fractal flame method is presented. As f i (r) = A ⋅ r + b
a first step new transformation functions are defined, and a
new method of generating such functions is introduced. In
the next step to increase the variability of the algorithm, 2.2 Chaos-game
the iterating functions are extended with non linear and
periodic members. Iterated function systems can be rendered several ways.
One of the wide spread methods is the so-called chaos-
The coloring and symmetry generating methods of the
game algorithm. Starting from a point in a plane a
original algorithm are also modified. This is followed by sequence of iterations is carried out. In every step one of
the most spectacular parts of the enhancement, the
the functions of the system is randomly chosen. By this
interpolation between the iteration cycles and the blurring are the coordinates of the point modified, and the new
effects. Finally an adaptive filtering technique is presented
position is registered for display. As the number of
that can be utilized in the rendering of iterated function iterations increase, so emerges our fractal (see figure 1.).
systems.
2. Background
2.1. Iterated function systems
Figure 1: Formation of the Sierpinski triangle in a chaos
The iterated function systems or IFS-s form one of the game algorithm
major classes of fractals. They were first described by
John Hutchinson (1981), and have become widely known
to the public due to the work of Michael Barnsley.
L. Simon / Enhancement of the Fractal Flame Algorithm
The improvement of this method is the indication of the The main point of the procedure is that the IFS is first
density. Using this procedure gray-scale or color images mapped onto a three dimensional surface. As the first step
can be generated as well. Its principle is that a counter is an R (u, v ) parametric three dimensional surface is
assigned to each point of a plane, the counter is increased chosen, where computed from the x, y coordinates of the
with one when the system has passed through this given actual point of the function system we obtain:
point. The set of counters is the so-called density
1+ x 1+ y
histogram. The values of the histogram can be visualized u = umin + ( u max − u min ) , v = v min + ( v max − v min )
if they are mapped onto the shades of gray or a color 2 2
palette, that displays the density distribution.
The IFS can be bounded on the surface by
umin , u max , v min , vmax parameters. In the next step R(u,v) is
2.3. The „Fractal flame” mapped onto the viewer plane by axonometric or central
(perspective) projection. Out of the new functions in
The „fractal flame” is a generalization of iterated function appendix A 1, 2, 8, 9 functions were used with this
systems, invented by Scott Draves in 1992 [Dra92]. The method.
major differences from the original concept are listed here:
− non linear functions in stead of affine 3.2. Extending the iterating functions
transformations,
The major advantage of the transformation functions is
− logarithmic indication of density in stead of linear
that they cease the linearity of the IFS. Nevertheless this
indication,
can be obtained by directly changing the iterating
− structure based coloring in stead of monochromatic functions. The human perception can easily tell the
shading. difference between linear and non linear curves. Telling
the difference between different types of non linear curves
The first element modifies the structure of fractals, the is much harder. Therefore the type of non linearity is not
other two improve the quality of visualization. first priority concerning the result. Because of this and to
Besides generalizing the iterated function systems, reduce computational costs the non linearization of the
Draves published an application for generating „fractal iterating functions is solved by their extension to 2 degree
flame” images. The program was written to present the polynomials. The extended function is the following:
eye-catching advancement compared to the previously
a x 2 + ai ,1 y 2 + a i , 2 xy + ai , 3 x + ai , 4 y + ai ,5
presented IFS visualizations f i ( x, y ) = i ,0 2
ai , 6 x + ai , 7 y + ai ,8 xy + ai ,9 x + ai ,10 y + ai ,11
2
3. Enhancements to the algorithm The other salient feature that our visual system is fairly
sensible to is periodicity. The periodicity increases the
esthetical value of an image similarly to symmetry. Due to
3.1. New transformation functions this includes the fractal frame algorithm symmetry
functions. The only disadvantage of these is over-
The transformation functions of the „fractal flame” regularity, the two halves of the symmetrically generated
algorithm significantly change the shape of a fractal, but function system are completely coincident.
have a serious disadvantage that all IFS-s are distorted to
the same distorted field, therefore despite the make- We add periodicity to the algorithm by adding a two
believe do not add much variability to the system. dimensional coordinate dependent sinusoid member
function to the iterating functions. The extended iterating
Mixing the transformation functions is a very expensive function:
task, while all functions have to be computed in stead of
one, and in many cases the distortion effect of the f i ' ( x, y ) = f i ( x, y ) +
dominant transformation function can be easily spotted a i ,12 sin(a i ,1 3 x + a i ,14 ) + a i ,15 sin(a i ,16 y + a i ,17 )
even if the mixing method has been applied. +
a i ,18 sin( a i ,19 x + a i ,20 ) + a i , 21 sin( a i , 22 y + a i , 23 )
As a first attempt to increase the variability 14 new
transformation functions have been added to the
algorithm. These functions are listed in appendix A. 3.3. Symmetry, modification of the coloring
The original functions of the „fractal flame” algorithm
are two dimensional distortion functions, some of these We have incorporated the symmetry part from the original
are well-known in image processing. In the followings we fractal flame algorithm, but not as an additional function
present a new method for creating transformation but in the iteration loop. This way a more fluent
functions, by which a new class of transformation interpolation became possible in case of rotational
functions is formed. symmetries.
The main point is the following: the rotational
symmetry is not defined by a discrete symmetry value, but
L. Simon / Enhancement of the Fractal Flame Algorithm
by a continuous φ symmetry angle. From this angle a non although a computationally costly solution. A substitute
integer s number of symmetries is obtained. In every had to be found.
iteration loop a random number is generated on interval (0,
s), then φ is multiplied by the integer part of this s value. As a first attempt linear interpolation was used between
Using the obtained φ’ angle is the given coordinate rotated the two values (see Figure 3a). The major failure of this
around the origo. Due to this when the symmetry angle is method is the the blurred surface „plane”, does not follow
continuously increased, the symmetry branches close a the shape of the IFS properly. To make the surface aligned
decreasing angle, giving room for the next branch, that to the curvature of the function system, the linear
emerges on the way. interpolation was placed one iteration loop backwards.
This way the surfaces are properly aligned in the rendered
In the coloring method used in the „fractal flame” image (Figure 3b). The equation of this method is the
algorithm, the colors of the generated image are positioned following:
on a curve in the three dimensional (red, green, blue)
colorspace. This limits the number of used colors. P ' n + 1 = f i ( r P n − 1 + (1 − r ) P n )
In stead of a method that utilizes a color palette, such a If the density function of the r value is specified, a
solution is used, where a real, three component color is pattern can be rendered onto the surface of the IFS. The
assigned to the chaos-game, not a color index. This color result can be seen on Figure 3c.
value converges to the color of the chosen function
throughout the iteration. Consequently not only the colors
of a one dimensional color palette appear on the image,
but a linear combination of the colors of all functions.
3.4. Blurring effects
By further modification of the chaos-game blurring effects a) linear b) prelinear
can be incorporated into the algorithm. One of the applied
methods is that to the actual point a disturbance is added
whose amplitude is linearly proportional to the distance
from its position in the previous iteration loop (see Figure
Figure 2:). As an effect of the disturbance the details of the
function system are blurred in varying amount. Since the
chaos game converges the actual point to the IFS set over
and over in every iteration loop, the blurring in stochastic
sense is proportional to the displacement of the point.
Consequently the change or gradient of the blurring is
continuous over the visual details of the IFS. This bluring
emphasizes the three-dimensional illusion of the generated
image. c) patterned
Figure 3: Surface blurring
On the diagram of Figure 4 can be seen how the
different blurs influence the path of a a given point during
the iteration.
3.5. Densification
a) scheme b) result
The next enhancement of the algorithm called iteration
Figure 2: Curvilinear blurring densification works similarly to the previously presented
blur method. This increases the frequency of the repetitive
details of the fractal. The procession of the computation is
The essence of the other blurring method is that the the same as in the case of surface blur, but the r parameter
iterations of the chaos-game are interpolated. According to here is not a random number, but a user defined value. The
point Pn point Pn+1 is computed, but a Pn+1’ point is other difference is that the point Pn’ is not only the location
displayed, that is generated randomly between points Pn of displaying the point, but this value is propagated to the
and Pn+1. To achieve an adequate effect, that the result next iteration step as well. So the iteration proceeds only
envelopes the original IFS, the P ' n + 1 = M r ⋅ P n equation an 1/r part of the original step. The effect of iteration
should be used, where r is a random number, this is densification can also be seen on the diagram of Figure 4.
L. Simon / Enhancement of the Fractal Flame Algorithm
1 x+ n
1 x − 1+ n
0.1 y Cx = ∑
2n + 1 i = x − n
Ci = ∑ C i − C x − 1− n + C x + n =
2n + 1 i = x − 1− n
1
= C x− 1 + ( − C x − 1− n + C x + n )
0.05
2n + 1
where 2n+1 is the width of the kernel, Cx is the color
component at position x.
x
0 The adaptive filter is built from these fast blurring
-0.5 -0.3 -0.1 0.1 kernels. In the algorithm 2n size filters are used where n is
integer. The image is blurred by the maximum 2 nmax size
Basic kernel, then it is combined as a function of its difference
Prelinear
-0.05 from the original image with an image blurred by a 2 nmax-1
size kernel. The bigger the difference, the more the image
Densificated blurred with the smaller size kernel will be seen. By
reducing n and iterating the image combination, we get to
Linear -0.1 the final image.
The pseudo-code of the blurring filter is the following:
Figure 4: Surface blurring and densification – path of a
point during iteration
result image = original image blurred by an 2nmax width
filter
for n = nmax-1 downto 1 do begin
filtered image = original image blurred by an 2 n width
filter
differece image = gradient of result image
result image = (1- difference image) * result image
+ difference image * filtered image
end;
Figure 5: IFS generated by densification
3.6. Adaptive filtering
As a consequence of their method of generation the IFS-s
remain noisy despite the referred quality enhancement Figure 6: The effect of adaptive filtering
methods. The reduction of the noise can be obtained by
adaptive filtering presented in the followings.
4. Future directions
Adaptive filters have a great variety of realizations. One
of these is that all pixels of the image are convolved by a The algorithm and the corresponding application could be
from pixel to pixel determined size convolution kernel. developed in several directions. Similarly to the making of
This method has a huge computational cost, because in quasi-continuous iterations an interpolation between the
case of a n x n filtering kernel, n x n pixels need to be transformation functions is realizable. In the visualization
involved in the computation. Therefore adaptive filtering particle-systems and ray-tracing can be used, but the
is produced by a combination of different, fast, fixed size computational costs would significantly increase. To
filters. enhance the coloring tone-mapping could also be
incorporated.
Even fix sized filters can be created different ways.
There are filters using convolution kernels, Fourier
transforms, etc. The simplest realization of blurring filters
References
is the averaging kernel, that computes the mean value of
the pixel´s given size neighborhood. The advantage of the [Bar87] BARNSLEY, MICHAEL F.: Fractals everywhere,
fix sized averaging filter is that the computational cost of Viking Penguin Inc., 1987.
the convolution can be radically reduced by extending the
algorithm with accumulators. The acceleration in one [Dra92] DRAVES, SCOTT: The Fractal flame algorithm,
dimensional case is according to the followings: 1992.
L. Simon / Enhancement of the Fractal Flame Algorithm
Appendix A – New transformation functions
No. Space Sample Image Function Name
Original
ϖ 2−1 ω ⋅ sin( 20ϖ ) + cos(π ⋅ y )
ω +ω
1. V1 ( x, y ) = 2 2 Snail
2 1 − sin(π ⋅ y )
1− 2⋅ ω ⋅
2
cos(π ⋅ x ) ⋅ cos(π ⋅ y )
2. V2 ( x , y ) = Globe
sin(π ⋅ y )
ln( x + y ) ⋅ sin x
3. V3 ( x, y ) = Grass
ln( x + y ) ⋅ cos x
*
1− r 1− r
4. V4 ( x , y ) = 2 +1 2 + 1 Gravity
y − 1 x − 1
sin( r ⋅ π ⋅ ϕ ) ⋅ arctan(π + ϕ ) / 1.5
5. V5 ( x, y ) = Hypercircle
cos( r ⋅ π ⋅ ϕ ) ⋅ tan(π − ϕ ) / 1.5
*
sin x cos x
6. V6 ( x, y ) = Sandglass
r r
*
1 r ϕ ⋅ (1 − r )
7. V7 ( x, y ) = ⋅ − ϕ S-Space
4 π 2
cos(π x ) ⋅ cos(π y )
8. V8 ( x, y ) = Sphere
sin(π x ) ⋅ cos(π y )
ω ⋅ cos(6π ω ) ⋅ (1 + sin ( π y ) ) ⋅ 0,5
9. V9 ( x, y ) = Spirals
ω ⋅ sin(6π ω ) ⋅ (1 + sin ( π y ) ) ⋅ 0,5
*
sin x cos y
10. V10 ( x , y ) = Television
r r
L. Simon / Enhancement of the Fractal Flame Algorithm
*
cos x sin x
11. V11 ( x, y ) = Tube
y y
*
sin x cos y
12. V12 ( x, y ) = Flowerpot
r r
V13 ( x ) = x + sin( y * 10) / 10
13. Waves
V13 ( y ) = y + sin( x * 10) / 10
*
x + sin(10 y ) y + sin(10 x)
14. V14 ( x, y ) = Weave
10 10
where
x x y
ω = 2 ⋅ − trunc , r = x 2 + y 2 , ϕ = arctan .
2 2 x
Appendix B – Sample fractals created by the enhanced fractal flame algorithm