trim_disconnected_blobs

Import packages

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

np.random.seed(0)
ps.visualization.set_mpl_style()

Create image and variables

[2]:
im = np.zeros([100, 100])
im = ps.generators.RSA(im, r=9, clearance=1)

plt.figure(figsize=[4, 4])
plt.imshow(im);
plt.axis(False)
[2]:
(-0.5, 99.5, 99.5, -0.5)
../../../_images/examples_filters_howtos_trim_disconnected_blobs_4_1.svg

Apply filter function

inlets

[3]:
inlets = ps.tools.get_border(shape=im.shape, mode='faces')
x = ps.filters.trim_disconnected_blobs(im=im, inlets=inlets)

fig, ax = plt.subplots(1, 3, figsize=[8, 4])
ax[0].imshow(im)
ax[0].axis(False)
ax[0].set_title('inlets')

ax[1].imshow(inlets + im)
ax[1].axis(False)
ax[1].set_title('inlets')

ax[2].imshow(x)
ax[2].axis(False)
ax[2].set_title('trimmed blobs');
../../../_images/examples_filters_howtos_trim_disconnected_blobs_7_0.svg