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

ps.visualization.set_mpl_style()
im = ~ps.generators.overlapping_spheres([100, 100], r=10, porosity=0.6, seed=7)

fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(im, origin="lower", interpolation="none")
ax.axis(False);
../../../_images/526b96382259ca01ad71b8c79e6f2d67d189c40ab5378d53cb8fb9fe5eb8c152.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)

fig, ax = plt.subplots(figsize=[4, 4])
ax.imshow(regions, origin="lower", interpolation="none")
ax.axis(False);
../../../_images/a06cc09418fe548c0fca16a309d9b8171b2fafecdcd63747e2457197705f95b7.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=[14, 4])
ax[0].imshow(im1, origin="lower", interpolation="none")
ax[0].axis(False)
ax[1].imshow(im2, origin="lower", interpolation="none")
ax[1].axis(False)
ax[2].imshow(im3, origin="lower", interpolation="none")
ax[2].axis(False);
../../../_images/b61848831c4e3fc9ac7e4d8fcd44eafeb1b6e3780afe2815eb01a933b76ae1ff.png