2

My PPM image contains the following :

P6

1200

670

255

ܒNԪjɝ[؋Cц:̈6y5"r-¼,ֈ?Ԛ_݈׵̻֬كڕÒɪxڇՄmxɘl܊؇euί\jĩqÿHqAʻK΃PùG9EʁM͂M΂O̿PɼLȀMǃOǁLƾH»D5A®>ǷFxCٲ;yFƾIǿJʀL»GڲAʂWǯŐĕх՜џᔡ嚪矱Ԫׄ࠘ĝц׶Qfһψ΅e{ڈڗÖܻԡȜׂӐ}˸_hؖ`­u؛dьWЋV̓MͺHυPƽF˂I߼>ٹ6}>س5>Eiuƻ1

and 40000 more lines of illegible code. Is this an encoding issue?

racecarjonathan
  • 1,244
  • 1
  • 11
  • 22
Dionysis Nt.
  • 955
  • 1
  • 6
  • 16

2 Answers2

1

If you want it in ASCII P3 format, you can use ImageMagick, which is in most Linux distros and available for OSX and Windows,iike this

convert yourFile.ppm -compress none output.ppm

Then it will look like this:

P3
70 46
255
48 47 45 50 48 46 54 50 47 56 51 46 58 51 45 57 50 45 56 48 45 57 49 46
56 48 45 56 48 45 55 47 44 53 45 42 52 44 41 53 45 42 53 45 42 49 45 39
49 46 39 52 49 42 55 52 45 57 54 47 63 58 47 70 63 51 74 66 52 76 65 50
...
...
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
0

No, this is completely normal for a mode P6 PPM.

In this mode, only the header is ASCII, the pixels are written as binary data, 8 or 16 bits per sample, pixel interleaved.

It's also possible to have PPM in "plain" or ASCII format, this mode uses P3 as its identifier.

See the PPM spec for more info.

Harald K
  • 26,314
  • 7
  • 65
  • 111
  • 1
    do you have any idea how to read this and seperate the pixcels rgb colors? in c++ r generaly the idea to work on it – Dionysis Nt. Nov 19 '14 at 20:47
  • I've written a complete reader in Java (see my profile for link, if you're interested). I'm no C++ developer, but basically, you just allocate an array of bytes (unsigned 8 bit type), of size `width * height * 3` and then read bytes from the file into the array until the array is filled. The values will follow the layout R1G1B1R2G2B2...RnGnBn (aka pixel interleaved). – Harald K Nov 19 '14 at 21:31
  • It's there, as part of my ImageIO project, see the [PNM module](https://github.com/haraldk/TwelveMonkeys/tree/master/imageio/imageio-pnm). PNM refers to PBM, PGM and PPM together, as these formats are similar. – Harald K Nov 20 '14 at 16:34