PIL: Getting a two color difference between images

Lie Ryan lie.1296 at gmail.com
Sat Oct 25 03:59:41 EDT 2008


On Fri, 24 Oct 2008 14:51:07 -0500, Kevin D. Smith wrote:

> I'm trying to get the difference of two images using PIL.  The
> ImageChops.difference function does almost what I want, but it takes the
> absolute value of the pixel difference.  What I want is a two color
> output image: black where the image wasn't different, and white where it
> was different.  Right now I get black where it wasn't different, and
> abs(image1-image2) where it was different.
> 
> It would be nice if I could specify the colors for difference and no
> difference.  This sounds like it should be easy, but I just don't see
> how to do it.
> 
> --
> Kevin D. Smith

Use the Image.point()

Also, see PIL Handbook: http://www.pythonware.com/library/pil/handbook/
index.htm




More information about the Python-list mailing list