trim_small_clusters

an example for the use of porespy.filters.trim_small_clusters

[1]:
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import skimage
ps.visualization.set_mpl_style()

trim_small_clusters removes clusters from images if they are smaller than the size given as an input.

Create image and variables

[2]:
im = ps.generators.blobs(shape=[500, 500])

fig, ax = plt.subplots(figsize=[7,7]);
ax.imshow(im);

ax.axis(False);
../../../_images/examples_filters_howtos_trim_small_clusters_4_0.png

Apply filter function

[3]:
size=10

x1 = ps.filters.trim_small_clusters(im, size=10)

fig, ax = plt.subplots(figsize=[7,7]);
ax.imshow(x1);

ax.axis(False);
../../../_images/examples_filters_howtos_trim_small_clusters_6_0.png