boxcount

boxcount(im, bins=10, d_min=1, d_max=None)[source]

Calculates fractal dimension of an image using the tiled box counting method [1]_

Parameters
  • im (ndarray) – The image of the porous material.

  • bins (int or array_like, optional) – The number of box sizes to use. The default is 10 sizes logarithmically spaced between 1 and min(im.shape). If an array is provided, this is used directly.

Returns

An object possessing the following attributes:

sizendarray

The box sizes used

countndarray

The number of boxes of each size that contain both solid and void

slopendarray

The gradient of count. This has the same number of elements as count and

Return type

results

References

[1] See Boxcounting on Wikipedia

Examples

>>> import porespy as ps
>>> import matplotlib.pyplot as plt
>>> dust = ps.generators.random_cantor_dust([1024, 1024], n=8)
>>> f = ps.metrics.boxcount(dust)
>>> fig, ax = plt.subplots(1, 2)
>>> ax[0].loglog(f.size, f.count, 'bo-')
>>> ax[1].semilogx(f.size, f.slope, 'ro-')
>>> ax[1].set_ylim([0, 4])