# 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.

[1]:

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

[1]:

<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:

[2]:

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