[Image-SIG] Re: less common modes

Fredrik Lundh fredrik at pythonware.com
Mon Sep 20 00:49:44 CEST 2004


Grant Goodyear wrote:

> I'm trying to write a PIL decoder for MRC files (which seems to be
> a common format in cryo-electron microscopy).  The format is pretty
> simple: a 1024-byte header followed 8-bit signed integers, 16-bit
> unsigned short (big-endian) integers, or 32-bit big-endian floats.
> My test data involves the floats, so I've been trying to use
> mode = "F;32BF" with no success (using PIL 1.1.5a5, btw):

> Am I missing something obvious?

"F;32BF" isn't an image mode, it's a format descriptor for the "raw"
codec.   to use it, set the image mode to "F" and pass in "F;32BF" as
the first argument to the raw codec; something like this should work:

    if mrcmode == 0:
        rawmode = "I;8S"
        self.mode = "I"
    elif ... etc
        ...
    elif mrcmode == 3:
        rawmode = "F;32BF"
        self.mode = "F"
    elif ...

    self.tile = [("raw", (0,0) + self.size, offset, (rawmode, 0, 1))]

</F> 





More information about the Image-SIG mailing list