Reads an HDF (Hierarchical Data Format) Image file, and outputs a uniform field containing the image data in ARGB format. Other HDF sub-formats cannot be loaded by this module.
module ReadHDFImageField <hdr_dirs="/usr/local/include", c_hdr_files="im.h", link_files="-L/usr/local/lib -lim -lsdsc -ltiff -ljpeg", src_file="r_hdfimg.c"> { omethod+notify_inst+req update( .filename+notify+read+req, .out+write ) = "read_hdf_image"; ReadHDFImageParams &ReadHDFImageParams <NEportLevels={2,1}>; string filename => ReadHDFImageParams.filename; Mesh_Unif+Node_Data out <NEcolor0=255,NEcolor1=65280, NEnumColors=4, NEportLevels={0,2}> { ndim = 2; points => { {0,0}, {(dims[0] - 1),(dims[1] - 1)} }; nspace = 2; nnode_data = 1; node_data { id = 669; // RGB Special Data ID }; };
ReadHDFImageField will read in the specified HDF Image file, via filename, and output a uniform field containing the image data. The HDF Image format supports images with an alpha channel, and the output field contains node data of vector length 4, containg the Alpha, Red, Green and Blue channels.
The HDF format supports other forms of datasets, but only images are supported by this module. The module uses the SDSC Image Tools library to read the HDF Image file, and this and other associated libraries must be present on the system, before this module can be compiled and used.
&ReadHDFImageParams
Reference to the parameter block, which contains a reference to the filename of the HDF Image file. Typically the file will have the extension .hdf.
filename
Reference to the filename of the HDF Image file, via the parameter block.
out
The output field of type Mesh_Unif+Node_Data, containing the (2D) image in ARGB format. Each scanline of the HDF image is read in reverse, so that the image appears in the correct orientation for the default 2D image viewers.
The low-level ReadHDFImageField module is used in the Functional Macro ReadHDFImage, and the User Macro read_hdf_image. Additionally these macros also use the ReadHDFImageParams, as does the ReadHDFImageUI UI Macro.
The example application ReadHDFImageEg is provided, and is a basic application containing a Uviewer2D and an instance of the read_hdf_image user macro. The file "image.hdf" is required for the example to work, and may be downloaded from the same directory as the project archive.
iac_proj/r_hdfimg/rhi_mods.v contains the ReadHDFImageParams parameter block group and the ReadHDFImageField module.
The project uses the SDSC image tool libraries, which are linked to when the project is compiled. The SDSC image tool library can be downloaded from ftp.sdsc.edu/pub/sdsc/graphics/imtools. In there you will find the source code archive, along with information about other required libraries, such as the TIFF and JPEG libraries.
The TIFF library is obtainable from ftp.sgi.com/graphics/tiff, and the JPEG library is obtainable from ftp.uu.net/graphics/jpeg, if you do not already have these installed on your system.
Note: By default, the V code for the module, assumes that it will find the "im.h" include file in /usr/local/include (the default installation area for the above libraries; PC users will have a different default), and similarly that it will find the libraries libim, libsdsc, libtiff and libjpeg in /usr/local/lib. Change the module properties hdr_dirs and link_files to point to the appropriate place. Additionally, on some systems, the SDSC library may already contain the TIFF and JPEG libraries, so the -ltiff and -ljpeg parts of the link_files property may not be required.
Paul G. Lever International AVS Centre Manchester Visualization Centre Manchester Computing University of Manchester Oxford Road Manchester United Kingdom M13 9PL
ReadHDFImageParams, ReadHDFImage, ReadHDFImageUI and read_hdf_image.
Read_Image, ReadHDFSDS.