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
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 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.