H5IM: HDF5 Image APIs provide a standard object interface for working with images. These APIs follow the HDF5 Image and Palette Specification.
These APIS are in the HDF5 High Level library. See the HDF5 Image API Reference for how to use these APIs.
The HDF5 Image (H5IM) Tutorial contains example programs for creating HDF5 image datasets.
There are two ways to store true color images - pixel vs. plane With both you will have a 3D dataset. With pixel interlace mode, it will be stored like this: [height][width][pixel_components]
For plane interlace the data will be store as: [pixel components][height][width]
Refer to the Image and Palette Specification for further details.
The Image and Palette Specification covers the types of images and palettes supported in HDF5. Currently the two supported types of palette are "STANDARD8" or "RANGEINDEX". (We may add more types into the future.)
You can create your own image palette. An image palette in HDF5 is just another dataset. For example, if you were only interested in values between 50 and 100, you could create a palette such that all values over 100 were white and all values smaller than 50 to be black. Something like this:
index red green blue 0 0 0 0 ... 49 0 0 0 50 whatever color you want ... 100 whatever color you want 102 255 255 255 ... 255 255 255 255
Then add a palette attribute in the image dataset to point to the palette you created. An image can have more than one palettes.
We don't address using bands with the Image Specification. You would have to store each band as a separate image.
Basically, you would save the dataset with a floating point datatype.
See the implementation of the HDF5 High Level function, H5IMmake_image_24bit, in the HDF5 source code. To save an image made from (r,g,b) floating point values, just replace the following call in this function:
if ( H5LTmake_dataset( loc_id, dset_name, rank, dims, H5T_NATIVE_UCHAR, buffer ) < 0 ) return -1;
if ( H5LTmake_dataset( loc_id, dset_name, rank, dims, H5T_NATIVE_FLOAT, buffer ) < 0 ) return -1;
Save the result in another function name (for example, H5IMmake_image_24bit_float).