[sane-devel] "gamma" and "bayer" ? What are they?

der Mouse mouse@Rodents.Montreal.QC.CA
Thu, 12 Jun 2003 16:22:35 -0400 (EDT)


>> It seems you are interpreting the hex dump as raw data...
>> One byte is 2 hex digit, and the whitespace is here for readability.
> Again, yes. My point was that a string of bytes equal in number to
> the number of pixels in the picture will give precisely no good
> result, but that on the other hand putting the text fomat of same
> data, obtained by suitable editing of the log file, will give a
> picture provided one only puts a ppm header on the top.

Your previous description made no sense to me.  While reading this, I
had a brainflash, and I think I know what's going on.

When you have one byte per pixel, you _do_ have a picture, it's just
that it's a colourmapped picture, and you don't have the colourmap to
go with it, so it makes no sense.  Prepend a pgm (not ppm) header and
it will be displayable, but it will make little sense - it may or may
not be possible to see the original image in it; this amounts to using
a gray-ramp colourmap instead of the colourmap the image should have.

When you expand it to three bytes per pixel and prepend a ppm header,
ppm takes those three bytes as the red, green, and blue bytes for that
pixel, so you get one ppm pixel per picture pixel and you get
something.  This amounts to imposing a different colourmap, one that
looks like

	index	red	green	blue
	0	48	48	32	("00 ")
	1	48	49	32	("01 ")
	...
	185	98	57	32	("b9 ")
	...
	255	102	102	32	("ff ")

which is why the picture looks as though its colours have been
scrambled: they have been!

Some of pixels may effectively use colourmap entries with 10 instead of
32 for the blue value, if you use newlines instead of spaces for some
of the inter-byte spacing.

>> But with 1 byte per pixel the image should be interpreted as
>> greyscale I think
> This is not what happens.  I judge by the results.

If you prepend a ppm header, no, it will perforce be taken as colour.
But if you use a pgm header, it will be taken as grayscale and you
should get something semi-sensible.  (I don't know enough about bmp to
comment on the results you get with bmp headers.)

There unfortunately is no format in the pbm/pgm/ppm series that handles
colourmapped images, as far as I know.  To get sensible pictures in p*m
format, you'll need to figure out what the colourmap the camera is
assuming the image will be used with is.  You may be able to do this by
taking pictures of washes of each primary, from black to full
brightness, and watching how the byte values change....

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B