props_to_image#

Values from the regionprops_3D function can be mapped back onto the original image.

import porespy as ps
import numpy as np
import matplotlib.pyplot as plt
import scipy.ndimage as spim
/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
np.random.seed(7)
im = ~ps.generators.overlapping_spheres([100, 100], r=10, porosity=0.6)
plt.imshow(im, origin='lower', interpolation='none');
../../../_images/d89e18ddaeb7598ccdfd0646517dbf1ad7b1fb4e9cc6f4430636ea8d6151fc7c.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)
plt.imshow(regions, origin='lower', interpolation='none');
../../../_images/519f3cd5dfc4e1b7622689a656614ea7766c923679bb613fa7cea144def44136.png
im1 = ps.metrics.prop_to_image(props, im.shape, 'convex_volume')
im2 = ps.metrics.prop_to_image(props, im.shape, 'sphericity')
im3 = ps.metrics.prop_to_image(props, im.shape, 'orientation')

fig, ax = plt.subplots(1, 3, figsize=[15, 5])
ax[0].imshow(im1, origin='lower', interpolation='none')
ax[1].imshow(im2, origin='lower', interpolation='none')
ax[2].imshow(im3, origin='lower', interpolation='none');
../../../_images/e1770112e4b6fc7effb25133cc1c1e4427e08a79ffb3642990c8b6586d5d0325.png