[SciPy-User] FreeImage <-> numpy IO wrappers

Stéfan van der Walt stefan at sun.ac.za
Thu Oct 21 17:23:51 EDT 2010


On Thu, Oct 21, 2010 at 5:49 PM, Zachary Pincus
<zachary.pincus at yale.edu> > At the end of _array_to_bitmap(array),
right before the return
> statement, I have the following stanza to copy in a greyscale palette:
>
>     if len(shape) == 2 and dtype.type == numpy.uint8:
>       palette = _FI.FreeImage_GetPalette(bitmap)
>       if not palette:
>         raise RuntimeError('Could not get palette of 8-bit greyscale
> image')
>       ctypes.memmove(palette, _GREY_PALETTE.ctypes.data, 1024)
>
> where _GREY_PALETTE is defined globally as:
> # 4-byte quads of 0,v,v,v from 0,0,0,0 to 0,255,255,255
> _GREY_PALETTE = numpy.arange(0, 0x01000000, 0x00010101,
> dtype=numpy.uint32)

I must admit, I haven't looked at this code recently.  Would you be so
kind as to patch the scikits.image version?  I'd appreciate the help!

Thanks
Stéfan



More information about the SciPy-User mailing list