Is try-except slow?
John Machin
sjmachin at lexicon.net
Tue Sep 2 21:45:28 EDT 2008
On Sep 3, 11:00 am, process <circularf... at gmail.com> wrote:
> how could I do getpixel once when x and y s changing?
I was not referring to *calling* im.getpixel, I was referring to
looking up getpixel as an attribute of im. How? See below.
>
> anyway I rewrote and saw I did a lot of stupid stuff. this is fast:
> def getPixels5(fileName):
> im = PIL.Image.open(fileName)
> colors = []
> r, c = im.size
im_getpixel = im.getpixel
> for y in range(0, c):
> row = []
> for x in range(0, r):
> color = im.getpixel((x,y))
color = im_getpixel((x, y))
> row.append(color)
> colors.append(row)
> return numpy.array(colors)
>
> but I don't need it anuyway apparently since there already was such
> methods :)
More information about the Python-list
mailing list