<jupyter_start><jupyter_text>`boxcount`A method for measuring the fractal dimension of an image<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import porespy as ps<jupyter_output><empty_output><jupyter_text>The arguments and their defaults for this function are:<jupyter_code>import inspect
inspect.signature(ps.metrics.boxcount)
im = ps.generators.sierpinski_foam(dmin=5, n=5, ndim=2)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(im, interpolation='none', origin='lower')
ax.axis(False);<jupyter_output><empty_output><jupyter_text>`im`The image which is to be analzyed.  Can be 2D or 3D.<jupyter_code>b = ps.metrics.boxcount(im=im)
print(b)<jupyter_output><empty_output><jupyter_text>The returned object is like a dataclass with each computed value stored in an attribute.  The result can be printed for inspection.  The results can also be plotted as follows:<jupyter_code>fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].loglog(b.size, b.count)
ax[0].set_xlabel('box length')
ax[0].set_ylabel('number of partially filled boxes')

ax[1].semilogx(b.size, b.slope)
ax[1].plot([0, 1000], [1.9, 1.9])
ax[1].set_xlabel('box length')
ax[1].set_ylabel('slope')
ax[1].set_ylim([0, 3]);<jupyter_output><empty_output><jupyter_text>`bins`The box sizes to use. The default is 10. If an integer is given it computes the range of box sizes.  If an array is given, these are used directly<jupyter_code>b = ps.metrics.boxcount(im=im, bins=20)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].loglog(b.size, b.count)
ax[0].set_xlabel('box length')
ax[0].set_ylabel('number of partially filled boxes')

ax[1].semilogx(b.size, b.slope)
ax[1].plot([0, 1000], [1.9, 1.9])
ax[1].set_xlabel('box length')
ax[1].set_ylabel('slope')
ax[1].set_ylim([0, 3]);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1514476614699332, 'fraction_numerical': 0.03396436525612472, 'mean_word_length': 6.779220779220779, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '324366', 'license': 'MIT', 'n_tokens_mistral': 734, 'n_tokens_neox': 700, 'n_words': 169, 'path': 'examples/metrics/reference/boxcount.ipynb', 'repo_name': 'xu-kai-xu/porespy', 'size': '1796'}