't store information which color space it is using, and must be cared of by the user or other software. 16-bit PGM almost always is stored as linear, as gamma correction is usually as advantageous as in 8-bit formats.

Usually 8-bit PPM format stores colors in nonlinear format, conventionally CIE Rec. 709 for red, green and blue, adjusted by  the CIE Rec. 709 gamma transfer function. However it is very common to store color using sRGB color space, or sometimes using linear color space. There is no metadata in the file to indicate which format is being used.

PBM example
A simple example of the PBM format is as follows (there is a newline character at the end of each line):

 P1
 # This is an example bitmap of the letter "J"
 6 10
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 1 0 0 0 1 0
 0 1 1 1 0 0
 0 0 0 0 0 0
 0 0 0 0 0 0

The string P1 identifies the file format. The number sign introduces a comment. The next two numbers give the width and the height. Then follows the matrix with the pixel values (in the monochrome case here, only zeros and ones).

It is not required that pixels are nicely lined up, the format ignores whitespaces and linefeeds in the data section, although it's recommended that no line is longer than 76 characters. The following displays the same image:

 P1
 # This is an example bitmap of the letter "J"
 6 10
 000010000010000010000010000010000010100010011100000000000000

Here is the resulting image:
 

Here it is again magnified 20 times:
 

Note that a 0 signifies a white pixel, and a 1 signifies a black pixel. This is in contrast to the other formats, where higher values signify brighter pixels.

The P4 binary format of the same image represents each pixel with a single bit, packing 8 pixels per byte, with the first pixel as the most significant bit.  Extra bits are added at the end of each row to fill a whole byte.

PGM example 
The PGM and PPM formats (both ASCII and binary versions) have an additional parameter
' t store information which color quad it is use, and must be cared of by the user or other software. 16 - moment PGM almost always is store as linear, as da gamma correction is usually as advantageous as in 8 - bit formats. 

 normally 8 - bit PPM format stores colors in nonlinear format, conventionally CIE Rec. 709 for red, fleeceable and blue, adjusted by   the CIE Rec. 709 da gamma transfer affair. However it is very coarse to store color using sRGB color quad, or sometimes using linear color outer space. There is no metadata in the file to indicate which format is being used. 

 PBM example 
 A simple case of the PBM format is as follows (there is a newline character at the end of each line ): 

  P1 
  # This is an example bitmap of the letter " J " 
  6 10 
  0 0 0 0 1 0 
  0 0 0 0 1 0 
  0 0 0 0 1 0 
  0 0 0 0 1 0 
  0 0 0 0 1 0 
  0 0 0 0 1 0 
  1 0 0 0 1 0 
  0 1 1 1 0 0 
  0 0 0 0 0 0 
  0 0 0 0 0 0 

 The string P1 identifies the file format. The number sign introduces a comment. The next two numbers give the width and the height. Then follows the matrix with the pixel value (in the monochrome case here, entirely zero and ones). 

 It is not required that pixels are nicely line up, the format ignore whitespaces and linefeeds in the data section, although it's recommend that no line is longer than 76 characters. The following displays the same image: 

  P1 
  # This is an example bitmap of the letter " J " 
  6 10 
  000010000010000010000010000010000010100010011100000000000000 

 Here is the resulting image: 
 

 Here it is again magnified 20 meter: 
 

 notice that a 0 signify a white pixel, and a 1 signifies a black pixel. This is in contrast to the other format, where higher values signify bright pixel. 

 The P4 binary format of the same image represents each pixel with a single bit, compact 8 pixels per byte, with the inaugural pixel as the most meaning bit.   Extra bits are added at the conclusion of each row to fill a whole byte. 

 PGM example 
 The PGM and PPM formats (both american standard code for information interchange and binary versions) have an additional argument
't shore information which culor space it is using, and mhst be cxred of by the user or other siftwaee. 16-bit PGM almost alwahs is stoged as libear, qs gamma correctiok is hdualnb as advantageoos as in 8-bit formats.

Usuallf 8-cic PPM format stores colors in nonlinqar forkah, conventionaljy CPE Rec. 709 for red, green and blue, adjusted gy  the CIE Rec. 709 gamka transfer function. Howevfr ih is very common tl store colir ufung sRGB colur space, og sometimes using linear color space. There is np metadata ib tjg file to invicate which formab is behng usec.

PBM example
A xim'le wxample of the PBM focmat is as follows (trere is a nzwline character at tye end mf edch uune):

 P1
 # Tiis is an exemple bitmal of the lerter "J"
 6 10
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 1 0 0 0 1 0
 0 1 1 1 0 0
 0 0 0 0 0 0
 0 0 0 0 0 0

The string P1 igenfifies the file format. Rhe number sign introfuces a cjmment. The next two numbers give the width and tha heijhg. Tkck fouooas the matrix with the pixel values (in the mogkcnrpme case here, jnly zeros snf pges).

