Explanation of PGM and PPM image file format
Seeing an image file in Linux
- Using the viewer xv
Type "xv"
use the right mouse button to access the menu
for loading, viewing, saving image files in various formats.
- Using the viewer ee
Common image formats
- GIF and JPEG (see Supercomputer Applications).
- For reading image data, two other formats, PGM and PPM are also used.
- P2 - PGM grey scale image, stored in ASCII, one value per pixel
- P3 - PPM color image, stored in ASCII, 3 RGB values per pixel
- P5 - PGM grey scale image stored in binary (compressed) format
- P6 - PPM color image stored in binary (compressed) format
Sample PGM file
First line tells the PGM format. P2 -- grey scale
Lines beginning with # are comment lines
Third line gives columns (width) and rows (height) of image
Fourth line gives the max pixel value
Rest is data
P2
# CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2)
97 128
45 45 49 57 65 65 61 85 125 138 121 117 117 121 121 121 117
109 146 215 219 219 223 206 182 190 194 194 190 194 198 198 198 202
198 194 190 190 194 198 198 202 202 202 198 198 194 194 194 194 198
198 198 198 198 194 194 194 198 198 198 202 198 198 194 190 194 194
194 198 198 190 190 210 215 215 210 206 170 146 146 142 130 65 45
40 45 49 61 53 36 16 28 28 61 121 142 53 53 53 57 69
. . .
|
|
Sample PPM file
Here's the same file in PPM (color) format.
Note the 3 values per pixel.
To make it a gray file the rgb values are the
same for each pixel.
P3
# CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2)
291 384
255
45 45 45 45 45 45 49 49 49 57 57 57 65 65 65 85 85
85 121 121 121 . . .
|
|
|
|