[Image-SIG] read image into an array

Marcin Szkudlarek marcin.szkudlarek at gmail.com
Thu Feb 9 14:03:56 CET 2006


Hello everyone,

I'm doing image processing on 8-bit gray color images.
This code loads the data into array:

    self.im     = Image.open("example.bmp")
    self.image  = zeros([self.im.size[0], self.im.size[1]], Int)

    i = 0
    while(i < self.im.size[0]):
      j = 0
      while(j < self.im.size[1]):
        self.image[i,j] = self.im.getpixel((i, j))
        j=j+1
      i=i+1

Is there a faster way to do it? For example using getdata() method of Image
class?
And later how I can convert above array into Image without using slow
putpixel method?

Marcin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/image-sig/attachments/20060209/3bab19cf/attachment-0001.html 


More information about the Image-SIG mailing list