XPM Image Format

The XPM image format was developed by the Koala team at Bull Research, France. An XPM file is an ASCII file. One of the reasons the XPM format was developed was so that an XPM image could be included in a C program. Thus, the format is in C syntax. An XPM is actually an array of strings composed of six different sections.

The header of an XPM file looks like this:


/* XPM */
static char* image2 = {
"512 484 2 2",
"__ c #000000",
"_` c #ffffff",

Unless you want to include the file in a C program, you can ignore the first two lines of the file. The double quotes and the commas are there only to separate the different strings--no data is represented by these characters. The third line contains the following information: width, height, number of colors, and characters per pixel. After this comes the colors section of the file. This section contains as many strings as there are colors (in this case, there are two). Each string has three data elements: characters, key, and color. The characters element is a string of length equal to the characters per pixel. The key identifies what type of color it is ("c" stands for "color visual"). Finally, there is a hexadecimal number with the pixel value of the color. For these images, the headers should all be the same:

__
is black and
_`
is white. Following the header, each line is a row in the image and is in the format of a string in C (surrounded by double quotes and separated from other strings by commas). With this information, you should be able to process the XPM files.

If you have access to the XPM library, it has many useful functions that may or may not make it easier for you to process the images (depending on your experience with developing X windows programs). There is a very nice manual available that comes with the XPM library (free, by anonymous ftp). Since it is 30 pages long, it goes into much more detail and will also tell you about the functions in the library to load and save XPM files. Here are a few locations for the latest release of the library:

  1. avahi.inria.fr
  2. ftp.x.org
Be advised that these sites are used heavily, so it might take a while to get through and download the library. Check your local system to see if the XPM library is alread installed (it probably is).

Up to "Camera Calibration"

Back to "User-supplied Centroids"