ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
Re: [Image-SIG] Obtaining image data in numarray
by Andrew Straw other posts by this author
Jul 14 2003 1:09PM messages near this date
[Image-SIG] Obtaining image data in numarray | [Image-SIG] obtaining palette data
On Thursday, July 10, 2003, at 09:29  PM, Chuck Bass wrote:

>  I need to look at the image data in an array form (ideally using
>  numarray).  With PIL I could loop over the data and stuff x,y's into a
>  numarray but the speed would be glacial large images.

I'm not the expert, but seeing as no one better qualified has answered:

I don't think C coding is needed, even for decent speed.  Here's Python 
code for Numeric, and I assume there must be something extremely 
similar for numarray.  There are also a number of similar recipes 
floating around.

import Numeric
import Image

def pil2numpy(im):
     if im.mode != 'RGB':
         raise ValueError("Expecting RGB image")

     width, height = im.size

     im_n = Numeric.fromstring( im.tostring('raw','RGB',0,-1), 
Numeric.UnsignedInt8 )
     im_n = Numeric.reshape( im_n, (height,width,3) )
     return im_n


_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:
Chuck Bass
Andrew Straw

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved