本文整理匯總了Python中skimage.measure.marching_cubes_classic方法的典型用法代碼示例。如果您正苦於以下問題:Python measure.marching_cubes_classic方法的具體用法?Python measure.marching_cubes_classic怎麽用?Python measure.marching_cubes_classic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類skimage.measure
的用法示例。
在下文中一共展示了measure.marching_cubes_classic方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: visualize_voxel_spectral
# 需要導入模塊: from skimage import measure [as 別名]
# 或者: from skimage.measure import marching_cubes_classic [as 別名]
def visualize_voxel_spectral(points, vis_size=128):
"""Function to visualize voxel (spectral)."""
points = np.rint(points)
points = np.swapaxes(points, 0, 2)
fig = p.figure(figsize=(1, 1), dpi=vis_size)
verts, faces = measure.marching_cubes_classic(points, 0, spacing=(0.1, 0.1, 0.1))
ax = fig.add_subplot(111, projection='3d')
ax.plot_trisurf(
verts[:, 0], verts[:, 1], faces, verts[:, 2], cmap='Spectral_r', lw=0.1)
ax.set_axis_off()
fig.tight_layout(pad=0)
fig.canvas.draw()
data = np.fromstring(
fig.canvas.tostring_rgb(), dtype=np.uint8, sep='').reshape(
vis_size, vis_size, 3)
p.close('all')
return data
示例2: plot_3d
# 需要導入模塊: from skimage import measure [as 別名]
# 或者: from skimage.measure import marching_cubes_classic [as 別名]
def plot_3d(image, threshold=-300):
# Position the scan upright,
# so the head of the patient would be at the top facing the camera
p = image.transpose(2, 1, 0)
p = p[:, :, ::-1]
verts, faces = measure.marching_cubes_classic(p, threshold)
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')
# Fancy indexing: `verts[faces]` to generate a collection of triangles
mesh = Poly3DCollection(verts[faces], alpha=0.70)
face_color = [0.45, 0.45, 0.8]
mesh.set_facecolor(face_color)
ax.add_collection3d(mesh)
ax.set_xlim(0, p.shape[0])
ax.set_ylim(0, p.shape[1])
ax.set_zlim(0, p.shape[2])
plt.show()
# plot_3d(pix_resampled, 400)