You are on page 1of 11

# 2009 International Conference on Computational Science and Its Applications

IFS Matlab Generator: A Computer Tool for Displaying IFS Fractals
Akemi G´alvez Tomida
Department of Applied Mathematics and Computational Sciences
University of Cantabria
Avda. de los Castros, s/n, 39005, Santander, SPAIN
galveza@unican.es

Abstract

decades it has been shown that many nonlinear phenomena are so complicated and irregular that they cannot be
modeled well using these classical techniques [18, 19, 20].
The spectrum of examples of this phenomena ranges from
the growth and decline of populations, weather forecast,
fluid turbulence, to topics in economics (see, for example,
[16, 25]). The development of fractal geometry provides
rigorous concepts and practical techniques for the mathematical formulation and analysis of irregular processes [22].
For example, the fractal dimension of strange attractors associated with chaotic dynamical systems gives valuable information about the irregular evolution observed in such
systems [7, 8, 9, 11, 12].
Several fractal modeling and generation methods have
been developed during the last two decades. Among them,
the Iterated Function Systems (IFS) models, popularized by
Barnsley in the 1980s, are particularly interesting due to
their mathematical simplicity [1]. IFS models have been
applied in many disciplines, for example, in artificial landscape modeling in computer graphics. Roughly speaking,
an IFS consists of a collection of functions that map a region onto smaller parts. Iteration of these mappings results
in convergence to a self-similar fractal that is called the attractor of the IFS. Self-similarity means that any portion
of the object, if enlarged in scale, appears identical to the
whole object. This property allows us to characterize the
kind of fractals that can be generated using IFS models in
an intuitive way. Of course, the concept of fractal includes a
wider class of objects, but many of the most popular fractal
images can actually be obtained through an IFS.
Although IFS fractals can be of any dimension, they
are commonly computed and drawn in the two-dimensional
plane. In the two-dimensional space, the fractal is made up
of the union of several copies of itself, where each copy is
transformed by a function (function system). Such a function is mathematically a 2D affine transformation (see Section 2 for details), so the IFS is defined by a finite number
of affine transformations (rotations, translations, and scalings), and therefore represented by a relatively small set of

Fractals are among the most exciting and intriguing
mathematical objects ever discovered. A particular type of
fractals, the Iterated Function Systems (IFS), has received
a lot of attention due to its appealing combination of conceptual simplicity, computational efficiency and great ability to reproduce natural formations and complex phenomena. This paper introduces a new Matlab program, called
“IFS Matlab Generator”, for generating and rendering IFS
fractals. In addition to providing a gentle introduction to
the mathematical basis of IFS, two of the most important
rendering algorithms, the deterministic algorithm and the
probabilistic algorithm (also called “chaos game” algorithm), are briefly outlined. A critical point of chaos game
is the choice of the set of probabilities associated with the
iterated functions. This issue will be briefly discussed in
this paper: we analyze the efficiency of the chaos game algorithm, comparing the standard method for choosing the
probabilities proposed by Michael Barnsley with another
method based on a new multifractal technique [13, 14]. The
latter method optimizes the rendering process by obtaining
the most efficient set of probabilities. Some examples aimed
at illustrating this technique along with a gallery of beautiful two-dimensional fractal objects are also given.

1. Introduction
Traditionally, the classical mathematical concepts and
methods were concerned with smooth objects, ignoring irregular sets. For example, the concept of derivative allows us to analyze smooth curves and surfaces. Nowadays,
smoothness and fairness are still much-desired properties
in almost any mathematical representation of real objects,
wherever it appears. However, in real world irregularity is
the rule rather than the exception: clouds are not spheres,
trees are not cylinders, mountains are not cones and fire
or smoke are not smooth surfaces. In fact, during the last
DOI 10.1109/ICCSA.2009.10

132

