[Image-SIG] Re: PIL bit decoder

Fredrik Lundh fredrik@pythonware.com
Tue, 13 May 2003 23:04:45 +0200


David Smith wrote:

> Evidently, I don't understand something about PIL's
> bit decoder.  I have an 11-bit image to read, with
> pixels packed so that they cross byte boundaries.  The
> documentation says that the bit decoder reads into
> floating point images.  I figured that reading 11-bit
> data should produce floating point pixels with integer
> values from 0.0 to 2047.0.  But I am getting littly
> teeny pixels instead, like 1e-15 and
> 7.3789486648102458e-021.  It also appears that only
> the low-numbered rows are receiving data.  What am I
> missing?

a working PIL install?

try this:

    import Image

    im = Image.fromstring("F", (10,10), "*"*1000, "bit", 11, 0, 0, 0, 0)

    print im.mode
    print im.size
    print list(im.getdata())

on my box, this prints:

    F
    (10, 10)
    [337.0, 650.0, 1108.0, 674.0, 1301.0, 168.0, ..., 1108.0, 674.0]

</F>