Sei sulla pagina 1di 20

CSE585/EE555: Digital Image Processing II

Computer Project #3:

Fractal Generation Using Iterated Function Systems

Timothy Hackett, Kenrick Dacumos, Matthew McTaggart

Date: 04/21/2017

A. Objectives

This purpose of this project is to understand how to generate fractal images using
iterated function systems. The objectives of the project are:
• Implement the Algorithm RenderIFS and generate the resulting images for
different number of algorithm iterations
• Observe the change in the resulting images when the affine transformation
probabilities are changed.
B. Methods

Peitgen and Saupe present the Algorithm RenderIFS in The Science of Fractal
Images, which is an extension on iterated function systems. Iterated function
systems, in general, are an iteration on well-defined functions. These functions
provide a transformation that maps one point f(x) ϵ Χ to each point x ϵ Χ. Forward
iterations of f are defined by:
f °(0)(x) = x
f °(1)(x) = f(x)
f °(2)(x) = f( f(x) )
f °(n)(x) = f( f °(n-1)(x) )
In a complete metric space (Χ,d), d can be considered a distance measure metric for
the space Χ when d has the following properties:
d(x,x) = 0, ∀ x ϵ Χ
d(x,y) ≥ 0, ∀ x,y ϵ Χ
d(x,y) = d(y,x), ∀ x,y ϵ Χ
d(x,y) ≤ d(x,z) + d(z,y), ∀ x,y,z ϵ Χ
A transformation f is a contractive transformation on the metric space (Χ,d) if the
distance measure between the output of the transformation of two points is less than
the distance between the two points before the transformation. This can be expressed
as:
d( f(x), f(y)) <= cd(x,y), 0 ≤ c < 1, ∀ x,y ϵ Χ
where c is known as the contractivity factor. A contractive function has exactly one
fixed point (attractor) xf ϵ Χ, which is the value that the iterated function outputs as
the number of iterations approaches infinity.

The Algorithm RenderIFS consists of a set of contractive, affine transformations wi


and set of probabilities pi that each transformation is used. Affine transformations are
those transformations that rotate, translate, and/or scale the input:
The algorithm uses random iterations of the set of transformations to generate a
deterministic image. The resultant image is the attractor of the transformations fi.

“main5.m” implements the Algorithm RenderIFS to generate the image of a fern.


The values for a00, a01, a10, a11, t0, and t1 for the four affine transformations used in the
implementation are listed below in Table 1:
a00 a01 a10 a11 t0 t1
0 0 0 0.16 0 0
0.2 -0.26 0.23 0.22 0 1.6
-0.15 0.28 0.26 0.24 0 0.44
0.85 0.04 -0.04 0.85 0 1.6

Table 1 – Affine transformation parameters

Table 2 lists the three different probability distributions that were tested for the four
functions:
p1 p2 p3 p4
0.2 0.35 0.35 0.1
0.25 0.25 0.25 0.25
0.35 0.2 0.1 0.35

Table 2 – Probability distributions for the four affine transformations described in


Table 1.

After initialization and definitions, “main5.m” chooses a random number based on


the defined probability distribution for that run. The probability distribution defines
which affine transformation will be used on that iteration. The transformation is
applied to the output of the transformation of the previous iteration (the starting point
is (0,0)). Before images of the fern are printed to file at certain iterations, the points
describing the fern are mapped from its transformation window to a 1024x1024
window.
To execute the fern generation, the user should run the “main5.m” script in the
MATLAB directory. Below is the general hierarchy of the flow.

main5.m

plotting

fern100.gif

fern5000.gif

fern10000.gif

fern20000.gif

fern100000.gif

fern500000.gif

fern1000000.gif

fern10000000.gif

fern100000000.gif
C. Results

Figure 1 – Generated fern after 100 iterations using first probability distribution in
Table 2.

Figure 2 – Generated fern after 5000 iterations using first probability distribution in
Table 2.
Figure 3 – Generated fern after 10,000 iterations using first probability distribution in
Table 2.

Figure 4 – Generated fern after 20,000 iterations using first probability distribution in
Table 2.
Figure 5 – Generated fern after 100,000 iterations using first probability distribution
in Table 2.

