memory problem

                    Hi, on a pc with linux and 512M of

    > RAM, I have a problem of memory when I'm using matplotlib.

    > from pylab import * imshow(zeros((2000,2000))) show()

    > is working but:

    > 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

Ok I didn't know that it was a well known problem, thanks to point me a solution. The image is grayscale because it's a fits file. I'm doing some publicity for matplotlib in my department and someone ask me to plot this peculiar image but we became to have some big CCD (or ccd mosaic) or create some simulation with big CCD.

It's good idea if that will be possible to have inside matplotlib the down-sampling :slight_smile:

I saw in the same time a small problem with matshow. I thought that this command preserve the aspect of the figure. It's true but not if you're using the colorbar() function at the same time.
thanks,

N.

a=zeros((20,20))
a[3,4] = 4 # if the image is totally flat colorbar give an error
matshow(a)
colorbar()

John Hunter wrote:

···

"Humufr" == Humufr <humufr@...136...> writes:
           
   > Hi, on a pc with linux and 512M of
   > RAM, I have a problem of memory when I'm using matplotlib.

   > from pylab import * imshow(zeros((2000,2000))) show()

   > is working but:

   > 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