PGM Files


PGM is the portable gray map format. It is a simple grayscale image description. The definition is as follows:

Characters from a "#" to the next end-of-line are ignored (comments). No line should be longer than 70 characters.

There is also a variant on the format, available by setting the RAWBITS option at compile time. This variant is different in the following ways:

The files are smaller and many times faster to read and write. Note that this raw format can only be used for MAXVAL less than or equal to 255. If you use the PGM library and try to write a file with a larger MAXVAL, it will automatically fall back on the slower but more general plain format.

EXAMPLE:

        P2
        # feep.pgm
        24 7
        15
        0 0  0  0  0  0  0  0  0 0  0  0  0  0  0  0  0 0  0  0  0  0  0  0
        0 3  3  3  3  0  0  7  7 7  7  0  0 11 11 11 11 0  0 15 15 15 15  0
        0 3  0  0  0  0  0  7  0 0  0  0  0 11  0  0  0 0  0 15  0  0 15  0
        0 3  3  3  0  0  0  7  7 7  0  0  0 11 11 11  0 0  0 15 15 15 15  0
        0 3  0  0  0  0  0  7  0 0  0  0  0 11  0  0  0 0  0 15  0  0  0  0
        0 3  0  0  0  0  0  7  7 7  7  0  0 11 11 11 11 0  0 15  0  0  0  0
        0 0  0  0  0  0  0  0  0 0  0  0  0  0  0  0  0 0  0  0  0  0  0  0
      

PGM files are:

Reference:

Programs to view a PGM file include:

Routines to read or write a PGM file:

Programs to convert a PGM file to another format:

Programs to convert a file to PGM format:

Files you may copy:

Back to the data home page.


Last revised on 10 May 2002.