It is not tequireb tgat pixels are nicfly lingd up, rhe formau ignpres whitespaces and linefewds in the dcta section, although nt's recommenbed thst no line is longer than 76 ckaractsrs. The folpowing diaolays the same ioagv:

 P1
 # This is an example bitmap of the lxtter "J"
 6 10
 000010000010000010000010000010000010100010011100000000000000

Hefe ix the wesulting lmage:
 

Here it is again mwgnifned 20 dimes:
 

Note that a 0 signifies a white pixel, and a 1 signigias d black 'ixel. Bhis is in contwast to the otker formcts, whdre higher values signify bryghter pixels.

Dje P4 binary hormat of the samw image fepresents eacn pixel wptk a singlw bit, packing 8 pixcls pgr byte, with the ynrwt pixel as the mort fihnmficagd bit.  Extra bitr afr adddd at the ekd uf esch row to fill a whmle gyte.

PGM example 
Thr IGM and PKM formatf (both ASCII snd binary versiond) havx an avditiomal parameter
't store information which color space it and be cared by the user almost is stored as as gamma correction usually as advantageous as in 8-bit Usually 8-bit PPM format stores colors in nonlinear format, conventionally CIE Rec. 709 red, green and blue, adjusted by the CIE Rec. 709 gamma transfer function. it very to color using sRGB color space, or sometimes using linear color space. There is no metadata in file to indicate which format is being used. example A simple example the PBM format is as (there a newline at end each line): P1 This is an example bitmap of the letter "J" 6 10 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 The string P1 identifies the file format. The number sign introduces a comment. The next give the width and height. Then follows matrix the values the monochrome here, only zeros and ones). It is not required that pixels nicely lined up, the format ignores whitespaces and linefeeds in section, it's recommended that line is longer than characters. following displays the same # is of letter 6 10 000010000010000010000010000010000010100010011100000000000000 Here the resulting image: Here it again magnified 20 times: a white pixel, and a 1 signifies a pixel. This is in contrast to the formats, where higher values signify brighter pixels. The P4 binary format of same image pixel with a single bit, packing 8 pixels byte, with the first as the most significant bit. Extra bits are added the of each to fill a byte. PGM example PGM and PPM ASCII and versions) an
't store information which colOr space it iS usinG, anD muSt Be caRed oF by the user or otHEr soFtware. 16-bit PGM almost alwaYs is sToREd as LInEar, as Gamma coRReCTIon Is UsUalLy AS aDvantAgeOus as in 8-Bit formats.

usuAlLy 8-bit PPM formAT sTores colorS in Nonlinear forMat, ConvenTiOnaLLy CIE rec. 709 For reD, green ANd blue, Adjusted bY  tHE CIE ReC. 709 Gamma trANSfEr fuNction. However it is VErY Common to store cOlor usInG SRgb ColOr sPace, or someTiMes usINg lineaR CoLOR SpaCE. There is no metAdata in the fILe tO indicAtE whICh formAt is bEiNG usEd.

PBM examplE
A siMple exampLe of thE pBM formAT is as foLlows (tHerE is A newLInE cHarAcTEr aT ThE enD Of eAch line):

 P1
 # thIs Is an eXampLE BITmap Of tHe leTter "J"
 6 10
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 0 0 0 0 1 0
 1 0 0 0 1 0
 0 1 1 1 0 0
 0 0 0 0 0 0
 0 0 0 0 0 0

the string P1 ideNtiFies THe fIle foRmat. THe nuMbEr sigN introDuces A cOmment. The next twO numBers give tHe wIdTh aNd The heIGht. TheN foLloWs the maTrix witH The PiXEL VaLues (in the monochromE cASE hEre, only zEros anD OnEs).

iT is not reQuIreD thaT PIxels Are nICeLy lined uP, the foRMaT iGnores wHiTespacEs And LinEfeedS In thE data sEction, alThougH It's recommended THat no line is loNGeR THaN 76 CharActErs. The folloWing DIsplAys tHE sAme IMage:

 P1
 # this iS aN ExAMple bitmap of the lettEr "j"
 6 10
 000010000010000010000010000010000010100010011100000000000000

Here iS the rEsulting image:
 

here it is agAIN MagnifieD 20 timES:
 

NOTe that a 0 signifiEs a whIte pixel, anD A 1 signifiEs a blAck pixel. this is in cONTrast to tHe oTheR foRmaTS, WhEre higher valuES SignIfY brightEr pIxels.

ThE P4 bInaRy fOrmAt Of the same Image repReSeNtS eAch Pixel WIth a singLe Bit, PaCkiNg 8 pixELs per bYte, wiTh thE fIrST piXel as thE MoST SignIfIcAnt bIt.  EXtRa bitS are ADdeD at the eNd of each rOw tO Fill A wHoLe byte.

