mesh_surface_area

Import packages

[1]:
import matplotlib.pyplot as plt
import numpy as np
import porespy as ps
import skimage

ps.visualization.set_mpl_style()
np.random.seed(10)

Genearate image for testing

[2]:
im = ps.generators.blobs(shape=[80, 80, 50])
fig, ax = plt.subplots()
ax.imshow(im[:, :, 40], origin="lower");
../../../_images/examples_metrics_howtos_mesh_surface_area_4_0.svg

Apply metric function

Output is the surface area of the mesh.

mesh

[3]:
mesh1 = ps.tools.mesh_region(region=im)
ps.metrics.mesh_surface_area(mesh=mesh1)
[3]:
90134.1015625

verts and faces

[4]:
mesh1 = ps.tools.mesh_region(region=im)
verts, faces, normals, values = skimage.measure.marching_cubes(im)
ps.metrics.mesh_surface_area(mesh=mesh1, verts=verts, faces=faces)
[4]:
90134.1015625