[Tutor] Questions about PIL

Chris Hengge pyro9219 at gmail.com
Thu Nov 9 01:18:58 CET 2006


I tried the .tostring again, seems to be working using != instead of is
not... Thanks for that thread link, very helpful.

I'll look more into im.transform and see what I can come up with. I'm not
sure I fully understand what it does, but I'm reading it as I'll remove the
wanted section of im and trash the rest. I'm more-so looking for a way to
maybe divide an image into quantrants for individual manipulation without
having to split and rebuild the image.

My goal with these two features is I'd like to create a way to compare an
image for changes based on an area of the image, rather then the entire
image. Lets use the quadrants for example (mental code).

1,2
3,4
^ this is how the quad appears on the image (upper left, upper right,
etc...)

for space in quad:
    if newpic[space].tostring() != oldpic[space].tostring():
           oldpic[space] = newpic[space]
    else :
           # Dont really care because this [space] isn't important.



On 11/8/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
>
>
> On Wed, 8 Nov 2006, Chris Hengge wrote:
>
> > I'm trying to figure out how to compare im1 to im2 and recognize the
> > difference. I dont care what the difference is...
> >
> > something like
> >
> > if im1 is not im2:
> >    print "Not same"
>
> Do not use 'is' here.  It is not doing any kind of equality testing at
> all.  We had a discussion about 'is' just a few days ago:
>
>      http://mail.python.org/pipermail/tutor/2006-November/050680.html
>
> According to:
>
>      http://www.pythonware.com/library/pil/handbook/image.htm
>
> the im.getdata() function looks interesting.
>
>
> > I've tried im.tostring() but that doesn't ever enter the loop either.
>
> This should have worked.  I'm not sure if you tried comparing
> two strings using 'is' or not.
>
> > Second question is this:
> > Is there a way to divide the screen so I only grab maybe the lower right
> > 200x200 pixels or some such?
> > Or possibly a way to seperate the image into a grid so I could just take
> the
> > grid I wanted?
>
> im.transform() from the documentation link above looks relevant.  Is that
> what you're looking for?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061108/797e740f/attachment.html 


More information about the Tutor mailing list