Blame userguide/pfm.html

Packit 78deda
Packit 78deda
<HTML>
Packit 78deda
<HEAD><TITLE>PFM Format Description</TITLE>
Packit 78deda
<META NAME="manual_section" CONTENT="5">
Packit 78deda
</HEAD>
Packit 78deda
<BODY>
Packit 78deda

pfm

Packit 78deda
Updated: 19 April 2012
Packit 78deda

NAME

Packit 78deda
Packit 78deda
PFM - PFM graphic image file format
Packit 78deda
Packit 78deda

DESCRIPTION

Packit 78deda
Packit 78deda

Packit 78deda
This document describes the PFM graphic image file format as understood by
Packit 78deda
the Netpbm converters pamtopfm and
Packit 78deda
pfmtopam.
Packit 78deda
Packit 78deda

There are multiple similar formats known as PFM in the world, none

Packit 78deda
of them authoritatively documented.  The format described here is one
Packit 78deda
that Bryan Henderson deduced from a program he found somewhere that
Packit 78deda
dealt with a "PFM" format.
Packit 78deda
Packit 78deda

The PFM format is inspired by the Netpbm formats, and you will see

Packit 78deda
lots of similarity.  It is not, however, an official Netpbm format.
Packit 78deda
Its goal is not consistent with those of Netpbm formats.
Packit 78deda
Packit 78deda

The format

Packit 78deda
Packit 78deda

A PFM image is a stream of bytes. The stream consists of a header

Packit 78deda
followed immediately by a raster.  These two components are described
Packit 78deda
below.  There are no delimeters before or after the sections as
Packit 78deda
described.
Packit 78deda
Packit 78deda

PFM header

Packit 78deda
Packit 78deda

The PFM header is 3 consecutive "lines" of ASCII text.

Packit 78deda
After each line is a white space character.  That character is
Packit 78deda
typically a newline character, hence the term "line," but
Packit 78deda
doesn't have to be.
Packit 78deda
Packit 78deda

pamtopfm uses a newline in the PFM it generates.

Packit 78deda
Packit 78deda

Identifier Line

Packit 78deda
Packit 78deda

The identifier line contains the characters "PF" or

Packit 78deda
"Pf".  PF means it's a color PFM.  Pf means it's a grayscale
Packit 78deda
PFM.
Packit 78deda
Packit 78deda

Dimensions Line

Packit 78deda
Packit 78deda

The dimensions line contains two positive decimal integers,

Packit 78deda
separated by a blank.  The first is the width of the image; the second
Packit 78deda
is the height.  Both are in pixels.
Packit 78deda
Packit 78deda

Scale Factor / Endianness

Packit 78deda
Packit 78deda

The Scale Factor / Endianness line is a queer line that jams

Packit 78deda
endianness information into an otherwise sane description of a scale.
Packit 78deda
The line consists of a nonzero decimal number, not necessarily an
Packit 78deda
integer.  If the number is negative, that means the PFM raster is
Packit 78deda
little endian.  Otherwise, it is big endian.  The absolute value of
Packit 78deda
the number is the scale factor for the image.
Packit 78deda
Packit 78deda

The scale factor tells the units of the samples in the raster. You

Packit 78deda
use somehow it along with some separately understood unit information
Packit 78deda
to turn a sample value into something meaningful, such as watts per
Packit 78deda
square meter.
Packit 78deda
Packit 78deda
Packit 78deda

PFM raster

Packit 78deda
Packit 78deda

The raster is a sequence of pixels, packed one after another, with no

Packit 78deda
delimiters of any kind.  They are grouped by row, with the pixels in each
Packit 78deda
row ordered left to right and the rows ordered bottom to top.
Packit 78deda
Packit 78deda

Each pixel consists of 1 or 3 samples, packed one after another,

Packit 78deda
with no delimiters of any kind.  1 sample for a grayscale PFM and 3 for a
Packit 78deda
color PFM (see the Identifier Line of the PFM header).
Packit 78deda
Packit 78deda

Each sample consists of 4 consecutive bytes. The bytes represent a

Packit 78deda
32 bit string, in either big endian or little endian format, as determined
Packit 78deda
by the Scale Factor / Endianness line of the PFM header.  That string is
Packit 78deda
an IEEE 32 bit floating point number code.  Since that's the same format
Packit 78deda
that most CPUs and compiler use, you can usually just make a program use
Packit 78deda
the bytes directly as a floating point number, after taking care of the
Packit 78deda
endianness variation.
Packit 78deda
Packit 78deda
</BODY>
Packit 78deda
</HTML>
Packit 78deda