PPM File Input

O

omar

Hi,

I'm trying to read a PPM file into an array so that I can modify it
within a program. A normal PPM file, for those of you who are
unfamilliar, should look like this:

0 0 0 0 0 0 0 0 0 15 0 15
0 0 0 0 15 7 0 0 0 0 0 0
0 0 0 0 0 0 0 15 7 0 0 0
15 0 15 0 0 0 0 0 0 0 0 0

Where each of the integers represent an R,G, or B value. For some
reason, though, whenever I view a PPM file created by djpeg (the jpeg
image decompression tool), it gives something like this:

A4JB5JB5LC4LC4MA1MA1MA1NB2OC3QD4P>0U?

Why are the two files different, and how can I convert the
djpeg-produced ppm file to a nice, neat array?

Thank You,

Omar
 
J

John C. Bollinger

omar said:
I'm trying to read a PPM file into an array so that I can modify it
within a program. A normal PPM file, for those of you who are
unfamilliar, should look like this:

0 0 0 0 0 0 0 0 0 15 0 15
0 0 0 0 15 7 0 0 0 0 0 0
0 0 0 0 0 0 0 15 7 0 0 0
15 0 15 0 0 0 0 0 0 0 0 0

Where each of the integers represent an R,G, or B value. For some
reason, though, whenever I view a PPM file created by djpeg (the jpeg
image decompression tool), it gives something like this:

A4JB5JB5LC4LC4MA1MA1MA1NB2OC3QD4P>0U?

Why are the two files different, and how can I convert the
djpeg-produced ppm file to a nice, neat array?

There are two "flavors" of PPM, "raw" and "plain". You have described
the "plain" format, which is in fact only rarely used. The "raw" format
consists of some ASCII metadata followed by a binary raster of pixel
data, and very likely that is what you're seeing. Consult the PPM
documentation for details ("man ppm" may give you what you want). Note
also that the same sort of thing applies to the related PGM and PBM formats.


John Bollinger
(e-mail address removed)
 
O

omar

Thanks for the response.

Do you know of any programs that could convert from the raw to the
plain format? I'm going to try and write somethig that does the
converting, but it would be a lot easier if there was already some code
out there to do it.
Is it as simple as converting ascii to regular integers?

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top