<br><div class="gmail_quote">On Tue, Jun 14, 2011 at 1:26 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On 14/06/2011 21:13, kafooster wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
I would like to visualize this data with PIL, but PIL works only with<br>
8bit data. How could I resample my array from 16bit to 8bit?<br>
</blockquote>
<br></div></div>
Multiply the numpy array by a scaling factor, which is<br>
float(max_8bit_value) / float(max_16bit_value).</blockquote><div><br>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.<br>
<br></div></div>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.<br><br><br><br>