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

Zachary Pincus zachary.pincus@yale....
Mon Oct 25 07:56:13 CDT 2010


Hi Luis,

>> Anyway, the only serious change I've made has to do with properly
>> saving 2D uint8 images, which need to have a palette defined for
>> certain formats (PNG maybe? I don't recall...). Anyway, the
>> scikits.image version has diverged in structure somewhat from the one
>> I use internally in my code, but here's the core of the change:
>
> Another change I made was to get rid of some copies and make the  
> Python
> wrapping much faster. This is probably what you're seeing here.


I think that this commit:
http://github.com/luispedro/mahotas/commit/f04f224079f2ed9fc70bd8b25d3fab2c0b2df622
breaks reading of images with an alpha channel, which in the new  
version will get silently discarded. The old version modified the  
array in-place so that the optional alpha doesn't get touched. Your  
version will need to have different code-paths for
BGR and BGRA images, which is of course easy enough to do.

Also, certain image formats require palettes with 8-bit greyscale  
images (this is what I was talking about above), and so images saved  
with FreeImage won't necessarily open correctly without a palette  
defined. This commit to the scikits version (which I sketched out  
before) does that:
http://github.com/stefanv/scikits.image/commit/325b59c59ade2a09f2b788f26801bb3f8d8a0d5e

Zach



On Oct 25, 2010, at 7:20 AM, Luis Pedro Coelho wrote:

> Hi,
>
> On Thursday, October 21, 2010 11:49:21 am Zachary Pincus wrote:
>>> Whatever fixes you make, please remember to contribute them back to
>>> scikits.image!  The plugin is being maintained there as well.
>>
>> Oh gosh, I didn't realize that -- great! (Did you ever diagnose that
>> segfault?)
>
> I made some of the changes to the scikits.image plugin when I  
> "borrowed" this
> for mahotas (my own image processing library [1]).
>
> I did fix one or two bugs in dealing with memory so those might  
> explain the
> random segfaults.
>
> [1] : http://luispedro.org/software/mahotas.
>
>> Anyway, the only serious change I've made has to do with properly
>> saving 2D uint8 images, which need to have a palette defined for
>> certain formats (PNG maybe? I don't recall...). Anyway, the
>> scikits.image version has diverged in structure somewhat from the one
>> I use internally in my code, but here's the core of the change:
>
> Another change I made was to get rid of some copies and make the  
> Python
> wrapping much faster. This is probably what you're seeing here.
>
> HTH
> Luis
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list