props_to_DataFrame#

Extracts the scalar values from a regionprops_3D query and uses them to populate a pandas DataFrame.

import porespy as ps
import numpy as np
import matplotlib.pyplot as plt
import scipy.ndimage as spim
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/openpnm/algorithms/_invasion_percolation.py:358: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
  def _find_trapped_pores(inv_seq, indices, indptr, outlets):  # pragma: no cover
np.random.seed(7)
im = ~ps.generators.overlapping_spheres([100, 100], r=10, porosity=0.6)
plt.imshow(im, origin='lower', interpolation='none');
../../../_images/d89e18ddaeb7598ccdfd0646517dbf1ad7b1fb4e9cc6f4430636ea8d6151fc7c.png
regions = spim.label(im)[0]
props = ps.metrics.regionprops_3D(regions)
plt.imshow(regions, origin='lower', interpolation='none');
../../../_images/519f3cd5dfc4e1b7622689a656614ea7766c923679bb613fa7cea144def44136.png
df = ps.metrics.props_to_DataFrame(props)
df
label volume bbox_volume sphericity surface_area convex_volume num_pixels area area_bbox area_convex ... euler_number extent feret_diameter_max area_filled axis_major_length axis_minor_length orientation perimeter perimeter_crofton solidity
0 1 270.0 304 3.377624 59.811131 274.0 270 270.0 304.0 274.0 ... 1 0.888158 20.615528 270.0 20.302892 17.144166 1.570796 58.970563 58.589116 0.985401
1 2 292.0 352 2.966109 71.760513 301.0 292 292.0 352.0 301.0 ... 1 0.829545 24.186773 292.0 22.792054 16.944133 -1.332241 64.384776 63.722113 0.970100
2 3 305.0 361 2.578463 84.981247 313.0 305 305.0 361.0 313.0 ... 1 0.844875 20.808652 305.0 19.710694 19.710694 -0.785398 62.627417 62.056032 0.974441
3 4 701.0 952 1.939290 196.782654 747.0 701 701.0 952.0 747.0 ... 1 0.736345 35.440090 701.0 34.990789 26.707805 1.291699 105.840620 103.024717 0.938420
4 5 1237.0 2205 1.255313 443.927490 1665.0 1237 1237.0 2205.0 1665.0 ... 1 0.560998 63.788714 1237.0 70.153363 29.934308 1.478716 202.539105 195.878727 0.742943
5 6 255.0 285 3.677297 52.882927 259.0 255 255.0 285.0 259.0 ... 1 0.894737 20.615528 255.0 20.466711 16.191807 0.000000 58.142136 57.803718 0.984556
6 7 641.0 945 1.932482 186.040405 762.0 641 641.0 945.0 762.0 ... 1 0.678307 47.434165 641.0 52.035208 18.629564 -1.383012 124.526912 120.740433 0.841207

7 rows × 22 columns