我有一个带空腔的器官的 3D 几何形状。它位于 3D numpy 数组中,但可以转换为 STL。我的任务是计算它的 3D 壁厚。我尝试以 2D 方式进行,然后以 3D 方式考虑。但我想知道有没有办法在3D中做到这一点?
您是否正在寻找这种解决方案:
import numpy as np
from scipy.ndimage import distance_transform_edt
from skimage import measure
# Assuming 'organ_array' is your 3D numpy array representing the organ geometry
# Step 1: Extract surface mesh
verts, faces, _, _ = measure.marching_cubes(organ_array, level=0)
# Step 2: Compute distance transform
distance_map = distance_transform_edt(organ_array)
# Step 3: Calculate thickness
thickness_values = []
for vertex in verts:
x, y, z = np.round(vertex).astype(int)
thickness = distance_map[x, y, z]
thickness_values.append(thickness)
# Step 4: Visualize thickness
# You can use a plotting library like Matplotlib or Mayavi to visualize the thickness