regionprops_3D#

This is similar to the regionprops in scikit-image but has some extra features that are relevant to 3D images. Note that the scikit-image version has been adding 3D capabilities, make the PoreSpy version less useful.

import porespy as ps
import numpy as np
import matplotlib.pyplot as plt
import scipy.ndimage as spim
im = ps.generators.rsa([80, 80, 80], r=10, clearance=3)
plt.imshow(im[20, ...], origin='lower', interpolation='none');
../../../_images/6c2c61f2133cb0c54c77760f0bf1ef182d752a9d096f0353d6d63d7c7ced6a61.png

We need to label each sphere so they are recognized as individual regions:

regions = spim.label(im)[0]
plt.imshow(regions[20, ...], origin='lower', interpolation='none');
../../../_images/524b1594a24c16aa3db7f596261656fd4c1cf593ed0ed35c5a1e854ea96de3f6.png
props = ps.metrics.regionprops_3D(regions)

props is a list of RegionProperties objects, subclassed from scikit-image. Each RegionProperties object possess the properties as attributes. Note that these are calculated on demand, so the regionsprops_3D function appears very quick, but the work has not yet been done.

props
[<porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170a50d0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc116cf8730>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc116cf8a00>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc15c1fd310>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1189c4f40>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc116c8d940>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc116c8d130>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc117094190>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170942b0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc117094280>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc117094220>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170945e0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170946a0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc117094730>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc117094640>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170942e0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170941c0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170940d0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170943a0>,
 <porespy.metrics._regionprops.RegionPropertiesPS at 0x7fc1170a5b50>]

The properties of regions 1 are on the RegionsProperties object located at position 0 in the props list:

for d in dir(props[0]):
    if not d.startswith('_'):
        print(d)
area
area_bbox
area_convex
area_filled
axis_major_length
axis_minor_length
bbox
bbox_volume
border
centroid
centroid_local
centroid_weighted
centroid_weighted_local
convex_volume
coords
dt
eccentricity
equivalent_diameter_area
euler_number
extent
feret_diameter_max
image
image_convex
image_filled
image_intensity
inertia_tensor
inertia_tensor_eigvals
inscribed_sphere
intensity_max
intensity_mean
intensity_min
label
mask
moments
moments_central
moments_hu
moments_normalized
moments_weighted
moments_weighted_central
moments_weighted_hu
moments_weighted_normalized
orientation
perimeter
perimeter_crofton
skeleton
slice
slices
solidity
sphericity
surface_area
surface_mesh_simplices
surface_mesh_vertices
volume

Let’s check a few of the properties:

print(props[0].volume)
4139

Because the present function is meant for 3D images, we have added specific terminology, like volume, instead of allowing area to mean volume like the scikit-image version”

print(props[0].area)
4139

We do have a surface_area, which is also specific to 3D objects:

print(props[0].surface_area)
1165.306396484375

In addition to scalar metrics, we also provide access to useful images of the region:

plt.imshow(props[0].dt[5, ...]);
../../../_images/5a5d507e20ebda575baebe445e1579e9aec555a5e57dc26dc6b455d4b6beb62b.png