outline additional material for lecture 07 fractals the Sierpinski triangle continuous ... estimating fractal dimensions via box counting ... pops up âeverywhereâ.
Pattern Recognition Prof. Christian Bauckhage
outline additional material for lecture 07 fractals the Sierpinski triangle continuous constructions discrete constructions fractal geometry computing fractal dimensions estimating fractal dimensions via box counting summary
purpose of this additional material
in lecture 07 of our course on pattern recognition, we discussed least squares for linear regression here, we consider a rather nice practical use case for this technique our use case has to do with fractal objects, so, for the sheer fun of it, we first look at (some) fractals and their properties impatient readers may (more or less safely) jump to the final section right away . . .
fractals
fractals
a fractal is an (abstract, mathematical) object that exhibits similar patterns across (all) scales ⇔ zooming in onto a fractal reveals similar structures
a Julia set
examples
examples
perfect fractals
if the replication is exactly the same at every scale (i.e. perfect), the fractal is called self-similar
the Heighway dragon
the Sierpinski triangle
the Sierpinski triangle
the Sierpinski triangle
the Sierpinski triangle is a perfect fractal named in honor of the Polish mathematician / set theorist Waclaw Sierpinski
W. Sierpinski (∗1882, †1969)
observe
an amazing fact about the Sierpinski triangle is that it pops up “everywhere” next, we will have a look at some of the constructions it results from
continuous constructions
removing triangles
1) start with an equilateral triangle ∆ 2) subdivide ∆ into four congruent equilateral triangles and remove the central one 3) repeat step 2) with each of the remaining smaller triangles
...
removing triangles
more formally, consider the recursive process S1 = ∆
Sn+1 = ∆i,1 , ∆i,2 , ∆i,3 = removeCenter ∆i ∆i ∈ Sn and let n → ∞, then the Sierpinski triangle is the set S∞
... S1
S2
S3
S4
S5
S6
shrinking and duplication
1) start with an equilateral triangle ∆ 2) scale width and height of ∆ by 1/2, make three copies, and position the three shrunken triangles so that each touches the other two at a corner 3) repeat step 2) with each of the newly created triangles
...
the Sierpinski arrowhead curve
1) draw a single line segment 2) repeatedly replace each line segment with three shorter segments, forming 120◦ angles at each junction
...
discrete constructions
cellular automata
a binary 1D (or elemental) cellular automaton consists of an infinite sequence of cells in two possible states (0 or 1) a update rule for how to update a cell based on its and its two neighbors’ current states
at (discrete) time ti , all cells are updated simultaneously ti ti+1
...
...
...
...
this update process continues forever
cellular automata
→
→
→
→
→
→
→
→
→
→
→
→
→
→
→
rule 90
→
rule 126
cellular automata
rule 90 in action
rule 126 in action
fractal geometry of the Sierpinski triangle
area of the Sierpinski triangle A1 =
1 2
bh
area of the Sierpinski triangle A1 = A2 =
1 2 3 4
bh A1
area of the Sierpinski triangle bh
A2 =
1 2 3 4
A3 =
3 4
A2 =
A1 =
A1 33 44
A1 =
3 2 4
A1
area of the Sierpinski triangle 1 2 3 4
bh
A3 = .. .
3 4
A2 =
An = .. .
3 4
An−1 =
A1 = A2 =
A1 33 44
A1 =
3 2 4
3 n−1 4
A1
A1
...
area of the Sierpinski triangle
therefore lim An = 0
n→∞
⇔ the Sierpinski triangle looks like a 2D object, but it is not (if it was a 2D object, it would have a measurable area)
(fractal) dimension of the Sierpinski triangle
at the same time, the Sierpinski triangle does not look like a 1D object either
(fractal) dimension of the Sierpinski triangle
at the same time, the Sierpinski triangle does not look like a 1D object either
indeed, its dimension is
D ≈ 1.585
wait, what?
computing fractal dimensions
dimensionality
cubes in various dimensions
1D
2D
3D
question if we shrink each cube by a scale factor 0 < s 6 1, then how many copies n of the shrunken cube do we need to cover the original as well as possible ?
question if we shrink each cube by a scale factor 0 < s 6 1, then how many copies n of the shrunken cube do we need to cover the original as well as possible ?
answer let’s see . . .
the Hausdorff dimension
D=1
D=2
D=3
n=1
n=1
n=1
n=2
n=4
n=8
n=3
n=9
n = 27
s=1
s=
s=
1 2
1 3
the Hausdorff dimension
observe that in any case n=s
−D
D 1 = s
the Hausdorff dimension
observe that in any case n=s
−D
D 1 = s
but this is to say that log n = D log
1 s
the Hausdorff dimension
observe that in any case n=s
−D
D 1 = s
but this is to say that log n = D log ⇔
log n =D log 1s
1 s
the Hausdorff dimension
observe that in any case n=s
−D
D 1 = s
but this is to say that log n = D log log n =D log 1s log n ⇔ − =D log s ⇔
1 s
back to the Sierpinski triangle
excluding s = 1, we find
... s = 12 , n = 3
s = 14 , n = 9
s = 18 , n = 27
therefore D=−
log n = 1.584962501 log s
s=
1 16 , n
= 81
note
since we can compute its Hausdorff dimension analytically, the Sierpinski triangle is indeed a perfect fractal since its dimension 1 < D < 2 is not an integer, it is neither a line- nor a surface-like object
question OK, but what about imperfect fractals ? how do we determine their dimension ?
answer that strongly depends on the problem at hand . . . however, if the problem is to determine the fractal dimension of an object in an image, then a popular standard approach is to use the box counting method
estimating fractal dimensions via box counting
setting
for simplicity, we restrict our discussion to square images whose width and height (in pixels) are an integer power of two for instance w = h = 2L = 512
step 1
apply an appropriate binarization procedure to create a binary image in which foreground pixels are set to 1 and background pixels to 0
→
step 2
specify a set S of scaling factors 0 < si < 1, for instance
1 i ∈ 1, 2, . . . , L − 1 S= 2i
step 2
specify a set S of scaling factors 0 < si < 1, for instance
1 i ∈ 1, 2, . . . , L − 1 S= 2i
for each si ∈ S cover the binary image with boxes of size si w × si h count the number ni of boxes which contain at least one foreground pixel
example
si = 12 , ni = 4
si =
1 16 , ni
= 94
si = 14 , ni = 12
si =
1 32 , ni
= 254
si = 81 , ni = 32
si =
1 64 , ni
= 716
observe
for perfect fractals, we found the relationship D · log
1 = log n s
observe
for perfect fractals, we found the relationship D · log
1 = log n s
for the box counting dimension of a fractal, the above suggests the following model D · log
1 + b = log ni si
observe
for perfect fractals, we found the relationship D · log
1 = log n s
for the box counting dimension of a fractal, the above suggests the following model D · log
1 + b = log ni si
therefore . . .
step 3
plot log ni against log s1i
log n
103
102
101
100
101
log 1s
102
step 3
plot log ni against log s1i
log n
103
fit a line to the data to obtain estimates of D and b
102
101
100
101
log 1s
102
step 3
plot log ni against log s1i
for our running example, we find
log n
103
fit a line to the data to obtain estimates of D and b
102
101
b ≈ 0.38 D ≈ 1.49
100
101
log 1s
102
in other words
given data N 1 log , log ni si i=1 the problem of estimating D is a simple linear regression problem that can of course be tackled using least squares
summary
we now know about
fractals and some of their properties the usefulness of linear regression for computing fractal dimensions
assignment
if you have never worked with digital images before, read C. Bauckhage, NumPy / SciPy Recipes for Image Processing: “Simple” Intensity Transformations, dx.doi.org/10.13140/RG.2.1.4125.3606 C. Bauckhage, NumPy / SciPy Recipes for Image Processing: “ Binary Images and Morphological Operations”, dx.doi.org/10.13140/RG.2.2.16622.00324