PGM file format

Source: Internet
Author: User
To read the. pgm file in C, please link the blog http://blog.csdn.net/a350203223/article/details/13102513
PGM file Format PGM----Portable Graymap format.

The PGM format is the minimum standard for grayscale file formats. The format of the PGM file is defined as follows: A PGM file consists of one or more PGM images. There is no data before or after the multiple images. Each PGM image consists of the following parts:-A "magic number", which is used to calibrate the file format.
The magic number of PGM is "P5".  -Blank area (space, TAB, enter, line wrap)-image width, decimal ascii-white space-image high, decimal ASCII-blank area-Maximum grayscale value (maxval), decimal ascii. Must be less than 65536-a new line or another white space character- An image of gray value with a wide * height of empty grids. Each grayscale value is taken from 0 to Maxval, 0 for Black, and maxval for white. Each grayscale value is represented by 1-2 bytes. If      maxval is less than 256, that line is one byte, otherwise two bytes. Maximum bytes ( 
Most significant byte) starts-each grayscale value is the density value that represents the current pixel value after the CIE rec.709 gamma correction.
-A very common PGM format alternative format is the linear grayscale value (without gamma correction), pnmgamma with such a PGM file as input, output a standard PGM file-#符号之后的一行为注释行, will be omitted.
-The raster value for each pixel is represented as a decimal ASCII value. -Each pixel has a space before and after the raster value.
So there will be greater than or equal to 1 spaces between the two pixels.

-No more than 70 characters per line. PGM File Example: P5 7 0    0    0    0    0    0    0    0    0    0    0     0    0    0    0  &NBsp 0    0    0    0    0    0     0    0    0 0    3    3    3 & nbsp;  3    0    0    7    7    7     7    0    0   11   11   11    11    0    0   15   15   15   15     0 0    3    0    0    0    0& nbsp;   0    7    0    0    0     0    0   11    0    0    0     0    0   15    0    0   15    0 0    3    3    3    0     0    0    7    7    7     0    0    0   11   11   11    0     0    0   15   15   15   15     0 0    3    0    0    0    0 & nbsp;  0    7    0    0    0    0     0   11    0    0    0    0     0   15    0    0    0    0 0     3    0    0    0    0    0    7    7    7    7     0    0   11   11   11   11     0    0   15    0    0    0     0 0    0    0    0    0    0 & nbsp;  0    0    0    0    0    0     0    0    0    0    0     0    0    0    0    0    0     0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.