PFM Portable FloatMap Image Format

The Portable FloatMap format was designed as a floating-point image format in the spirit of Jef Poskanzer's Portable Pixmap file format from the PBMPlus toolkit, most currently available through the Source Forge NetPBM distribution. Like the Portable Pixmap format (.ppm), the format begins with three lines of text specifying the image size and type, and then continues with raw binary image data for the rest of the file.

The text header of a .pfm file takes the following form:

[type]
[xres] [yres]
[byte_order]

Each of the three lines of text ends with a 1-byte Unix-style carriage return: 0x0a in hex, not the Windows/DOS CR/LF combination. The "[type]" is one of "PF" for a 3-channel RGB color image, or "Pf" for a monochrome single-channel image. "[xres] [yres]" indicates the x and y resolutions of the image. "[byte_order]" is a number used to indicate the byte order within the file. A positive number (e.g. "1.0") indicates big-endian, with the most significant byte of each 4-byte float first. If the number is negative (e.g. "-1.0") this indicates little-endian, with the least significant byte first. There are no comments in these files. For example:

PF
768 512
-1.0

Indicates an RGB color image, 768 by 512 pixels, with little-endian byte order.

After the final carriage return the file proceeds with a series of three 4-byte IEEE 754 single precision floating point numbers for each pixel, specified in left to right, bottom to top order.

   Example images, 512x768 pixels:

See also:

Greg Ward's High Dynamic Range Encodings page.