Fractal Dimension
Fractals are geometric features in which structures are similar when viewed at small localized regions, or the entirety of the structure itself. Fractals are said to be naturally occurring in nature, which is the motivation of applying concepts of fractals in modelling physical systems.
One way to look at fractals is by their fractal dimension, given by \(D = \lim_{\epsilon \to 0} \dfrac{\log{N}}{\log{1/\epsilon}},\) where $N$ is the number of boxes that contains the structure, and $\epsilon$ is the size of the box. As such, this method is called the box counting method. This is useful for looking at the fractal dimensionality of two dimensional images.
Suppose we want to look at the fractal dimension of this image:
In [1]:
<matplotlib.image.AxesImage at 0x6d2ecf8>
The following lines of code will count the number of blocks containing the structure $N$ for a given input of $\epsilon$.
In [2]:
We will then plot $\log{N}$ with $\log{1/\epsilon}$ and if the slope of the resulting plot, representing $D$ appoaches some finite value.
In [3]:
<matplotlib.text.Text at 0x6f50ba8>
Getting the fractal dimension
From the definition of the fractal dimension, we can see that it is simply the slope of $\log{N}$ vs $\log{1/\epsilon}$ for large values of $1/\epsilon$. To obtain this, it is best to fit a line at the end of the plot. In this case, we will fit a line to the last 50 points, the slope of which is our fractal dimension.
In [4]:
D = 1.93467964091
Hence, the fractal dimension of the image is $D=1.935$.