PIL: Getting a two color difference between images

Kevin D. Smith Kevin.Smith at sas.com
Fri Oct 24 21:51:07 CEST 2008


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




More information about the Python-list mailing list