Image to numeric array

Claudio Grondi claudio.grondi at freenet.de
Mon Feb 13 12:02:26 EST 2006


Diez B. Roggisch wrote:
>>Is there a difference between the 'Numeric' and 'numeric' module?
>>I have on my system only Numeric... And this has no function like
>>'from_image'.
> 
> 
> I actually didn't check that - I just wanted to point the OP to the
> numeric-module(s) available, as he suggested that 
> 
> 
>>The usual way of doing such things is to use PIL (Python Image Library) 
>>to load the image from file, then export it from PIL to a Python string 
>>in order to import from this string to an array of the targeted 
>>numerical module.
> 
> 
> I'd go for the getdata() method instead.
Yes, you are right.
Sorry, I should have checked it in source code before posting just from 
my memory. Usage of .tostring() was my first approach - I have replaced 
it later by .getdata() because of speed issues (we are speaking here 
about methods of the Image module available after installation of PIL).
As I have experience with numarray only, I can't help here directly with 
  a code example for Numeric.

Claudio
> 
> 
>>Really curious if there is a direct way in any of the numerical 
>>packages, as it would save the time and effort of unnecessary 
>>conversions from PIL, ImageMagick or from other image libraries.
> 
> 
> Whatever module is capable of converting needs to know how to read images -
> either by itself, or by means of another module. 
> 
> 
> I know for sure that pygame supports retrieving pixel-data as array.
> 
> Diez



More information about the Python-list mailing list