Iterated Function Systems input data. Since those functions are usually iterated. Since we are interested in 2D images. which follows from the fact that it is a union of three copies of itself. a lossy image compression method that uses IFS fractals to store the compressed image as a collection of IFS codes [2. A critical issue of this method is the choice of the set of probabilities associated with the iterated functions. This problem will be briefly discussed in this paper: we analyze the chaos game algorithm. w1 . Since we only consider two-dimensional images with the Euclidean distance. the final image might fill any screen size. two of the most important rendering algorithms. each scaled by a factor of 1/2. . called IFS Matlab Generator.x + bi where bi is a translation vector and Ai is a 2 × 2 matrix with eigenvalues λ1 . . There are several well-known methods for rendering fractal images based on IFS.585. b). this compression method is able to achieve higher compression ratios than conventional methods and still offer better quality. . λ2 such that |λi | < 1. The latter method optimizes the rendering process by obtaining the most efficient set of probabilities. For example. 14]. Some interesting examples of IFS fractals along with a gallery of beautiful twodimensional fractal objects are given in Section 4. . 5. while the affine transformations wi are of the form x∗ y∗    x y = wi   ai ci =      x ei . each of which is a translation composed with a scaling of one-half:    x∗ y∗ x∗ y∗ x∗ y∗   = w1   = w2   = w3 x y x y x y   = 0   =   = 1 2 1 2 0 1 2 0 0 1 2 0 1 2 0 1 2      x −1 . 27]. certain parts of the image resemble other parts of the same image. + y −1 This IFS code is usually represented in tabular form as in Table 2. d) is IR 2 with the Euclidean distance d2 . + y 1      x 1 . 21. Section 3 introduces IFS Matlab Generator. Each of these mappings defines one of the three different self-similar gaskets shown in color in Figure 1(right). This method has the great advantage that the final image becomes resolution independent. This result has motivated an intensive research effort in the field of fractal image compression. 2. Once an image has been converted into fractal code it can be recreated by successive iterations at will. The paper closes with the main conclusions and outlines the future work. In this case. The method is based on the idea that in images. since the number of iterations might be theoretically infinite. Section 5 includes a discussion about the efficiency of the probabilistic algorithm for different sets of probabilities and how to select those that optimize the rendering process. the metric space (X. the classical Sierpinsky gasket (see Figure 1) is generated by three mappings. .1. A very important result related to IFS fractals is the socalled Collage Theorem. an IFS consists of a complete metric space (X. we get the name Iterated Function System (IFS). This method differs from other compression methods in that no pixels but fractal codes are stored. an IFS will be onwards represented by a list of the pairs (A. wn }. the probabilistic algorithm (also known as the chaos game) is gaining popularity due to its efficiency and conceptual simplicity. i = 1. + (1) y fi bi di or equivalenty: wi (x) = Ai . . . that roughly states that any 2D image can be approximated to any degree of precision by a fractal using an IFS model. the final image is (approximately) the attractor of the IFS [1]. |det(Ai )| < 1 meaning that wi shrinks distances between points.2. 26. the deterministic algorithm and the probabilistic algorithm. Moreover. The Sierpinski gasket has Hausdorff dimension log(3)/log(2) ≈ 1. we restrict our attention to contractive affine transformations on the real plane. This paper introduces a new Matlab program for generating and rendering IFS fractals. . The structure of this paper is as follows: in Section 2 a gentle introduction to the mathematical basis of IFS fractals is given. We begin with an introduction to IFS fractals. an IFS is a finite set of contractive maps defined on a complete metric space. What is an IFS? As a first notion. 24. Further. relies on the use of the chaos game algorithm. We refer to the IFS as W = {X. The program. In fact. comparing the standard method for choosing the probabilities with another method based on a multifractal technique [13. Among these methods. + y 1      x 0 . 133 . d) and a finite set of linear transformations wi : X −→ X. which is a complete metric space. Note that the three mappings forming the Sierpinsky gasket share the same rotation-scaling matrix while having different translation vectors. Mathematically. In other words. Then. a new Matlab program for generating and rendering IFS fractals by using the probabilistic algorithm. n. are briefly outlined.

Also. 3. In fact.support(ν) = |W|. known as probabilistic algorithm. H(X). |W| supports several measures in a natural way. some nice viewing features such as 3D rotation.. it is possible to show that M is a contraction with a unique fixed point.5 0 0 0. . they avoid us the tedious and time-consuming task to implement many routines for graphical output by ourselves. . Furthermore. However. a similar iterative deterministic scheme can be derived from Eq. pn }. Although our current needs do not require to apply them at full extent. called the invariant measure of the IFSP.2.(2) to obtain |W|. The Markov operator associated to the IFSP is a transformation. 134 . Sierpinsky gasket (left) is an IFS made up of three copies of itself (right) 3. i=1 where S is a Borel subset of X. . i=1 where B(X) denotes the Borel subsets of X. these built-in Matlab routines provide extensive control on a number of different options and are fully optimized to offer the highest level of performance. Program Architecture The program IFS Matlab Generator introduced in this paper for generating and rendering IFS fractals consists basically of two major components: 2. . .5 0 0 0.1. where: Table 1. T . p1 . with n X pi = 1. the powerful Matlab graphical capabilities exceed those commonly available in other CAS such as Mathematica and Maple. . T is also a contraction in H(X) with the induced Hausdorff metric. 1.2. (2) 2. On the other hand.5 1 1 w3 0. coloring and others.5 0 0 0. [3]). . This fact can be easily shown through the introduction of the Markov operator [17]. . . They take advantage of the large collection of numerical routines available in this system. there exists an unique Borel regular measure ν ∈ M(X). i=1 If all the wi are contractions. zooming in and out. IFS Attractor Let us now define a transformation. Using the Hutchinson metric on M(X). labeling. Although this toolbox is enough to meet all our computation needs. Then. wN . . Considering a set of probabilities p1 . potential end-users might be challenged for using it properly unless they are really proficient on Matlab’s syntax and functionalities and the toolbox routines. for the generation of the attractor of an IFS. . Our numerical functions have been implemented by using the native Matlab programming language. Thus.5 0 -1 xk = wi (xk−1 ) with probability pi > 0 (3) (see. scaling. . T has a unique fixed point. a computational library (toolbox): it contains a collection of commands. ν ∈ M(X). for instance. . this is one of the major strengths of the program and one of the main reasons to choose Matlab as a convenient programming environment. S ∈ B(X). in the compact subsets of X. given an arbitrary initial measure ν0 ∈ M(X) the sequence {νk }k=0. . . IFS code of the Sierpinsky gasket a b c d e f w1 0. pn ∈ (0. .5 -1 1 w2 0. Program Architecture and Implementation Figure 1. 1). w1 . This issue will be discussed in Sections 4 and 5.1. such that ν(S) = n X pi ν(wi−1 (S)). |W|. constructed as νk+1 = M (νk ) converges to the invariant measure of the IFSP. have been intensively used in our system. Given a set {p1 . a graphical user interface (GUI): this component is responsible for input/output windowing and smooth interaction with the user.. which are automatically inherited from the Matlab windows system. there exists a more efficient method. This algorithm follows from the result {xk }k>0 = |W| provided that x0 ∈ |W|. called the attractor of the IFS. Usually. In fact. M : M(X) −→ M(X) defined by: (M ν)(S) = n X pi ν(wi−1 (S)). pn } as an IFS with Probabilities (IFSP).. functions and routines implemented to perform the numerical and graphical tasks. by T (A) = n [ wi (A). This i=1 We refer to {X.

a well-designed GUI uses readily recognizable visual cues to help the user navigate efficiently through information. 3..). Me. Screenshot of main window of our program kind of limitations can be overcome by creating a GUI. thus facilitating its use and dissemination. As a result. Although its implementation requires . method and iterations (see Figure 2 and subsequent description in Section 4). 2000. In general. or input) while the OpenGL-based built-in graphics Matlab commands are applied for rendering purposes. Figure 2. this GUI presents an interface which is both aesthetic and very functional to the user. menus. To this purpose. such as PCs (with Windows 9x.2.4 GHz. text boxes for displaying messages. A version for Apple Macintosh with Mac OS X system is also available provided that X11 (the implementation of the X Window System that makes it possible to run X11-based applications in Mac OS X) is properly installed and configured.1. The graphical tasks are performed by using the Matlab GUI for the higher-level functions (windowing. with input boxes for the coefficients of the 135 . Matlab provides a mechanism to generate GUIs by using the so-called guide (GUI development environment). Figures in this paper correspond to the PC platform version. some buttons for additional tasks and a list box to display generated IFS code are also included (see Section 4 for further description). Based on this idea. all graphical output is displayed in separate windows so that the information is better organized and “flows” in a natural and intuitive way. It allows an effective use of powerful interface tools designed according to the type of values being displayed (e. Implementation Issues Regarding the implementation. Below those boxes. However.for complex interfaces . For instance. All our numerical functions have been implemented in the native Matlab programming language.topic under analysis have been grouped and arranged in a rectangular area with an indicative title on the top. This feature is not commonly available in many other CAS so far.a high level of expertise. Additional functionalities are also provided in hidden menus or in separate windows which can be invoked at will if needed so as to keep the main window streamlined and uncluttered. a GUI for the already-generated toolbox has been implemented. list boxes for input/output user interaction. etc. in the upper part of area 1 you can see some boxes and buttons for input/output user interaction. the program supports many different platforms. Figure 2 shows an example of a typical window. initial set. NT. some input boxes are provided in the IFS code area (labeled as 1 in Figure 2). They are also labeled with numbers in red from 1 to 4 in Figure 2 for prompt identification. Thus. Some Illustrative Examples In this section the main features of the program are described through its application to generate and render several IFS fractals. this program has been developed by the author in Matlab [23] v2008a on Windows XP operating system by using a PC with Intel Core 2 Duo processor at 2. functions associated with each 4. radio buttons for single choice from multiple options. such as: code. Session Workflow A typical session in IFS Matlab Generator program begins by writing the IFS code of a fractal. They reproduce the typical structure of an IFS code. 4. Fortunately.g. XP and Vista) and UNIX workstations. it allows end-users to deal with the toolbox with a minimal knowledge and input. and 2 GB of RAM. drop-down menu for a choice list.