Computes the porosity profile along the given axis of an image.

import porespy as ps
import numpy as np
import matplotlib.pyplot as plt
/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 porosity is computed by summing the voxels with a value of 1. This means that in a boolean image the void space is indicated by True. If the image is multiphase (i.e. voxel values of 1, 2, …) then only the 1’s will be counted.

im = ps.generators.overlapping_spheres(shape=[50, 50, 50], r=5, porosity=0.65)
prf = ps.metrics.porosity_profile(im)
plt.plot(prf, 'b.-')
plt.plot([0, 50], [0.65, 0.65], 'r--')
plt.ylim([0, 1]);


The axis along which to compute the profile. The default is axis=0.

prf0 = ps.metrics.porosity_profile(im, axis=0)
prf1 = ps.metrics.porosity_profile(im, axis=1)
prf2 = ps.metrics.porosity_profile(im, axis=2)
plt.plot(prf0, 'b.-')
plt.plot(prf1, 'g.-')
plt.plot(prf2, 'c.-')
plt.plot([0, 50], [0.65, 0.65], 'r--')
plt.ylim([0, 1]);