Akshay Paranjape
Akshay Paranjape

Reputation: 21

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'

Upvotes: 1

Views: 2051

Answers (1)

Novak
Novak

Reputation: 2171

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

Upvotes: 3

Related Questions