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
[01:04: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/b6fac067f5a227fd5f6201c8e9c4d640d8d90e8dd9c4ebae190ff9bbdde66207.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)
plt.imshow(regions, origin='lower', interpolation='none');
../../../_images/651c489520522bcd5fa197967c5a0f9a70ce4f2020bdc13ffee8a1a4996e70c6.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/5049b52a3ab8ac8a9924e6448fbf2b64aff31c1749188889e051c4ff3e5b9396.png