'Estimating the Hausdorff dimension (fractal dimension) of images in Python

I transformed a time-series into phase space using Python via the following code.

import numpy as np
import matplotlib.pyplot as plt

Subjects = ["Subject1"]

for Subject in Subjects:
    Data = np.loadtxt("/path-to-file")
    
    Colormap = plt.get_cmap("tab20_r")
    Segment_Colormap = Colormap(np.linspace(0, 1, len(Subjects)))

    x_list = Data[:-1]
    y_list = Data[1:]
    
    plt.plot(x_list, y_list, c=Segment_Colormap[Subjects.index(Subject)], linewidth=1.5)

I am interested in the fractalness of the image. In phase space, I would like to estimate the Hausdorff dimension (fractal dimension) of the data’s spatial representation. I would then like to compare the Hausdorff dimension with the data’s topological dimension to judge if the data is fractal (Hausdorff dimension > toplogical dimension) or not (Hausdorff dimension < topological dimension).

To estimate the Hausdorff dimension, I found one Python code here: https://francescoturci.net/2016/03/31/box-counting-in-numpy/

I'm not sure how reliable this code is for all kinds of images, and not just for images that exhibit a clear fractal surface like the shown Sierpinski gasket. The image below shows the result of transforming a time-series into phase space using my code above. The code in the link yields a Hausdorff dimension of 1.9165706952426873 for this image.

My questions are thus:

  1. Is the result of 1.9165706952426873 really appropriate for this image?
  2. Are there other Python codes to estimate the fractalness of images?
  3. I didn't find Python codes to estimate the topological dimension of images in phase space. Do codes for this task exist?

enter image description here

Here are the transformations of two further time-series into phase space. Where is the fractal nature of this phase set? As far as my understanding goes, the phase set shows a nestedness of ever smaller "circles" inside circles. Hence, the trajectories in phase space yield "circles" that are nested into each other. This probably provides a fractral structure.

The first image shows the whole phase set, while the second picture is a zoom in of the former.

However, even the zoom in image only yields a Hausdorff dimension of 1.8521208566544454, while the topological dimension should be 2, is that correct? This would mean that the phase set is fractal.

enter image description here

enter image description here

Finally, this third image shows the phase set of another time-series with a rather low sampling rate.

enter image description here The Hausdorff dimension is 1.9415998549657336. It suprises me that the fractral dimension of this phase set is only slightly higher than the previous one with 1.85, even though the previous one clearly seems fractal, while the third one does not.

I therefore wonder how reliable the code is, or if I interpret the results wrong.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source