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
[17:46:05] ERROR    PARDISO solver not installed, run `pip install pypardiso`. Otherwise,          _workspace.py:56
                    simulations will be slow. Apple M chips not supported.                                         
np.random.seed(7)
im = ~ps.generators.overlapping_spheres([100, 100], r=10, porosity=0.6)
plt.imshow(im, origin='lower', interpolation='none');
../../../_images/b3ee499bebb31bd997fd84dae4458747ec61ab557a16356d8b13dcaeba9de491.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)
plt.imshow(regions, origin='lower', interpolation='none');
../../../_images/2b2ca8100c5e0426d6e2844d397fcb8643093dc08662c76d73b1390cdd09d203.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/80c0f75737f01e22d3211c67def8eed6cd0e38f9bc48644b455e955e7c1a644a.png