Image Formats


Image file formats are the standards by which pictoral information is stored in and retrieved from files. Since images are often a bit of work to produce, and you will probably want to keep a number of them around (for repeatable testing if nothing else) you will need to deal with these.

Image file formats are distinct from memory or in-core formats, which are used for handling images inside programs. Historically, in-core formats did not exist as computers did not have enough memory to hold an entire image. These days, loading entire images into the program is standard practice, and a number of in-core formats exist. One of these is defined by RN's ipp package, and there are others as well.

There are a lot of different image file formats, developed for different purposes, and with different attributes. Common ones include tiff, jpeg, png, gif, pgm, ppm, matlab matrices, and postscript files. These all have their own advantages and disadvantages. Most allow color (tiff, jpeg, png, gif, ppm, postscript); some may be compressed in a complicated and possibly lossy manner (gif, jpeg are (usually) lossy, png is lossless but conpressed, and tiff supports several compression schemes, but is often used for uncompressed images); some are terribly inefficient (matlab, postscript); and some are proprietary (gif, postscript). My up front recommendation for this course is to use the tiff format as much as possible as it is relatively simple, allows color, is not propriatary, and is in common use.

The historical department image file format, which a lot of old software runs on is known as iff, and it is convenient to designate iff image file with the .iff suffix (as in picture.iff). It is primarily a gray-scale format (though with a variable number of bits). There is presently no department standard for representing color images with iff, though several people have hacked together their own representations (e.g., using three separate images, or 24 bit pixels which are then pulled apart). One of these is associated with the nelson image processing library (ipp), though you will probably never need to use it. The main problem with iff is that no one else in the world uses it, so it is probably best to use some other format as much as possible. There are programs for converting iff to and from other formats, for example iff2ps, iff2pgm and RN's convert_format program. The basic iff format is in /usr/src/vision/iff/bin/image.h,v.

One very useful program is xv, which take images in various formats, including tiff, pgm, jpeg, ps, and oldstyle gif, and allows you to display them and do other operations (e.g find the value at a point, specify a window using a mouse, remap colors, convert to new formats, etc.) using an Xwindows interface. Xv will accept old style gif images, but not newer versions due to a licensing problem. It does not recognize iff, but the program "convert_format" in my bin (/u/nelson/bin/[Solaris|SunOS|DigitalUnix]), which converts between a limited number of formats (tiff, pgm, iff and cvl), can be used get an iff image into a form that xv can use.

A quick way of viewing a tiff, png, jpg, pgm, iff, or cvl image is to use the "xshow" program, also in my bin. The dithering is not quite as good as xv if you happen to be on an 8-bit or fewer!! display (unlikely as of 2003), but it is adequate, and the program is a lot faster. The component routines can also be called from inside a program by linking the ipp utility library.


List of Common Image File Formats

Back to vision course main page