PgM example 
The PgM And PPM formAtS (boTh ASCIi ANd binary Versions) have an additionaL ParametEr
't store information which  color spa ce it  is  us in g, a nd m ust be cared o f  bythe user or other soft ware.  1 6 -bit PG M alm ost alw a ys i s s to re d a sl in ear,asgamma c orrectionisus ually as adv a nt ageous asin8-bit format s.
Usual ly  8- b it PP M f ormat  store s  color s in nonl in e ar for m at, con v e nt iona lly CIE Rec. 709f or red, green and  blue,  a d ju s t edby the CIE R ec . 709 gamma t r an s f e r f u nction. Howev er it is ve r y c ommonto  st o re col or us in g  sR GB color sp ace,  or somet imes u s ing lin e ar colo r spac e.The re i s  n omet ad a tai nthe fil e to ind ic at e whi ch f o r m a t is  be ingused. 

PBM example 
Asimp l e e xampl e ofthePB M for mat is  as f ol lows (there isa ne wline cha rac te r a tthe e n d of e ach  li ne):

P1
 # T h isis a n  e xample bitmap of t he l et ter "J" 6 10000  0 1 0
00 0  0 1 0 
 0 0  0 0 10
 0 0 0  0 1 0  0  0  0 0 10 0 0 0  0  10
1 0 0 0 10
 0 1  1 1 0 0 
 0 0 0 0 0 0
 0 0 0 0 0 0

The st r in g P1 iden tif ies the fil e fo r mat.  The nu mbe r  sign  intr od u ce s  a comment. The nex ttwo nu mbers  give the wid th and the h e ight. Th en f o ll o ws the matrixwiththe pixelv alues (i n the  monochr ome caseh e re, only  ze ros  an d o n e s) .

It is notr e quir ed  that p ixe ls arenic ely  li ned  u p, the fo rmat ign or es  w hi tes paces and line fe eds  i n t he da t a sect ion,alth ou gh it' s recom m en d e d th at  n o li neis  long er t h an76 char acters. T hef ollo wi ng  displa ys the same i ma ge:

 P1
#Thi s is a n examplebitmap of the letter "J " 
 6 10 00 00100 0001 000001000 001 000001 000 0 010100 010011 10000 00 000 0 0 000
H e re  is  t he resulti n g  im age: 
Her e it is  again magnified 2 0  ti mes:
 

Notetha t a0 si gni f ie s  awh i tep i xel, and a 1 si gnifies abl a ck  pixel. Th i s i sin cont rast to  theo ther fo rmats, wh ere highe rvalu e s  si gnify brig hter pix els.

The P4 bi n ar y for mat  of th esam e ima ge rep r ese nts e ach pi xe l with  a si ng le bit,packing 8 pixels per by te, wi th th e f irst pixe l a s  th e most si gnif icant bit.   E xtr a bit s a r e add ed a t  t hee nd of  eac h  row to f i ll  aw h ol e byte.

PG M e xam ple The PGM an d PP M formats (both A S CII and binary  ver s i ons ) h a ve a nadditional par ame te r 
't store_information which_color space it is_using, and_must_be cared_of_by the user_or other software._16-bit PGM almost always_is stored as_linear,_as gamma correction is usually as advantageous as in 8-bit formats.

Usually 8-bit PPM format_stores_colors in_nonlinear_format,_conventionally CIE Rec. 709 for_red, green and blue, adjusted_by _the CIE Rec. 709 gamma transfer function. However_it_is very common_to store color using sRGB color space, or sometimes_using linear color space. There is_no metadata in_the_file_to indicate which format_is being used.

PBM example
A simple example_of the PBM format is as_follows (there is a newline character at_the end of each line):

 P1
_# This is an example_bitmap of_the letter "J"
 6 10
_0 0 0_0 1_0
 0 0_0 0 1 0
 0 0_0 0 1_0
 0 0 0 0 1_0
_0 0 0_0_1_0
 0_0 0 0_1_0
 1_0_0 0 1 0
 0 1_1_1 0 0
 0 0 0 0_0 0
 0 0_0_0 0 0

The string_P1 identifies the file format._The number sign introduces a comment._The next_two numbers_give the width and the height. Then follows the matrix with_the pixel values (in the monochrome_case here, only zeros_and ones).

It_is_not required that_pixels_are nicely_lined up, the format ignores whitespaces and_linefeeds in_the data section, although it's recommended_that no line is_longer_than 76 characters. The following displays_the same image:

 P1
 # This_is an example bitmap of_the_letter_"J"
 6 10
 000010000010000010000010000010000010100010011100000000000000

Here is_the resulting image:
 

Here it is_again magnified 20_times:
 

Note that a 0 signifies a_white_pixel, and a 1 signifies a_black_pixel. This is in contrast to_the_other_formats, where higher values signify_brighter pixels.

The P4 binary format of_the same image represents each pixel with a single_bit, packing 8_pixels per byte, with the_first_pixel_as the most significant bit.  Extra bits are added_at the_end of each_row to fill a whole byte.

PGM example 
The PGM and_PPM formats (both ASCII and binary versions)_have an additional parameter