Christopher Tyler

Finding Differences in Images with Python and Pillow

Mike’s article about using Pillow to find differences in images.

In his example, you could output the difference using a simple function:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from PIL import Image, ImageChops

def diff(image_path_one, image_path_two, output_path):
    image_one = Image.open(image_path_one)
    image_two = Image.open(image_path_two)
    image_three = ImageChops.difference(image_one, image_two)
    image_three.save(output_path)

if __name__ = "__main__":
    diff("yellow_butterfly.jpg","watermarked_butterfly.jpg")

I can see how this could be useful to do a compare of a given picture like what Mike did or take a image of a chart and compare the differences as well.

<< Previous Post

|

Next Post >>

#Mike Driscoll #Python #Pillow