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
np.random.seed(7)
im = ~ps.generators.overlapping_spheres([100, 100], r=10, porosity=0.6)
plt.imshow(im, origin='lower', interpolation='none');
../../../_images/43470007c54e46d76bb10bea959a93d0f2886610c01f0be1d9e13f658f964920.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)
plt.imshow(regions, origin='lower', interpolation='none');
../../../_images/e7a4b2b1c75cd27d6a03926b78a0b28747f87ca03ac5b4146f6a092358451ada.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/5f0eb579023d58c17a9461308f7b4d756a8cfadd3769f7e859de0f68c81b0fac.png