read_volume2.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. """Load and render a 3D Volume
  2. mode=0, composite rendering
  3. mode=1, maximum-projection rendering"""
  4. from vedo import dataurl, Volume, show
  5. vol1 = Volume(dataurl+"vase.vti")
  6. # can set colors and transparencies along the scalar range
  7. # from minimum to maximum value. In this example voxels with
  8. # the smallest value will be completely transparent (and white)
  9. # while voxels with highest value of the scalar will get alpha=0.8
  10. # and color will be=(0,0,1)
  11. vol1.color(["white", "fuchsia", "dg", (0,0,1)])
  12. #vol1.color('jet') # a matplotlib colormap name is also accepted
  13. vol1.alpha([0.0, 0.2, 0.3, 0.8])
  14. # a transparency for the GRADIENT of the scalar can also be set:
  15. # in this case when the scalar is ~constant the gradient is ~zero
  16. # and the voxel are made transparent:
  17. vol1.alpha_gradient([0.0, 0.5, 0.9])
  18. vol1.add_scalarbar3d('composite shade')
  19. vol1.scalarbar = vol1.scalarbar.clone2d("center-right", size=0.2)
  20. # mode = 1 is maximum-projection volume rendering
  21. vol2 = Volume(dataurl+"vase.vti").mode(1)
  22. vol2.add_scalarbar3d('maximum-projection')
  23. vol2.scalarbar = vol2.scalarbar.clone2d("center-right", size=0.2)
  24. # show command creates and returns an instance of class Plotter
  25. show([[vol1, __doc__], vol2], N=2, axes=1).close()