[Image-SIG] eval & PIL

Christopher Barker Chris.Barker at noaa.gov
Fri Jun 6 18:13:15 CEST 2008


Eric Germaneau wrote:
> Currently, I'm using a double loop in order to covert each 512x512 
> pixels of each images.

It's hard to know without knowing what you are doing with each pixel, 
but it's likely that you could use numpy to manipulate the pixels:

import numpy as np
import PIL.Image as Image

i = Image.open('lena.jpg')
a = np.asarray(i)

Now you can do math with pixels in the array.

When you want a PIL image again:

i = Image.fromarray(a)

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Image-SIG mailing list