Skip to content

Instantly share code, notes, and snippets.

@prerakmody
Last active July 2, 2021 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prerakmody/a14e2891170b52ae2639680cc4256644 to your computer and use it in GitHub Desktop.
Save prerakmody/a14e2891170b52ae2639680cc4256644 to your computer and use it in GitHub Desktop.
Quick / Few-line 3D visualization of Organ Volumes
import skimage
import skimage.measure
import plotly.graph_objects as go
voxel_mask = #
verts, faces, _, _ = skimage.measure.marching_cubes(voxel_mask, step_size=1)
fig = go.Figure(data=[go.Mesh3d(x=verts[:,0], y=verts[:,1], z=verts[:,2], i=faces[:,0],j=faces[:,1],k=faces[:,2])])
fig.write_html('tmp.html') # in VS-Code install the "HTML Preview" extension (Analytic Signal Limited)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment