working with raw image files

Dan Stromberg drsalists at gmail.com
Tue Jun 14 17:06:53 EDT 2011


On Tue, Jun 14, 2011 at 1:26 PM, MRAB <python at mrabarnett.plus.com> wrote:

> On 14/06/2011 21:13, kafooster wrote:
>
>>
>> I would like to visualize this data with PIL, but PIL works only with
>> 8bit data. How could I resample my array from 16bit to 8bit?
>>
>
> Multiply the numpy array by a scaling factor, which is
> float(max_8bit_value) / float(max_16bit_value).


I don't know PIL specifics at all, but often 8 bit graphics formats are
palette-based, and 16 bit graphics are often a compressed form of 24 bit rgb
graphics that take advantage of how much the human eye sees various colors.
IOW, for some formats I'm sure scaling will help, but for others I'm sure it
won't.

The O.P. could try rawtopgm and rawtoppm, after attempting the scaling
thing, assuming scaling doesn't help - and hopefully it will.  I believe PIL
understands these NetPBM formats.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110614/b832d43a/attachment-0001.html>


More information about the Python-list mailing list