Eric Firing wrote:
> Tobias Wood wrote:
>> Hi everyone,
>> After getting fed severely fed up with Matlab in recent months I 
>> downloaded Python, Numpy and Matplotlib to try out as an alternative. So 
>> far I'm pleasantly impressed, even if building from source on Mac OS X 
>> is an experience ;) However, I have discovered a couple of problems with 
>> Matplotlib's imread() function and, shall we say, 'esoteric' PNG files. 
>> My research group uses a 12-bit CCD controlled through Labview to 
>> capture high dynamic range image stacks. Often there are ~30 images in a 
>> single data set. These get read into Matlab in one go for processing as 
>> a stack. I tried converting my code over to Python but, after digging 
>> through the _png.cpp source file found the following that are problems 
>> from my point of view:
>>
>> 1) All .png files in imread() are converted to 4-plane RGBA files 
>> regardless of original format. I would prefer greyscale images to return 
>> a single plane.
>> 2) 16-bit PNGs are stripped to 8 bit, losing any extra precision.
>> 3) The significant bits option in the PNG header was not being checked. 
>> Our camera software will automatically save the PNGs at the maximum 
>> bit-depth required to cover the dynamic range in the image, and can sum 
>> images before saving, so pixels can be anywhere from 6- to 16-bits (at 
>> least those are the values I have observed whilst using the camera).
>>
>> I have attached the results of an svn diff after I made an attempt at 
>> correcting these issues. This is the first time I have contributed to an 
>> open source project, so am not sure of the etiquette here. Also, I have 
>> only had Python and Matplotlib for a fortnight so am still unfamiliar 
>> with them and haven't programmed with libpng before so I apologise in 
>> advance if there any stupid mistakes in my code. I am aware that 
>> imread() is a pretty important function in Matplotlib and hence any 
>> changes I suggest would need comprehensive testing. In brief, I made the 
>> following changes:
> 
> Tobias,
> 
> Thank you very much for the patch and the careful explanation.  I'm not 
> the right person to review it, but I expect someone familiar with libpng 
> use in mpl will do so soon.  Mike D. would be a candidate, but I think 
> he will be unavailable for several days.  If you have not gotten any 
> feedback within a week, *please* ping us with a reminder.  If it comes 
> to that, you could do it by forwarding your original message to 
> matplotlib-devel.

Tobias,

I would like to apply your patch, but the test in
examples/tests/pngsuite fails. If you can submit a new patch where this
test passes, and, even better, if a small example 12-bit PNG of yours is
added to the test, I will apply it.

Apart from that, I would echo Eric's thanks for the patch and explanation.

-Andrew

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to