read_volume1.py 636 B

12345678910111213141516171819
  1. from vedo import *
  2. from vedo.pyplot import histogram, plot
  3. cmap = 'nipy_spectral'
  4. alpha = np.array([0, 0, 0.05, 0.2, 0.8, 1])
  5. vol = Volume(dataurl+"embryo.slc")
  6. vol.cmap(cmap).alpha(alpha).add_scalarbar3d(c='white')
  7. xvals = np.linspace(*vol.scalar_range(), len(alpha))
  8. fig = histogram(vol, logscale=True, c=cmap, ac='white')
  9. fig+= plot(xvals, alpha*max(fig.frequencies), '--ow', like=fig).z(1)
  10. show([
  11. (vol, Axes(vol, c='w'), f"Original Volume\ncolor map: {cmap}"),
  12. (fig.clone2d("center",1.2), "Voxel scalar histogram\nand opacity transfer function")
  13. ],
  14. N=2, sharecam=False, bg=(82,87,110), zoom=1.1,
  15. ).close()