HELP! * GREY=local Full HTML for

LOCAL foilset Image Format Basics

Given by Nancy J. McCracken at CPS606fall96 on Fall Semester 96. Foils prepared Sept 1996
Abstract * Foil Index for this file

See also color IMAGE
This talk will introduce the topics of graphics files and the various formats.
The main formats discussed are bitmap (PBM, PPM, PGM), GIF, JPEG, and a little on TIFF.
The compression techniques discussed are Run-Length Encoding, Huffman Coding, and Dictionary Systems.
References:
  • John Levine, ³Programming for Graphics Files in C and C++², John Wiley & Sons, 1994.
  • James Murray and William vanRyper, Encyclopedia of Graphics File Formats, Second Edition, O¹Reilly, 1996.

Table of Contents for full HTML of Image Format Basics


1 Image Format Basics
2 Image Format Basics
3 Graphics Data Files
4 Color Models: RGB
5 Color Models: CMY(K)
6 Color Models: Luminence/Chrominance Models - HSV and YUV
7 Color Maps
8 Bitmap File Formats
9 Header Formats
10 Data Compression Techniques
11 Run-Length Encoding
12 Huffman Coding
13 LZW (Lempel-Ziv-Welch) Compression
14 JPEG Compression
15 Graphics File Formats: PBM, PGM, PNM, PPM and the pbmplus programs
16 Graphics File Formats: GIF
17 Graphics File Formats: JPEG
18 Graphics File Formats: TIFF

This table of Contents Abstract



HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 1 Image Format Basics

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
Nancy McCracken, NPAC, 3-234 CST
Syracuse University
111 College Place
Syracuse NY 13244-4100

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 2 Image Format Basics

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
This talk will introduce the topics of graphics files and the various formats.
The main formats discussed are bitmap (PBM, PPM, PGM), GIF, JPEG, and a little on TIFF.
The compression techniques discussed are Run-Length Encoding, Huffman Coding, and Dictionary Systems.
References:
  • John Levine, ³Programming for Graphics Files in C and C++², John Wiley & Sons, 1994.
  • James Murray and William vanRyper, Encyclopedia of Graphics File Formats, Second Edition, O¹Reilly, 1996.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 3 Graphics Data Files

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
Traditionally, graphics files have either been vector or bitmap.
Vector files have represented graphics objects in terms of lines, polygons, and other high-level structures. This kind of representation has also been extended in Scene Description files, used in languages such as VRML. These kinds of files are not covered in this talk.
We will be discussing the various bitmap formats, in which the graphics data is represented by an array of pixels. Each value in the array represents the color of the pixel, either to be shown on a screen, or printed on paper. The pixel depth is the number of bits used to represent each pixel, which determines how many colors can be used in the image.
The pixel arrays can be stored by rows (scan lines), interleaved rows, or by planes based on color components or bits of the color representation:

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 4 Color Models: RGB

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
Each pixel is specified by 3 components, representing the amount of red, green and blue in the pixel.
This model is additive: each color is created by starting with black and adding in the given amounts of red, green and blue. Additive colors are self-luminous, and are used on color monitors.
Component colors are usually given in numbers from 0 to 255, resulting in a total of 24 bits per color.
The absence of all colors is black (0, 0, 0) and the presence of all colors is white (255, 255, 255). Bright red is (255, 0, 0). A darker red is produced by adding less red, such as (127, 0, 0), and a lighter red by adding some of the other colors to make a color closer to white.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 5 Color Models: CMY(K)

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
CMY (Cyan, Magenta, Yellow) is a subtractive color system used by printers and photographers to render colors with ink or emulsion. When illuminated, each of the three colors absorbs its complementary light color. Cyan absorbs red; magenta absorbs green; and yellow absorbs blue. By increasing the amount of yellow ink, for instance, the amount of blue in the image is increased.
The model is subtractive: each color is created by starting with white and subtracting the given amount of cyan, magenta, and yellow.
In real life, the colors are created by mixing inks and true black is difficult to produce by adding all the colors; it turns out a dark brown. For this reason, black is treated as a separate component, the fourth component, K.
Colors may be given as a color triple as in RGB, except that (0, 0, 0) is white and (255, 255, 255) is (theoretically) black. The colors may also be given as percentages of 100.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 6 Color Models: Luminence/Chrominance Models - HSV and YUV

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
Luminence/Chrominance models vary the properties of colors instead of mixing the colors themselves to create colors.
In HSV (Hue, Saturation, Value (sometimes Brightness)), the hue is the actual color, the saturation is the amount of white in the hue (full saturation at 100% has no white), and value is the amount of self-luminescence.
In YUV, or YCrCb, the Y component is the luminance, and Cr and Cb are the color (chrominance) in amounts of redness and blueness.
These models pay more attention to the way that the human eye sees color, namely, that the eye is quite sensitive to changes in brightness, but much less sensitive to changes in color.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 7 Color Maps

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
Instead of storing the actual 24 bit color for each pixel in a file, individual pixels are often stored as index numbers into a color map.
The color map itself gives the 24 bit value for each index.
A typical color map has from 16 to 256 entries, so the number of bits used to store an index is only 4 or 8 bits, compared to the full 24 bits, resulting in significant savings of space in typical size images. (Of course, the color map itself also has to be stored.)
Color maps are almost also used in screen controllers, sometimes called frame buffers, to minimize the memory needed to store the image.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 8 Bitmap File Formats

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
The bitmap file formats always have a header, may also have a footer, color palette, scan-line tables (for the order of the image rows), color correction tables, or an index for multiple images in a file.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 9 Header Formats

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
Typical header format:
The first field should be the unique
id of this type file format
Practical details of reading and
writing files include whether the
file is binary or ascii, whether the
order of bytes within a word is
big-endian or littl-endian

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 10 Data Compression Techniques

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
Symmetric and Asymmetric Compression: asymmetric techniques require substantially more work to either compress or decompress the data. For example, retrieval of stored images would be best served by a compression technique that may be lengthy to compress (once), but is very fast to decompress every time the image is requested.
Adaptive Encoding: depends on the properties of the data.
Lossy and Lossless compression: In a lossless compression, the data is unchanged after compression and decompression. In a lossy compression, the data will be less precise.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 11 Run-Length Encoding

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
Images tend to have large areas that are a solid color, so that there are many pixels in a row with the same value. In Run-Length Encoding, each such set of pixel values are replaced by the run count and the run value.
  • AAAAAAAAAbbbbTTTTTTT becomes 8A3b6T
