nphase_border
#
Computes the number of phases that border on each pixel.
import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
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
The arguments and their defaults are:
import inspect
inspect.signature(ps.filters.nphase_border)
<Signature (im, include_diagonals=False)>
im
#
This function works on both 2D and 3D images. If an im
matrix = ps.generators.blobs([200, 200])
inclusions = ps.generators.rsa(~matrix, r=5, return_spheres=True, clearance=3)
bd = ps.filters.nphase_border(matrix*1.0 + inclusions*1.0)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(matrix*1.0 + inclusions*1.0, origin='lower', interpolation='none')
ax[0].axis(False)
ax[1].imshow(bd, origin='lower', interpolation='none')
ax[1].axis(False);
/tmp/ipykernel_3368/2381005276.py:2: DeprecationWarning: Call to deprecated function (or staticmethod) rsa. (This function will be renamed random_spheres in a future version)
inclusions = ps.generators.rsa(~matrix, r=5, return_spheres=True, clearance=3)

np.unique(bd)
array([1., 2., 3.])
The unique values in bd
are 1, 2 and 3 indicating that some pixels border on 1 phase (internal pixels), 2 phases (edges) or 3 phases (corners where void, matrix and inclusion meet). Including diagonals results in a thicker border since more voxels are found that lie on an edge.
include_diagonals
#
Controls that neighbor of the search.
bd1 = ps.filters.nphase_border(matrix*1.0 + inclusions*1.0, include_diagonals=False)
bd2 = ps.filters.nphase_border(matrix*1.0 + inclusions*1.0, include_diagonals=True)
fig, ax = plt.subplots(1, 2, figsize=[12, 6])
ax[0].imshow(bd1, origin='lower', interpolation='none')
ax[0].axis(False)
ax[1].imshow(bd2, origin='lower', interpolation='none')
ax[1].axis(False);
