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.
0TypePForPf, then a newline3 bytes3Size width and height as textvaries…Scale as text, negative for little-endianvaries…Pixels 32-bit floats, bottom row firstvaries
Also used for
- PostScript Type 1 font metrics – Adobe’s PostScript font: cubic outlines in an encrypted PostScript program.
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