Figure 6 – Generated fern after 500,000 iterations using first probability distribution
in Table 2.
Figure 7 – Generated fern after 1,000,000 iterations using first probability
distribution in Table 2.

Figure 8 – Generated fern after 10,000,000 iterations using first probability


distribution in Table 2.
Figure 9 – Generated fern after 100,000,000 iterations using first probability
distribution in Table 2.

Figures 1 through 9 show the generated fern after 100 to 100,000,000 iterations of the
Algorithm RenderIFS using the first probability distribution in Table 2. We can see
that it takes many iterations until a fern shape really starts to emerge onto the output
photo---subjectively, this doesn’t occur until 500,000 iterations (Figure 6). By
100,000,000 iterations (Figure 9), the fern branches all start to really be defined and
fill out. This took approximately 5 minutes of execution to iterate 100,000,000 times.
Figure 10 – Generated fern after 100 iterations using second probability distribution
in Table 2.

Figure 11 – Generated fern after 5000 iterations using second probability distribution
in Table 2.
Figure 12 – Generated fern after 10,000 iterations using second probability
distribution in Table 2.

Figure 13 – Generated fern after 20,000 iterations using second probability


distribution in Table 2.
Figure 14 – Generated fern after 100,000 iterations using second probability
distribution in Table 2.

Figure 15 – Generated fern after 500,000 iterations using second probability


distribution in Table 2.
Figure 16 – Generated fern after 1,000,000 iterations using second probability
distribution in Table 2.

Figure 17 – Generated fern after 10,000,000 iterations using second probability


distribution in Table 2.
Figure 18 – Generated fern after 100,000,000 iterations using second probability
distribution in Table 2.

Figures 10 through 18 show the generated fern after 100 to 100,000,000 iterations of
the Algorithm RenderIFS using the second probability distribution (uniform
distribution) in Table 2. The image of the fern using this probability distribution is
more defined and filled in with the same amount of iterations compared to Figures 1
through 9. Specifically, after 100,000,000 iterations, the fern using the uniform
distribution is significantly more filled in and detailed than the first probability
distribution. Using the uniform distribution, the fern shape seemed to emerge with
less iterations (subjectively, starting at 100,000 iterations) than with the first
distribution (starting at 500,000 iterations).
Figure 19 – Generated fern after 100 iterations using third probability distribution in
Table 2.

Figure 20 – Generated fern after 5000 iterations using third probability distribution in
Table 2.
Figure 21 – Generated fern after 10,000 iterations using third probability distribution
in Table 2.

Figure 22 – Generated fern after 20,000 iterations using third probability distribution
in Table 2.
Figure 23 – Generated fern after 100,000 iterations using third probability
distribution in Table 2.

Figure 24 – Generated fern after 500,000 iterations using third probability


distribution in Table 2.
Figure 25 – Generated fern after 1,000,000 iterations using third probability
distribution in Table 2.

Figure 26 – Generated fern after 10,000,000 iterations using third probability


distribution in Table 2.
Figure 27 – Generated fern after 100,000,000 iterations using third probability
distribution in Table 2.

Figures 19 through 27 show the generated fern after 100 to 100,000,000 iterations of
the Algorithm RenderIFS using the third probability distribution (a variation on the
first probability distribution) in Table 2. Comparing to Figures 1 through 9, the
image of the fern is more defined and filled in with the same amount of iterations.
Specifically, after 100,000,000 iterations, the fern using this distribution is
significantly more filled in and detailed than the first distribution. Comparing to
Figures 10 through 18, the fern image seems to be about the same in terms of
definition. The fern shape seemed to emerge with the same number of iterations as
the uniform distribution (subjectively, starting at 100,000 iterations).

D. Conclusions

In this project, the Algorithm RenderIFS was implemented in order to synthetically


generate an image of a fern. To draw the fern, four different iterated functions were
used with a probability describing the usage of each function. It takes a very large
number of iterations (100,000,000+) to generate a detailed image of a fern using the
algorithm, which can take significant computing time. Producing finer details
requires exponentially more iterations. The choice of the probability distribution
plays a role in how fast the detail shows up in the fern image. By choosing a “better”
probability distribution, one can generate the fern image with less iterations. This
project was a great example of the applicability of fractals in images.

Potrebbero piacerti anche