numpy_imread.py 521 B

12345678910111213141516171819202122232425
  1. """Create a Volume
  2. from a numpy object using imread"""
  3. from vedo import *
  4. from skimage.io import imread
  5. f = dataurl+'embryo.tif'
  6. voriginal = Volume(f)
  7. printc('voxel size is', voriginal.spacing(), c='cyan')
  8. raw = imread(f)
  9. narray = np.transpose(raw, axes=[2, 1, 0])
  10. vraw = Volume(narray, spacing=(104,104,104))
  11. # Compare loading the volume directly with the numpy volume:
  12. # they should be the same
  13. show(
  14. [(voriginal, __doc__),
  15. (vraw,"From imread\n(should be same as left)")],
  16. N=2,
  17. axes=1,
  18. ).close()