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

1.7k Views Asked by At

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'

1

There are 1 best solutions below

0
On

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()