[Numpy-discussion] create a numpy array of images

Friedrich Romstedt friedrichromstedt at gmail.com
Tue Feb 1 11:31:59 EST 2011

2011/2/1 Asmi Shah <asmi.capri at gmail.com>:
> Thanks a lot Friedrich and Chris.. It came in handy to use PIL and numpy..
> :)


> I have one more question: how to avoid the limitation of memoryerror in
> numpy. as I have like 200 images to stack in the numpy array of say
> 1024x1344 resolution.. have any idea apart from downsampling?

In case you *have* to downsample:

I also ran into this, with the example about my 5 images ...
im.resize((newx newy), PIL.Image.ANTIALIAS) will be your friend.

Note, you might take advatage of floating-point images ('F' spec), I
don't know what the trade-offs are here.  'F' most probably takes
4x(8bit), so ...

The PIL handbook does not state what PIL.Image.ANTIALIAS actually
does, we can only hope that it's real sinc interpolation or similar
(if your images are frequency bounded this would be best to my
knowledge).  In this case you do not even lose information as long as
the spacial resolution of the downsampled images is still sufficient
to make the signal frequency bounded.

You might do a FFT (spacial) to check if your images *are* actually
bounded in frequency domain.  I think it does not need to be perfect.

I strongly believe sinc is in scipy, but I never looked for.


More information about the NumPy-Discussion mailing list