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'
Asked
Active
Viewed 1,605 times
1
-
A general comment is that it best to try a things yourself and post where you get stuck. First, it will limit answers to things that you are interest in (e.g. you might not be interested in using OpenCV but rather want to use matplotlib). Second, you are likely to get stuck at a similar place as others. This way, your question will thus help others. Third, too open questions are very much opinionated, which is not the aim of the platform. – Tom de Geus Nov 13 '18 at 07:05
1 Answers
3
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()

Novak
- 2,143
- 1
- 12
- 22