简体   繁体   中英

How can I "visualize" 3D image stored (h5py) .h5 format in python?

I want to visualize 3D image stored in .h5 format. I would like to know how can I to it in python. For input , I have file name as '***.h5'

Load the file in python like:

import h5py
filename = 'file.hdf5'
f = h5py.File(filename, 'r')

And then check it's type. If it's a numpy array you can use OpenCV or Pillow. If it's not, just make a numpy array from it with f = np.array(f) .

OpenCV:

cv.imshow('text', f)
cv.waitKey(0)
cv.destroyAllWindows()

Pillow:

Image.fromarray(f).show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM