Introduction
The Portable Float Map is the simplest way to store an image of floating point values. It follows the idea of the Netpbm formats: a few lines of text, then the raw pixel values with no compression. Each sample is a 32-bit float, so the file can hold any brightness, not just 0 to 255.
It is used for high dynamic range photographs and renders, and in computer vision research for depth and disparity maps. The files are large, but any program can read them with a few lines of code.
Structure
The header is three lines of text. The first is PF for a colour image
with three channels, or Pf for one greyscale channel. The second gives
the width and height. The third is a scale factor whose sign gives the byte order:
a negative number means little-endian floats, a positive one big-endian.
After the header come the pixels as 32-bit floats, with no padding. Rows are stored from the bottom of the image to the top, the opposite of most Netpbm formats. The file layout page has the details.
0TypePForPf, then a newline3 bytes3Size width and height as textvaries…Scale as text, negative for little-endianvaries…Pixels 32-bit floats, bottom row firstvaries
Not described
PFM has no official specification. These pages follow Paul Debevec’s description and Netpbm’s documentation; the parts below are not covered yet.
Unknown
- Viewer: the viewer reads the whole header and every sample, draws
the picture with a tone map you choose and lists every pixel. Where the sources say
nothing it reports a problem and says what it assumed: it draws NaN samples
magenta and clips infinities, assumes red, green, blue for
PF, does not apply the scale factor, and reads a carriage return and line feed as one line end. The row order of the Photoshop variant is an option; nothing else about that variant is known. - Reference: the channel order of a
PFpixel, the handling of NaN and infinite samples, and any limit on the scale factor’s magnitude; neither source states them (file layout). The Photoshop variant’s top-to-bottom rows are noted but its other differences, if any, are not documented.
Also used for
- Windows Printer Font Metrics – The Windows binary file of a font’s extents, kerning pairs and names.
Links
Software
- ImageMagick – command-line tools that convert to and from PFM (Windows, macOS, Linux)
- Netpbm – command-line image toolkit with PFM converters (Windows, macOS, Linux)
Developers
- OpenCV – computer vision library that reads and writes PFM (C++, Python)
Reference
- PFM Portable Float Map – Paul Debevec’s description of the format