[Image-SIG] Help on accessing pixels values

bestdomdom bestdomdom at neuf.fr
Fri Jun 23 18:55:26 CEST 2006


Hello Everybody,

First please forgive me for asking such a basic question but I am a newbie
to Python, to programming and I am alone with my IT worries.
I would like to access pixels values in order to make some computations but
with the 1.1.6 PIL, I don't understand.
As an example, here is what I do:

import Image
im = Image.open("myimage.jpg")
pixel=im.load()
print pixel [0,0] # to see the value of pixel[0,0]
x=(0,0,0) #black in RGB
pixel[0,0]=x # to set the first pixel in black

This gives me an error : "TypeError: unsubscriptable object".
I believe I am doing something wrong ;(

May someone just explain me with such an example what I should do.
Thanks in advance for your help

Dom



More information about the Image-SIG mailing list