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

Luis Pedro Coelho lpc@cmu....
Mon Oct 25 17:27:05 CDT 2010


Hi Zach,

That's a good catch! I'll fix the code (both on my distribution and on 
scikits.image [I'll fix my branch and send a pull request upstream]).

I prefer to have the code be a bit more complex with the extra if than slow it 
down (the difference is easily measurable in case someone is worried about 
premature optimisation).

Thank you,
Luis

On Monday, October 25, 2010 08:56:13 am Zachary Pincus wrote:
> 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/f04f224079f2ed9fc70bd8b25d3fab2c
> 0b2df622 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/325b59c59ade2a09f2b788f26801
> bb3f8d8a0d5e
> 
> 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
> 
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20101025/94526d4e/attachment.bin 


More information about the SciPy-User mailing list