Image Formats

Image file format refers to the way an image is written in a computer file. In the course of several years, a very large number of formats has been developed. The most popular ones are described below.

Raw Format

The raw format is the most trivial one: the pixel values are saved in a raster-scan order (left-to-right, top-to-bottom), one value at a time. For grayscale images having values in the range 0-255, 8 bits or 1 byte per pixel is sufficient. Consequently, an NxM image occupies NxM bytes on disk, with each byte corresponding to the value of one pixel.

The drawback of this format is that the original size of the image cannot be inferred directly by inspection of the file. For example a 256x512 image could not be distinguished from a 512x256 one, unless the image is displayed on the screen.

All other formats were created so that the file itself contains useful information about the image, including size, color map entries (for pseudo-color images, i.e., those that use Color Look-Up Talbes--CLUT), etc.

PBMplus Formats

These are part of a very popular public domain package for Unix systems called pbmplus. It defines three basic formats: PBM (Portable Bitmap, for bi-level images), PGM (Portable Graymap, for grayscale images), and PPM (Portable Pixel Map, for color images). It also includes more than a 100 utilities to convert from/to other formats, including raw, GIF, JPEG, G3, TIFF, etc. It acts as a least common denominator, trying to alleviate the problems of the format pollution that currently exists. I highly recommend its use.

If you are on a Unix system, it will probably be convenient to either deal directly with one of the PBMplus formats, or process your images using the raw format and convert to PBM/PGM/PPM only when you want to display your results.

CompuServe GIF

GIF (Graphics Interchange Format) is a very popular format, especially on PCs and Macs, that has been developed by CompuServe. It supports pseudo-color images, using a CLUT. It provides capabilities for lossless compression of the image as it is stored on the file, as well as 4-way interlaced storage so that a rough outline of the image is available very quickly on the display (this is a very popular option in Web pages, since many people access the Web using slow modem lines).

GIF is not ideal for image processing with grayscale images, because of the presence of the CLUT. A properly constructed grayscale GIF must have a color map with entries starting from (0, 0, 0), (1, 1, 1), up to (255, 255, 255). The pixel values can then be considered as regular grayscale levels.

At any rate, a GIF reader is probably rather involved to create, so you probably want to use existing tools to convert your raw images to this format. The PBMplus package supports GIF.

Image Viewers

A variety of programs exist for viewing images. The Netscape and other Web browsers have internal support for viewing a variety of image formats, including GIF and JPEG (a sophisticated lossy compression standard that we will discuss in class). None of them, unfortunately, supports any of the PBMplus formats.


If you are on a Unix system running the X Window System (X11), then your best choice is the program xv. It supports all the PBMplus formats, GIF, and many others, and it offers a powerful interface for manipulating images.

Windows (PC)

If you are working on a PC running Windows (Windows 3.1, Windows 95, or Windows NT 3.x/4.x), you can either use existing imaging software (e.g., the very powerful but expensive Adobe PhotoShop), or even better one of the shareware or public domain viewers that are abundant on the Internet. You can search for those at the Yahoo directory ( You can also try LView Pro, which you can download from here (


Similar to the PC, you can either use a commercial package (PhotoShop, if you already have it), or a shareware or public domain viewer