version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
pgm |
|
|
2 |
!!!pgm |
|
|
3 |
NAME |
|
|
4 |
DESCRIPTION |
|
|
5 |
COMPATIBILITY |
|
|
6 |
SEE ALSO |
|
|
7 |
AUTHOR |
|
|
8 |
---- |
|
|
9 |
!!NAME |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
pgm - portable graymap file format |
|
|
13 |
!!DESCRIPTION |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
The portable graymap format is a lowest common denominator |
|
|
17 |
grayscale file format. |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
The format definition is as follows. |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
A PGM file consists of a sequence of one or more PGM images. |
|
|
24 |
There are no data, delimiters, or padding before, after, or |
|
|
25 |
between images. |
|
|
26 |
|
|
|
27 |
|
|
|
28 |
Each PGM image consists of the following: |
|
|
29 |
|
|
|
30 |
|
|
|
31 |
- |
|
|
32 |
|
|
|
33 |
|
|
|
34 |
A |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
- |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
Whitespace (blanks, TABs, CRs, LFs). |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
- |
|
|
44 |
|
|
|
45 |
|
|
|
46 |
A width, formatted as ASCII characters in |
|
|
47 |
decimal. |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
- |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
Whitespace. |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
- |
|
|
57 |
|
|
|
58 |
|
|
|
59 |
A height, again in ASCII decimal. |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
- |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
Whitespace. |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
- |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
The maximum gray value (Maxval), again in ASCII decimal. |
|
|
72 |
Must be less than 65536. |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
- |
|
|
76 |
|
|
|
77 |
|
|
|
78 |
Newline or other single whitespace character. |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
- |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
A raster of Width * Height gray values, proceeding through |
|
|
85 |
the image in normal English reading order. Each gray value |
|
|
86 |
is a number from 0 through Maxval, with 0 being black and |
|
|
87 |
Maxval being white. Each gray value is represented in pure |
|
|
88 |
binary by either 1 or 2 bytes. If the Maxval is less than |
|
|
89 |
256, it is 1 byte. Otherwise, it is 2 bytes. The most |
|
|
90 |
significant byte is first. |
|
|
91 |
|
|
|
92 |
|
|
|
93 |
- |
|
|
94 |
|
|
|
95 |
|
|
|
96 |
Each gray value is a number proportional to the intensity of |
|
|
97 |
the pixel, adjusted by the CIE Rec. 709 gamma transfer |
|
|
98 |
function. (That transfer function specifies a gamma number |
|
|
99 |
of 2.2 and has a linear section for small intensities). A |
|
|
100 |
value of zero is therefore black. A value of Maxval |
|
|
101 |
represents CIE D65 white and the most intense value in the |
|
|
102 |
image and any other image to which the image might be |
|
|
103 |
compared. |
|
|
104 |
|
|
|
105 |
|
|
|
106 |
- |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
Note that a common variation on the PGM format is to have |
|
|
110 |
the gray value be |
|
|
111 |
pnmgamma__ |
|
|
112 |
takes such a PGM variant as input and produces a true PGM as |
|
|
113 |
output. |
|
|
114 |
|
|
|
115 |
|
|
|
116 |
- |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
Characters from a |
|
|
120 |
|
|
|
121 |
|
|
|
122 |
Note that you can use __pnmdepth__ To convert between a |
|
|
123 |
the format with 1 byte per gray value and the one with 2 |
|
|
124 |
bytes per gray value. |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
There is actually another version of the PGM format that is |
|
|
128 |
fairly rare: |
|
|
129 |
pbm__(5) for some |
|
|
130 |
commentary on how plain and raw formats relate to one |
|
|
131 |
another. |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
The difference in the plain format is: |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
- |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
There is exactly one image in a file. |
|
|
141 |
|
|
|
142 |
|
|
|
143 |
- |
|
|
144 |
|
|
|
145 |
|
|
|
146 |
The magic number is P2 instead of P5. |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
- |
|
|
150 |
|
|
|
151 |
|
|
|
152 |
Each pixel in the raster is represented as an ASCII decimal |
|
|
153 |
number (of arbitrary size). |
|
|
154 |
|
|
|
155 |
|
|
|
156 |
- |
|
|
157 |
|
|
|
158 |
|
|
|
159 |
Each pixel in the raster has white space before and after |
|
|
160 |
it. There must be at least one character of white space |
|
|
161 |
between any two pixels, but there is no |
|
|
162 |
maximum. |
|
|
163 |
|
|
|
164 |
|
|
|
165 |
- |
|
|
166 |
|
|
|
167 |
|
|
|
168 |
No line should be longer than 70 characters. |
|
|
169 |
|
|
|
170 |
|
|
|
171 |
Here is an example of a small graymap in this |
|
|
172 |
format: |
|
|
173 |
|
|
|
174 |
|
|
|
175 |
P2 |
|
|
176 |
# feep.pgm |
|
|
177 |
24 7 |
|
|
178 |
15 |
|
|
179 |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|
|
180 |
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 |
|
|
181 |
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 |
|
|
182 |
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 |
|
|
183 |
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 |
|
|
184 |
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 |
|
|
185 |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
|
|
186 |
Programs that read this format should be as lenient as possible, accepting anything that looks remotely like a graymap. |
|
|
187 |
!!COMPATIBILITY |
|
|
188 |
|
|
|
189 |
|
|
|
190 |
Before April 2000, a raw format PGM file could not have a |
|
|
191 |
maxval greater than 255. Hence, it could not have more than |
|
|
192 |
one byte per sample. Old programs may depend on |
|
|
193 |
this. |
|
|
194 |
|
|
|
195 |
|
|
|
196 |
Before July 2000, there could be at most one image in a PGM |
|
|
197 |
file. As a result, most tools to process PGM files ignore |
|
|
198 |
(and don't read) any data after the first |
|
|
199 |
image. |
|
|
200 |
!!SEE ALSO |
|
|
201 |
|
|
|
202 |
|
|
|
203 |
fitstopgm(1), fstopgm(1), hipstopgm(1), lispmtopgm(1), |
|
|
204 |
psidtopgm(1), rawtopgm(1), pgmbentley(1), pgmcrater(1), |
|
|
205 |
pgmedge(1), pgmenhance(1), pgmhist(1), pgmnorm(1), |
|
|
206 |
pgmoil(1), pgmramp(1), pgmtexture(1), pgmtofits(1), |
|
|
207 |
pgmtofs(1), pgmtolispm(1), pgmtopbm(1), pnm(5), pbm(5), |
|
|
208 |
ppm(5) |
|
|
209 |
!!AUTHOR |
|
|
210 |
|
|
|
211 |
|
|
|
212 |
Copyright (C) 1989, 1991 by Jef Poskanzer. |
|
|
213 |
---- |