To rescale you could try using the point method on your image object.
On Jun 21, 2011, at 11:05 AM, Christopher Barker <chris.bar...@noaa.gov> wrote: > Managan, Rob wrote: >> If you are not worried about rounding errors; this command grabs the data, >> and puts it back scaled by 255/65535 and no offset. >> i.putdata(i.getdata(),255.0/np.iinfo(np.uint16).max,0.0) > > yup -- easy with numpy (I actually already did that), but I'm trying to > figure out how to do it with PIL. Maybe there is no reason to, but is sure > seems like it should be something PIL could easily do: > > Convert a unsigned int16 grayscale image to 24bit RGB. > > Thanks, > > -Chris > > By the way, your replies are not making it to the list -- you need to hit > "reply all" or "reply to list". > > > >> On 6/20/11 1:17 PM, "Chris Barker" <chris.bar...@noaa.gov> wrote: >>> On 6/17/2011 8:58 PM, Managan, Rob wrote: >>>> While I am not an expert, it seems you have to use mode = 'F' in from >>>> string. >>>> Presumably then you can convert it to RGB? >>>> All the floating point decoders (libImaging/Unpack.c) have mode 'F' so it >>>> does not find a mode 'RGB' with the rawmode 'F;16' >>>> >>>> Hope this helps. >>>> >>> indeed it did -- I thought I'd triked that, but I guess I got confused >>> about "mode" vs, "raw mode". So now I'm using mode: 'F', and raw mode >>> 'F;16N'. >>> >>> It works without an error, but I'm still lost on how I can then convert >>> the 'F' image to an RGB image. convert('RGB') seems to convert to grey >>> (which I want), but doesn't scale t all -- so a value of 255 in the >>> original uint16 data is white. How can I tell it to re-scalse? >>> >>> see attached code (requires numpy) >>> >>> -Chris >>> > > > -- > Christopher Barker, Ph.D. > Oceanographer > > Emergency Response Division > NOAA/NOS/OR&R (206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > chris.bar...@noaa.gov > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig