[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Easy PIL question

Adam W.

2/16/2008 4:36:00 PM

I know there is an easy way to do this, but I can't figure it out, how
do I get the color of a pixel? I used the ImageGrab method and I want
to get the color of a specific pixel in that image. If you know how
to make it only grab that pixel, that would also be helpful.
Basically I'm trying to make a:
if pixel == color:
do_this()
else:
pass

And have it do this as fast as my pc can handle (that is why only
grabbing 1px would be helpful)
6 Answers

Gary Herron

2/16/2008 5:14:00 PM

0

Adam W. wrote:
> I know there is an easy way to do this, but I can't figure it out, how
> do I get the color of a pixel? I used the ImageGrab method and I want
> to get the color of a specific pixel in that image. If you know how
> to make it only grab that pixel, that would also be helpful.
> Basically I'm trying to make a:
> if pixel == color:
> do_this()
> else:
> pass
>
> And have it do this as fast as my pc can handle (that is why only
> grabbing 1px would be helpful)
>
Try image.getpixel((x,y)) to retrieve the pixel at (x,y).

Gary Herron


Bearophile

2/16/2008 8:15:00 PM

0

Gary Herron:
> Try image.getpixel((x,y)) to retrieve the pixel at (x,y).

If the OP needs to access many pixels, then he can use the load()
method on the image object, and then read/write pixels (tuples of 3
ints) using getitem []

import Image
im = Image....
img = im.load()
img[x,y] = ...
.... = img[x,y]

I don't know why the image object itself can't have the __getitem__/
__setitem__

Bye,
bearophile

Tell it like it is.

4/19/2011 10:39:00 PM

0

pm, rst0wxyz <rst0w...@yahoo.com> wrote:
>
> > > > > On Apr 19, 1:41 pm, rst9 <rst9w...@yahoo.com> wrote:
> > > > > > Moving back to Africa is NOT the answer.  That was tried already.  The
> > > > > > country of Liberia was created by the people once were slaves in
> > > > > > America.  Many Black-Americans have tried going back to Africa to
> > > > > > live, only to find death, Stokely Carmichael moved to Africa and died
> > > > > > of cancer.
>
> > > > > That's all true. But in today's virtual world and the real world that
> > > > > generation n understands, they really  have the best of all of it.
>
> > > > Do we really have the best?  Do we know what the best is?  My answer
> > > > is, the best is alway the future generations to come.
>
> > > > >                     It's a remarkeable story, of a family finding
> > > > > peace and fulfillment,
>
> > > > I wonder how many families can say they have found peace and
> > > > fulfillment.
>
> > > > > in a real community in a village in a
> > > > > beautiful, unspoiled part of the real world,
>
> > > > Unsoiled part of the world?  I wonder where that is!!!
>
> > > > > while in touch with the
> > > > > global virtual world.
>
> > > > No, we are a world apart.  That is why we have wars.
>
> > >                    We have wars because there is no communication.http://weblog.liberationmagazine.com/2011/03/panther-in-afr......
> > > My family moved to California when they cut down all the orange groves
> > > in Orange County in the fifties, and turned them into housing tracts
> > > on quarter acre lots. There were so many crows living off them oranges
> > > and breeding in the trees that the sky darkened as they flew over
> > > twice a day.- Hide quoted text -
>
> > > - Show quoted text -
>
 http://www.liberatormagazine.com/2011/03/panther-in-af...
kansas-city-to.html
> oughta work this time I changed liberation to liberator.
>
>
>
> > It/s an inspiring story of an American family that overcame oppression
> > in the USA in the sixties, by founding something better in a real
> > community in Tanzania, Africa..- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

at "film"
press the mouse button
Now press it again at
Black Panther
on all that print.

rst0wxyz

4/19/2011 11:26:00 PM

0

On Apr 19, 2:48 pm, "Tell it like it is."
<DanielAlbertDesfos...@yahoo.com> wrote:
> On Apr 19, 5:02 pm, rst0wxyz <rst0w...@yahoo.com> wrote:
> > No, we are a world apart.  That is why we have wars.
>
>                    We have wars because there is no communication.http://weblog.liberationmagazine.com/2011/03/panther-in-afr......
> My family moved to California when they cut down all the orange groves
> in Orange County in the fifties, and turned them into housing tracts
> on quarter acre lots. There were so many crows living off them oranges
> and breeding in the trees that the sky darkened as they flew over
> twice a day.

I got news for you. Orange Country is still California. Where did
you move from?


rst0wxyz

4/19/2011 11:29:00 PM

0

On Apr 19, 2:57 pm, "Tell it like it is."
<DanielAlbertDesfos...@yahoo.com> wrote:
> > On Apr 19, 5:02 pm, rst0wxyz <rst0w...@yahoo.com> wrote:
>
> >                    We have wars because there is no communication.http://weblog.liberationmagazine.com/2011/03/panther-in-afr......
> > My family moved to California when they cut down all the orange groves
> > in Orange County in the fifties, and turned them into housing tracts
> > on quarter acre lots. There were so many crows living off them oranges
> > and breeding in the trees that the sky darkened as they flew over
> > twice a day.
>
> http://www.liberationmagazine.com/2011/03/panther-in-africa......
> It/s an inspiring story of an American family that overcame oppression
> in the USA in the sixties, by founding something better in a real
> community in Tanzania, Africa..

Sounds like you are an African American moved to Tanzania, Africa to
live for good.
Is that right?



rst0wxyz

4/19/2011 11:33:00 PM

0

On Apr 19, 3:03 pm, "Tell it like it is."
<DanielAlbertDesfos...@yahoo.com> wrote:
>  http://www.liberatormagazine.com/2011/03/panther-in-africa-.......
> oughta work this time I changed liberation to liberator.

Yep!!! you changed it. I can't get the earlier links, but I can get
the later links.