[Image-SIG] Fast cropping

Guy K. Kloss g.kloss at massey.ac.nz
Thu Jan 8 03:10:41 CET 2009


On Thu, 08 Jan 2009 14:18:19 cab938 at mail.usask.ca wrote:
> I have the need to break a single large image up (3 colour bands) into a
> series of smaller images in a grid-like fashion.  The code we have written
> write now works, but it's really slow - we essentially walk around the
> image cropping and loading to return new PIL Image objects.  Any
> suggestions on a faster way? Should I be using fromBuffer() and pixelaccess
> to create my sub-images?  I want Image objects as I use a number of PIL
> methods after that, I just don't know the fastest way to create them.

Have you tried to convert the PIL image into a NumPy image, and then just use 
the slicing operations? After getting those sub-arrays as slices convert them 
back to PIL arrays. Just a thought, as NumPy is actually quite fast, but don't 
know whether it compares to what you're doing now.

Guy

-- 
Guy K. Kloss
Institute of Information and Mathematical Sciences
Te Kura Pūtaiao o Mōhiohio me Pāngarau
Room 2.63, Quad Block A Building
Massey University, Auckland, Albany
Private Bag 102 904, North Shore Mail Centre
voice: +64 9 414-0800 ext. 9585   fax: +64 9 441-8181
eMail: G.Kloss at massey.ac.nz  http://iims.massey.ac.nz



More information about the Image-SIG mailing list