about summary refs log tree commit diff
path: root/pfm.html
diff options
context:
space:
mode:
Diffstat (limited to 'pfm.html')
-rw-r--r--pfm.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/pfm.html b/pfm.html
new file mode 100644
index 00000000..c08c3a53
--- /dev/null
+++ b/pfm.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML><HEAD><TITLE>PFM Format Description</TITLE></HEAD>
+<BODY>
+<H1>PFM Format</H1>
+<p>
+This document describes the PFM graphic image file format as understood by
+the Netpbm converters <a href="pamtopfm.html"><b>pamtopfm</b></a> and
+<a href="pfmtopam.html"><b>pfmtopam</b></a>.
+
+<p>There are multiple similar formats known as PFM in the world, none
+of them authoritatively documented.  The format described here is one
+that Bryan Henderson deduced from a program he found somewhere that
+dealt with a &quot;PFM&quot; format.
+
+<p>The PFM format is inspired by the Netpbm formats, and you will see
+lots of similarity.  It is not, however, an official Netpbm format.
+Its goal is not consistent with those of Netpbm formats.
+
+<h2>The format</h2>
+
+<p>A PFM image is a stream of bytes.  The stream consists of a header
+followed immediately by a raster.  These two components are described
+below.  There are no delimeters before or after the sections as
+described.
+
+<h3>PFM header</h3>
+
+<p>The PFM header is 3 consecutive &quot;lines&quot; of ASCII text.
+After each line is a white space character.  That character is
+typically a newline character, hence the term &quot;line,&quot; but
+doesn't have to be.
+
+<p><b>pamtopfm</b> uses a newline in the PFM it generates.
+
+<h4>Identifier Line</h4>
+
+<p>The identifier line contains the characters &quot;PF&quot; or
+&quot;Pf&quot;.  PF means it's a color PFM.  Pf means it's a grayscale
+PFM.
+
+<h4>Dimensions Line</h4>
+
+<p>The dimensions line contains two positive decimal integers,
+separated by a blank.  The first is the width of the image; the second
+is the height.  Both are in pixels.
+
+<h4>Scale Factor / Endianness</h4>
+
+<p>The Scale Factor / Endianness line is a queer line that jams
+endianness information into an otherwise sane description of a scale.
+The line consists of a nonzero decimal number, not necessarily an
+integer.  If the number is negative, that means the PFM raster is
+little endian.  Otherwise, it is big endian.  The absolute value of
+the number is the scale factor for the image.
+
+<p>The scale factor tells the units of the samples in the raster.  You
+use somehow it along with some separately understood unit information
+to turn a sample value into something meaningful, such as watts per
+square meter.
+
+
+<h3>PFM raster</h3>
+
+<p>The raster is a sequence of pixels, packed one after another, with no
+delimiters of any kind.  They are in standard Western reading order:
+left to right and top to bottom within the image.
+
+<p>Each pixel consists of 1 or 3 samples, packed one after another,
+with no delimiters of any kind.  1 sample for a grayscale PFM and 3 for a
+color PFM (see the Identifier Line of the PFM header).
+
+<p>Each sample consists of 4 consecutive bytes.  The bytes represent a
+32 bit string, in either big endian or little endian format, as determined
+by the Scale Factor / Endianness line of the PFM header.  That string is
+an IEEE 32 bit floating point number code.  Since that's the same format
+that most CPUs and compiler use, you can usually just make a program use
+the bytes directly as a floating point number, after taking care of the
+endianness variation.
+
+</BODY>
+</HTML>
+