<jupyter_start><jupyter_text>`trim_small_clusters```trim_small_clusters`` function is a filter that removes isolated voxels or clusters of a given size or smaller.<jupyter_code>import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage<jupyter_output><empty_output><jupyter_text>`im`This function works on 2D and 3D images.<jupyter_code>im = ps.generators.blobs(shape=[500, 500], blobiness=5, porosity = 0.5)

plt.figure(figsize=[6,6]);
plt.imshow(im);
plt.axis(False);<jupyter_output><empty_output><jupyter_text>`size`The maximum `size` of a cluster to trim is varied trying 10, 100, and 500 voxels.<jupyter_code>x1 = ps.filters.trim_small_clusters(im, size=10)
x2 = ps.filters.trim_small_clusters(im, size=100)
x3 = ps.filters.trim_small_clusters(im, size=500)

fig, ax = plt.subplots(1, 3, figsize=[18, 18]);
ax[0].imshow(x1);
ax[0].axis(False);
ax[0].set_title('size = 10', fontdict={'fontsize': 18});
ax[1].imshow(x2);
ax[1].axis(False);
ax[1].set_title('size = 100', fontdict={'fontsize': 18});
ax[2].imshow(x3);
ax[2].axis(False);
ax[2].set_title('size = 500', fontdict={'fontsize': 18});<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16243654822335024, 'fraction_numerical': 0.05414551607445008, 'mean_word_length': 7.8283582089552235, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '558444', 'license': 'MIT', 'n_tokens_mistral': 505, 'n_tokens_neox': 459, 'n_words': 96, 'path': 'examples/filters/reference/trim_small_clusters.ipynb', 'repo_name': 'xu-kai-xu/porespy', 'size': '1182'}