Is it possible to open hdf5 (.h5) images in MATLAB?

38 views (last 30 days)
I am trying to open a .h5 image in MATLAB but IMREAD does not support this format.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Nov 2009
An image ingestion tool is not available for hdf5 images.
A possible workaround is to use HDF5INFO and HDF5READ functions to query the hdf5 database and extract image data. This can be done by loading the file into the MATLAB workspace with the HDF5INFO function then manually searching for the image data inside the resulting structure. Then query the database for the data with the HDF5READ function. Image data can then been processed or plotted with the IMAGESC function.
%%Read an hdf5 image and plot in MATLAB
%%Load the hdf5 file in MATLAB
info = hdf5info('hdf5_test.h5');
%%Find the addres of the image
% The operation must be done manually and the position inside the structure
% could be variable depending on the structure itself
address_data_1 = info.GroupHierarchy.Groups(3).Datasets(5).Name;
%%Query the database
image1 =hdf5read('hdf5_test.h5',address_data_1);
%%Plot the image
figure
imagesc(image1)

More Answers (0)

Tags

Products


Release

R2008b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!