From: John H. <jdh...@ac...> - 2005-04-01 15:34:47
|
>>>>> "Humufr" == Humufr <hu...@ya...> writes: Humufr> Hi, on a pc with linux and 512M of Humufr> RAM, I have a problem of memory when I'm using matplotlib. Humufr> from pylab import * imshow(zeros((2000,2000))) show() Humufr> is working but: Humufr> from pylab import * imshow(zeros((4000,4000))) show() Yes this is a problem. The image module turns everything into an rgba matrix under the hood. This was an early design decision to conserve programmer resources (my time) over memory and CPU. We made it with the knowledge that this couldn't last forever, since someone (you apparently) would eventually need a grayscale image w/o this overhead. Note if you want to colormap this image, then the problem is going to be there regardless. Several releases ago I spent some time hammering on the image module looking for CPU performance gains, with some success. Looks like I'll have to do the same for memory..... Note that agg has a built-in limit of 4096x4096 buffers, and your display device is likely to be much smaller still. I suggest you consider down-sampling your image in numarray before processing passing it to imshow. There are a number of people working on algorithms to down-sample images (I think Maxim, the agg author is one of them, and I think the numarray/stsci people are too). If there is a good agg algorithm to do it, it would be nice to expose is in mpl. JDH |