slab_vol.py 695 B

1234567891011121314151617181920
  1. """Use slab() to extract a "thick" 2D slice from a 3D volume"""
  2. from vedo import Axes, Volume, Box, dataurl, settings, show
  3. from vedo.pyplot import histogram
  4. settings.default_font = "Calco"
  5. vol = Volume(dataurl + "embryo.tif")
  6. vaxes = Axes(vol, xygrid=False)
  7. slab = vol.slab([45,55], axis='z', operation='mean')
  8. slab.cmap('Set1_r', vmin=10, vmax=80).add_scalarbar("intensity")
  9. # histogram(slab).show().close() # quickly inspect it
  10. bbox = slab.metadata["slab_bounding_box"]
  11. slab.z(-bbox[5] + vol.zbounds()[0]) # move slab to the bottom
  12. # create a box around the slab for reference
  13. slab_box = Box(bbox).wireframe().c("black")
  14. show(__doc__, vol, slab, slab_box, vaxes, axes=14, viewup='z')