mesh_volume#

Calculates the volume of a single region by meshing it. This method works by applying Trimesh on the region to mesh the region using marching cube algorithm and calculate the volume of the meshed region.

import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import inspect
inspect.signature(ps.metrics.mesh_volume)
<Signature (region)>

regions#

The input image with a single region labelled as True or any value>0. The image can be 3D or 2D. For visualization purpose, we create a 2D test image:

np.random.seed(10)
im = ps.generators.blobs(shape=[50,50])
snow = ps.filters.snow_partitioning(im)
regions = snow.regions
region = regions == 10
volume = ps.metrics.mesh_volume(region)
print('volume is=', volume)
fig, ax = plt.subplots(1, 1, figsize=[6, 6])
ax.imshow(region, origin='lower', interpolation='none')
ax.axis(False);
volume is= 36.416666666666664
../../../_images/c67edb0412fa7757a9b6f07254a9cf3b1ec51207d777ffdf35c57e0f5ecc481e.png