where the run count is the length of the run - 1.
This scheme is easy to implement and fast to both compress and decompress. It achieves good rates of compression on simple pictures.
It is not as successful on complex pictures, such as color photographs, where there are more gradations of color.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 12 Huffman Coding

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
More sophisticated schemes based on assigning a (variable length) code for different runs that occur in the image. For example, we would assign a short code of 4 bits or less to runs that occur often, and longer codes up to 10 or 11 bits to the less common runs of pixel values.
Named after David Huffman, who established in 1952 how to assign codes given the relative frequency of bytes in a file so that the total coded length was minimized.
Huffman schemes require that a table that assigns runs to codes. Either a fixed table is used, or the table is constructed and stored along with the image.
The CCITT Group 3 for bi-level images used a fixed Huffman scheme and is widely used for FAX transmission. Examples of Group 3 encodings:
20 pixel black run: 0000 1101 000
100 pixel white run: 11011 001 0101
A pixel run can either have a code (called terminating) or be made up of one or more other codes for runs (called makeup).

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 13 LZW (Lempel-Ziv-Welch) Compression

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
LZW is the most commonly used dictionary scheme, and is patented by Welch at Unisys.
It is adaptive and constructs the table while it is compressing (unlike the Huffman schemes, which compute the code table on one scan and compress on the next).
An LZW compressor starts with a dictionary that has one entry for each single pixel value. For example, if the pixels are 8 bits, the original dictionary has 256 entries. Each time it sees a new sequence of inputs, it adds a new entry to the dictionary. If it sees a pattern that has been seen before, it uses a previous entry.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 14 JPEG Compression

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
Capable of compressing continuous-tone image data with a pixel depth of 6 to 24 bits with reasonable speed and efficiency.
Lossy compression, but tries to limit loss to what human eye can¹t see. Good quality images can be reproduced from files compressed at 25:1.
Toolkit of compression methods: parameters can be chosen to vary image quality versus storage size.
Works best on photographs or natural images, not good on single color areas.
Compression scheme:
  • Transform the image into an optimal color space. Convert RGB to YCrCb.
  • Downsample chrominace components. Since the eye is most sensitive to the luminence, keep the Y value for each pixel, but only keep 1/4 of the CrCb components, one average value for every 2x2 pixel block.
  • Apply a Discrete Cosine Transform to 8 by 8 blocks, separating high and low-frequency information. This is the most time-consuming part of the transform.
  • Quantize each block with functions weighted for the human eye. This is the step affected most by the Q factor to decide how much high-frequency information to discard.
  • Encode resulting coefficients using a Huffman algorithm.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 15 Graphics File Formats: PBM, PGM, PNM, PPM and the pbmplus programs

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
This is a collection of simple formats and utilities written and maintained by Jef Poskanzer, and available on most Unix systems.
  • PBM (Portable BitMap) - monochrome
  • PGM (Portable GreyMap) - gray-scale
  • PPM (Portable PixMap) - color
  • PNM (Portable aNything) - for programs which operate on any format
The headers have fields: MagicValue, ImageWidth, ImageHeight, MaxValue (not on PBM)
The MagicValues are PBM - P1(ascii) and P4 (raw), PGM - P2 and P5, PPM - P3 and P6
Example of a PPM file - each pixel has 3 (RGB) values:

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 16 Graphics File Formats: GIF

From Image Format Basics CPS606fall96 -- Fall Semester 96. * Critical Information in IMAGE
Full HTML Index
This is a widely used format made available by Compuserv (subject to licensing restricitions by Unisys).
The image data stored in a GIF file is LZW compressed.
The GIF formats allow for a header, logical screen descriptor and global color table at the beginning. Then for each image, there is a local image descriptor, a local color table and the image data. GIF89 adds other extension blocks of control information.
One of the options for storing the image is as ³interlaced². In this scheme, the rows are stored in the order of first and halfway, then the rows halfway inbetween, those and so on.
Allows from 1 to 8 bit color.
Reasonably fast to decompress.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 17 Graphics File Formats: JPEG

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
JPEG is actually the name of the standards organization, Joint Photographic Experts Group, but is used to refer to the compression and the file format (actually JFIF).
Stored as a stream of blocks, each identified by a beginning marker value.
Up to 24 bits per pixel.

HELP! * GREY=local HTML version of LOCAL Foils prepared Sept 1996

Foil 18 Graphics File Formats: TIFF

From Image Format Basics CPS606fall96 -- Fall Semester 96. * See also color IMAGE
Full HTML Index
The TIFF (Tag Image File Format) was introduced by Aldus in 1986 as a standard image file format.
It is very flexible, allowing many different types of compressions and formats, which are differentiated by ³tags².
Up to 24 bit color pixels.
Since there are so many options, very difficult for application programs to support reading all TIFF files.

Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Feb 19 1997