probe_line2.py 783 B

1234567891011121314151617181920212223242526272829303132
  1. """Probe a Volume with a line and plot the intensity values"""
  2. from vedo import dataurl, Volume, Line, show
  3. from vedo.pyplot import plot
  4. vol = Volume(dataurl + "embryo.slc")
  5. vol.add_scalarbar3d("wild-type mouse embryo", c="k")
  6. vol.scalarbar = vol.scalarbar.clone2d("bottom-right", 0.2)
  7. p1, p2 = (50, 50, 50), (200, 200, 200)
  8. pl = Line(p1, p2, res=100).lw(4)
  9. # Probe the Volume with the line
  10. pl.probe(vol)
  11. # Get the probed values along the line
  12. xvals = pl.points[:, 0]
  13. yvals = pl.pointdata[0]
  14. # Plot the intensity values
  15. fig = plot(
  16. xvals,
  17. yvals,
  18. xtitle=" ",
  19. ytitle="voxel intensity",
  20. aspect=16 / 9,
  21. spline=True,
  22. lc="r", # line color
  23. marker="O", # marker style
  24. )
  25. fig = fig.shift(0, 25, 0).clone2d()
  26. show(vol, pl, fig, __doc__, axes=14).close()