[Image-SIG] problem in converting pixel data to image file

Ashish Sethi ashishbitsgoa at gmail.com
Wed Aug 20 08:44:55 CEST 2008

thanks for the reply,
I am a noob in python and image processing and really appreciate your
patience with me
and sorry about the 0-16 bit crap
about the garbage data...if that is binary data then shouldn't ppm(p3)
image contain information in ascii (only p6 data contains binary).
Does this mean pil accepts only p6 and not p3 files??
About the use of these files, well i am creating a tool to convert a
veriety of color spaces.
Now i'll be really blunt and tell u the complete detail of the
work...no matter how stupid it makes me look (as if i am not already
looking it!!!)

IF there is a file in ppm format like

3 3
0 0 0   10 10 10  2 2 2
1 1 1   12 12 12  4 4 4
4 4 4   11 11 11  9 9 9

Then isnt this file in RGB 4:4:4 color space as the maximum value that
any of the color components can take is 15 (binary 4 bit)
What my job is to read a ppm(p3) file in RGB 8:8:8 color space where
values are in 0-255 range and change these values to 0-16 range as i
explained earlier.
This much i have acheived...now i need to create another ppm(p3) image
using thes new values (a list 3 member tuples).
Now please explain if their is something wrong in my understanding and
if not please help me in creating the new ppm file

On 8/20/08, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Ashish Sethi wrote:
> > But the thing is I was under the impression that in a ppm image the
> > maximum or the min color value that any of the R,G and B components
> > can take...i.e. if instead of 255 in the file below, if I give 16 then
> > automatically it would imply my color space has changed to RGB 4:4:4
> > as all the color components now would be in the range 0-16 (i.e 4 bit
> > binary...and let me clarify...
> >
> 4-bit binary can hold 0-15 per component, not 0-16.
> 4-bit is also a measurement of the number of bits required to store the data
> on file; a text file that uses 9 bytes per pixel isn't the same thing as a
> 4-bit binary file.  A PPM text file is not a 4-bit file.
> Since you insist on creating 4-bit text files, I'm beginning to suspect that
> you're confusing internal storage with external storage.
> i am repeatedly talking about binary
> > from time to time as I use the color information in binary to
> > clip/zero pad them to change the color space from rgb888 to rgb444 or
> > rgb121212.That is it, not that i wish to save my files in binary
> > format. After doing the above manipulation i convert them back to
> > decimal nos. and save them to the ppm files.)
> >
> who's going to use those PPM files?
> > Also, is it required to register this file as an image file or
> > something, coz I have plenty of such ppm files in my system which pil
> > doesnt recognise as image files. And the ones that it does recognize
> > as image files have garbage data (apart from the header part) when
> > opened in a text editor.
> >
> that "garbage" is binary data and contains the image data.  are you telling
> me that you haven't seen binary data before?
> I'm beginning to feel that this leads nowhere at all; if you want us to be
> able to help, please specify
> 1) what kind of images you plan to convert
> 2) what the intended use for the "4-bit" text files is
> 3) what application you're planning to use for the next step (that is,
>   who's going to read the 4-bit files?)
> </F>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig

More information about the Image-SIG mailing list