trim_nonpercolating_paths
#
trim_nonpercolating_paths
function is a filter which removes all nonpercolating paths between specified locations.
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import matplotlib.pyplot as plt
ps.visualization.set_mpl_style()
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
def _find_trapped_pores(inv_seq, indices, indptr, outlets): # pragma: no cover
im
#
This function works on both 2D and 3D boolean images of the pore space:
np.random.seed(0)
im = ps.generators.blobs(shape=[500, 500], porosity=0.55, blobiness=1.5)
plt.figure(figsize=[6, 6]);
plt.axis(False);
plt.imshow(im);

inlets
and outlets
#
Inlets and outlets are specified by creating boolean
images the same shape as im
, with True
values indicating which voxels are inlets and outlets, respectively. The function then only keeps paths which connect to both inlets and outlets:
inlets = np.zeros_like(im)
inlets[0, :] = True
outlets = np.zeros_like(im)
outlets[-1, :] = True
x = ps.filters.trim_nonpercolating_paths(im=im, inlets=inlets, outlets=outlets)
fig, ax = plt.subplots(1, 2, figsize=[12, 12]);
ax[0].imshow(x);
ax[0].set_title('Trimmed Nonpercolating Paths', fontdict={'fontsize': 18});
ax[0].axis(False);
ax[1].imshow(x + (im != x)*0.5);
ax[1].set_title('Showing Paths Removed', fontdict={'fontsize': 18});
ax[1].axis(False);
