1PFM Format Description(5) File Formats Manual PFM Format Description(5)
2
3
4
6 PFM - PFM graphic image file format
7
8
10 This document describes the PFM graphic image file format as understood
11 by the Netpbm converters pamtopfm(1) and pfmtopam(1).
12
13 There are multiple similar formats known as PFM in the world, none of
14 them authoritatively documented. The format described here is one that
15 Bryan Henderson deduced from a program he found somewhere that dealt
16 with a "PFM" format.
17
18 The PFM format is inspired by the Netpbm formats, and you will see lots
19 of similarity. It is not, however, an official Netpbm format. Its
20 goal is not consistent with those of Netpbm formats.
21
22
24 A PFM image is a stream of bytes. The stream consists of a header fol‐
25 lowed immediately by a raster. These two components are described
26 below. There are no delimeters before or after the sections as
27 described.
28
29
30 PFM header
31 The PFM header is 3 consecutive "lines" of ASCII text. After each line
32 is a white space character. That character is typically a newline
33 character, hence the term "line," but doesn't have to be.
34
35 pamtopfm uses a newline in the PFM it generates.
36
37 Identifier Line
38
39 The identifier line contains the characters "PF" or "Pf". PF means
40 it's a color PFM. Pf means it's a grayscale PFM.
41
42 Dimensions Line
43
44 The dimensions line contains two positive decimal integers, separated
45 by a blank. The first is the width of the image; the second is the
46 height. Both are in pixels.
47
48 Scale Factor / Endianness
49
50 The Scale Factor / Endianness line is a queer line that jams endianness
51 information into an otherwise sane description of a scale. The line
52 consists of a nonzero decimal number, not necessarily an integer. If
53 the number is negative, that means the PFM raster is little endian.
54 Otherwise, it is big endian. The absolute value of the number is the
55 scale factor for the image.
56
57 The scale factor tells the units of the samples in the raster. You use
58 somehow it along with some separately understood unit information to
59 turn a sample value into something meaningful, such as watts per square
60 meter.
61
62
63
64 PFM raster
65 The raster is a sequence of pixels, packed one after another, with no
66 delimiters of any kind. They are grouped by row, with the pixels in
67 each row ordered left to right and the rows ordered bottom to top.
68
69 Each pixel consists of 1 or 3 samples, packed one after another, with
70 no delimiters of any kind. 1 sample for a grayscale PFM and 3 for a
71 color PFM (see the Identifier Line of the PFM header).
72
73 Each sample consists of 4 consecutive bytes. The bytes represent a 32
74 bit string, in either big endian or little endian format, as determined
75 by the Scale Factor / Endianness line of the PFM header. That string
76 is an IEEE 32 bit floating point number code. Since that's the same
77 format that most CPUs and compiler use, you can usually just make a
78 program use the bytes directly as a floating point number, after taking
79 care of the endianness variation.
80
82 This manual page was generated by the Netpbm tool 'makeman' from HTML
83 source. The master documentation is at
84
85 http://netpbm.sourceforge.net/doc/pfm.html
86
87netpbm documentation 19 April 2012 PFM Format Description(5)