PIL, and Parts of tuples
clp2 at rebertia.com
Mon Apr 13 22:41:11 CEST 2009
On Mon, Apr 13, 2009 at 1:34 PM, Vistro <vistro at vistro.net> wrote:
> I have two problems, and I can't find anything about either of them.
> The first is that PIL does not seem to have any way to search each and every
> pixel for a value, like
> for pixel in img:
> if pixel = ((60, 30), (58, 23), (87 57)):
> see if the pixel is in an acceptable color range. So, say, the 60 above can
> be anywhere from 58-62, but the 30 needs to be between 28-40.
> Is there any way to parse/deal with a value at a specific "slot" in a tuple?
Yes, use subscripting, just like with lists:
the_tuple = (60, 30)#for example
if not (58 <= the_tuple <= 62) or not (28 <= the_tuple <= 40):
#it's out of range, do something
I have a blog:
More information about the Python-list