some tweaks to make code compact
@@ -84,12 +84,11 @@ def extract_pore_network(im, dt=None, voxel_size=1):
filter_mask = spim.convolve(padded_mask*1.0,
weights=ball(1))/sp.sum(ball(1))
verts, faces, norm, val = measure.marching_cubes_lewiner(filter_mask)
- mc_sa[pore] = measure.mesh_surface_area(verts, faces)
else:
padded_mask1 = sp.reshape(pore_im, (1,) + pore_im.shape)
padded_mask1 = sp.pad(padded_mask1, pad_width=1, mode='constant')
verts, faces, norm, val = measure.marching_cubes_lewiner(padded_mask1)
- mc_sa[pore] = 0.5 * measure.mesh_surface_area(verts, faces)
+ mc_sa[pore] = measure.mesh_surface_area(verts, faces)
# ---------------------------------------------------------------------
s_offset = sp.array([i.start for i in s])
p_label[pore] = i
@@ -129,11 +128,6 @@ def extract_pore_network(im, dt=None, voxel_size=1):
constant_values=0)
jfilter = spim.convolve(j_mask,
weights=ball(1))/sp.sum(ball(1))
- verts1, face1, n1, v1 = measure.marching_cubes_lewiner(mfilter)
- mc_sa_combined = measure.mesh_surface_area(verts1, face1)
- verts2, face2, n2, v2 = measure.marching_cubes_lewiner(jfilter)
- mc_sa_j = measure.mesh_surface_area(verts2, face2)
- mc_area = 0.5 * (mc_sa_j + mc_sa[pore] - mc_sa_combined)
else:
merged_region = sp.reshape(merged_region,
(1,) + merged_region.shape)
@@ -144,9 +138,9 @@ def extract_pore_network(im, dt=None, voxel_size=1):
jfilter = sp.pad(j_mask*1.0, pad_width=1,
mode='constant', constant_values=0)
verts1, face1, n1, v1 = measure.marching_cubes_lewiner(mfilter)
- mc_sa_combined = 0.5 * measure.mesh_surface_area(verts1, face1)
+ mc_sa_combined = measure.mesh_surface_area(verts1, face1)
verts2, face2, n2, v2 = measure.marching_cubes_lewiner(jfilter)
- mc_sa_j = 0.5 * measure.mesh_surface_area(verts2, face2)
+ mc_sa_j = measure.mesh_surface_area(verts2, face2)
mc_area = 0.5 * (mc_sa_j + mc_sa[pore] - mc_sa_combined)
if mc_area < 0:
