Read and write blocked image data as single H5 file
H5 object is an adapter that reads and writes blocked image
data as a single chunked HDF5 file.
When writing to disk, if the blocked image has any additional metadata in the
UserData property, then the
H5 object writes the data to
a separate MAT file with the same file name.
The object supports lossless compression. By default, the compression level is set to
1. To use a different compression level, create the object and then
change the compression level using the
GZIPLevel property. You can also
use this property to turn off compression. For example, to use a compression level of
3, use this code.
adapter = images.blocked.H5; adapter.GZIPLevel = 3;
The table lists the support that the
H5 object has for various
adapter = images.blocked.H5 creates an
that reads and writes blocked image data as a single chunked HDF5 file.
GZIPLevel — GZIP compression level
1 (default) | numeric scalar in the range [0, 9]
GZIP compression level, specified as a numeric scalar in the range [0, 9]. This
value controls the level of GZIP (lossless) compression. The value
turns off compression. Higher values attempt to increase the level of compression and
reduce the file size at the cost of higher runtimes.
Save Single Level Image in Single HDF5 File
Create a blocked image.
bim = blockedImage('tumor_091R.tif');
Write blocked image data to a HDF5 file using the blocked image write object function. Specify the
images.blocked.H5 adapter for use by the
write object function.
wa = images.blocked.H5(); wa.GZIPLevel = 5; % Slower, but results in smallest file size write(bim, "tumor1.h5", "Adapter", wa);
Create a blocked image from the HDF5 file you just created. The
blockedImage object automatically picks the appropriate adapter for the data.
bh5 = blockedImage("tumor1.h5"); disp(bh5.Adapter.Extension)
Introduced in R2021a