[Matrix-SIG] PIL and NumPy Relationship

Travis Oliphant Oliphant.Travis@mayo.edu
Mon, 15 Feb 1999 00:07:39 -0600 (EST)


PIL and/or NumPy users:

Thanks to F Lundh and all else who have contributed to the PIL.  It is
a very nice piece of work and a very useful tool for those of us who
use python to look at and display images.  

Since I have only been a python regular for under a year I wasn't
around when the PIL was just getting off the ground and I have a
couple of questions about the relationship between the PIL and
Numerical Python.

I come from a background of using other data analysis environments
like MATLAB and IDL which treat images as an array of numbers.  As a
result I'm a little surprised to see two different objects being
developed in Python that both serve as images.  The Image object in
PIL and the multiarray object in NumPy.  I wondered if someone could
enlighten me as to any advantage of having two separate objects for
the same kind of data.

Personally, I think this creates an unnecessary dichotomy and division
of scarce resources.  I know, for example, that people have written
and will write "image processing" routines that will work on the Image
object and that I would like to apply those same routines to my Array
object but will first have to get the data into an Image object and
then back into an Array object for further processing.  While not
difficult this is not really acceptable if one is trying to use Python
as an interactive analysis environment.

In many cases one deals with an image which is simply a slice through
or projection of a larger array data set.  With a separate Image
object, all of the methods people have and may develop for image
processing (including loading and saving of image types) are
unavailable unless the translation is made first.

What is the possibility of unifying the PIL and NumPy a bit more?  I
know you can translate between the two objects with fromstring and
tostring methods but this is wasteful in both mental effort (in
keeping track of the different objects and .  It would be better, I
think if the PIL were built around the multiarray object already.  I
guess I'm not sure what kind of work this would involve.  Another
possibility is to have the underlying image data be both an Image
object and Multiarray object at the same time (same data area
different headers? in the C-struct)

So, I'm basically asking users of the PIL to tell me if and why they
feel it is necessary to have two different objects to represent images.

I don't mean to sound critical at all.  I'm just offering my
thoughts.  I basically wouldn't care at all except I find the PIL to
be such a useful addition to Python and am also a heavy user of
Numerical Python.  Thanks again to all involved in
its development.

Thanks,

Travis Oliphant



----------------------------------------------------
Travis Oliphant            200 First St SW          
    	                   Rochester MN 55905       
Ultrasound Research Lab	   (507) 286-5293           
Mayo Graduate School	   Oliphant.Travis@mayo.edu