props_to_image#

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

import matplotlib.pyplot as plt
import numpy as np
import scipy.ndimage as spim

import porespy as ps
np.random.seed(7)
im = ~ps.generators.overlapping_spheres([100, 100], r=10, porosity=0.6)
plt.imshow(im, origin='lower', interpolation='none');
../../../_images/8bf196dc0d45edc46345a6025bef9f52f594286612c99be01b190f36116ad7f1.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)
plt.imshow(regions, origin='lower', interpolation='none');
../../../_images/72211124eb20798343d03d725ef56d869fb5098e4b110915a8802bd0c444b1b2.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/5a718371fdd6fe56bfdc5140be343696424a41f3085c04fa559d9f2904265488.png