Graphics Reference
In-Depth Information
17.3.1 Choosing an Image Format
Most digital cameras produce JPEG images; because of this, JPEG has become a
de facto standard that is especially appropriate for natural images containing gray
values or RGB values. On the other hand, the format is lossy, which makes it dif-
ficult to use when comparing images because it is impossible to know whether the
images are really different from each other or whether minor underlying differ-
ences caused the JPEG compression algorithm to make different choices.
When image storage requirements were critical, and scanners and digital cam-
eras were rare, a common format was GIF (Graphics Interchange Format) ,in
which each pixel stored a number from 0 to 255, which was an index into a table
of 256 colors. To create a GIF image, one had to decide which 256 colors to
use, adjust each pixel to be one of these 256 colors, and then build the array of
indices into the table. In images with just a few colors (some corporate logos, dia-
grams produced with simple drawing and painting tools, icons like arrows, etc.),
the GIF format works beautifully; for natural images, it works rather poorly in
general. Because one is only allowed 256 colors, the GIF representation is usually
lossy.
As mentioned above, TIFF images store multiple channels, each with a
description of its contents. For image editing and compositing tools, in which mul-
tiple layers of images are blended or laid atop one another, a TIFF image provides
an ideal representation for intermediate (or final) results.
The PPM format, which you already encountered in Chapter 15, is very closely
related to the organization of image data. In the text-based version of the format,
one gives a “magic code” (namely P3 ), and then the width and height of the image
(a pair of ASCII representations of positive integers w and h ), the maximum color
value (an integer no greater than 65,536), and then 3 wh color values, representing
the red, green, and blue components of the image pixels, in left-to-right, top-to-
bottom order (so the first 3 w numbers represent the colors in the top row of the
image). Each color value must be no greater than the specified maximum color
value, and is stored as an ASCII representation of the value. All values (including
the width and height) are separated by whitespace. There's also a binary version
of the format (with magic code P5 ) in which the pixel data is stored in a binary
representation, and there are also variants for storing grayscale images in text and
binary formats.
One particular advantage of PPM is that the meaning of each pixel is, to a
large degree, specified by the format. To quote the description:
[Pixel values] are proportional to the intensity of the CIE Rec.
709 red, green, and blue in the pixel, adjusted by the CIE Rec.
709 gamma transfer function. (That transfer function specifies a
gamma number of 2.2 and has a linear section for small intensi-
ties). A value of Maxval for all three samples represents CIE D65
white and the most intense color in the color universe of which the
image is part (the color universe is all the colors in all images to
which this image might be compared) [Net09].
The CIE referred to in this description is the standards committee for color
descriptions, discussed in detail in Chapter 28.
In recent years, the Portable Network Graphics or PNG format has become
popular, in part because of patent issues with the GIF format. It is generally more
compact than the naive PPM format, but it is equally easy to use.
 
 
Search WWH ::




Custom Search