[Top] [Prev] [Next]

6.2 The 8-Bit Raster Data Model

The data model for the 8-bit raster image set, or RIS8, an acronym for "Raster Image Set, 8-bit", supports three types of objects; two-dimensional 8-bit raster images, dimensions and palettes. The latter two items occur once per RIS8. The following figure shows the contents of an 8-bit raster image set.

FIGURE 6a - 8-Bit Raster Image Set Contents

6.2.1 Required 8-Bit Raster Image Data Set Objects

Every RIS8 object requires an image and dimension object. Required objects are created by the HDF library using information provided at the time the image is written.

6.2.1.1 8-Bit Raster Image Data Representation

An 8-bit raster image is a two-dimensional array of 8-bit numbers which represent pixels or "picture elements".The first row of pixels corresponds to the top row of the image, the second row of pixels to the second row of the image and so forth. Pixel values range from 0 to 255, and indicate to the hardware which colors to use when mapping the corresponding pixels to the screen display. A color lookup table, or palette, provides the means of correlating pixel values to colors.

As an example, consider a stream of 8-bit numbers representing a raster image. (See Figure 6b.) When the image is displayed, the color associated with the first number in the data stream is placed in the upper left corner of the image. The remainder of the first line is then painted from left-to-right using as many values from the data stream as is necessary to complete the line. The remainder of the rows are similarly painted from left-to-right and top-to-bottom until every value in the data stream appears is represented by one pixel in the image.

FIGURE 6b - The Data Representation of an 8-Bit Raster Image

6.2.1.2 8-Bit Raster Image Dimension

The dimensions of an image are its height and width in pixels.

6.2.2 Optional 8-Bit Raster Image Data Set Objects

6.2.2.1 Palettes

A palette is a lookup table consisting of 256 unique numerical values, each of which map to the 256 possible pixel color values and is stored in a RIS8 object. For more details on HDF palettes refer to Chapter 9, titled Palettes (DFP API).

6.2.3 Compression Method

The compression method indicates if and how the image is compressed. It can be, at the programmer's option, explicitly set or left as its default setting of no compression. Compression schemes supported by HDF version 4.0 are run-length encoding or RLE, joint photographic expert group compression, or JPEG, and image compression, or IMCOMP . The list of compression methods is presented below. (See Table 6A.) The HDF tags COMP_RLE, COMP_IMCOMP and COMP_JPEG are respectively defined as the values 11, 12 and 2 in the "hcomp.h" header file.

TABLE 6A - 8-Bit Raster Image Compression Method List

Compression Method
Type
Compression Code
Requirements
None

N/A

COMP_NONE

Image data only (default setting).

RLE

Lossless

COMP_RLE

Image data only.

JPEG

Lossy

COMP_JPEG

Image data, quality factor and compatibility factor.

IMCOMP

Lossy

COMP_IMCOMP

Image data and palette.

RLE Compression

The RLE method is a lossless compression method recommended for images where data retention is critical. The RLE algorithm compresses images by condensing strings of identical pixel values into two bytes. The first byte identifies the number of pixels in the string and the second byte records the pixel value for the string.

The amount of space saved by RLE depends upon how much repetition there is among adjacent pixels. If there is a great deal of repetition, more space is saved and if there is little repetition, the savings can be very small. In the worst case when every pixel is different from the one that precedes it an extra byte is added for every 127 bytes in the image.

JPEG Compression

The JPEG, or Joint Photographic Expert Group, compression method is a lossy compression algorithm whose use is recommended for photographic or scanned images. Using JPEG compression to reduce the size of an image changes the values of the pixels and hence may alter the meaning of the corresponding data. Version 5.0 of the JPEG library is available in HDF version 4.0.

JPEG compression requires two parameters, the first the level of image quality and the second, compatibility. The quality factor determines how much of the data will be lost and thus directly impacts the size of the compressed image. A quality factor of 1 specifies the lowest quality or maximum image compression. A quality factor of 100 specifies the highest quality or minimum image compression. Note that all images compressed using the JPEG algorithm are stored in a lossy manner, even those stored with a quality factor of 100. Usually, it is best to experiment with the quality factor to find the most acceptable one.

The baseline parameter determines whether the contents of the quantization tables used during compression are forced into the range of 0 to 255. The baseline parameter is normally set to the value 1 which forces baseline results. You should set the value of the baseline parameter to values other than 1 only if you are familiar with the JPEG algorithm.

IMCOMP Compression

IMCOMP is a lossy compression method available in earlier versions of HDF. IMCOMP compression is generally of inferior quality to JPEG compression and is not recommended unless your images will be viewed on a 16-color monitor. For backward compatibility, IMCOMP compression is supported in the HDF library. For details on IMCOMP refer to Appendix F, titled Backward Compatibility Issues.



[Top] [Prev] [Next]

hdfhelp@ncsa.uiuc.edu
HDF User's Guide - 07/21/98, NCSA HDF Development Group.