Skip to content

Instantly share code, notes, and snippets.

@jamesnvc
Created October 2, 2010 22:06
Show Gist options
  • Save jamesnvc/608042 to your computer and use it in GitHub Desktop.
Save jamesnvc/608042 to your computer and use it in GitHub Desktop.
# Note that these are just samples, and may not work unmodified...
# Comparing pictures stored in picture_a and picture_b
# Assumes:
# 1. You've already resized the images to the same size
# 2. The width & height of the images are stored in variables of the same names
# 3. The images have been normalized to the same average intensity
# 4. You've written a function named 'intensity' to calculate the intensity of
# a given pixel
def DiffPics(picture_a, picture_b):
diff = 0
for x in range(width):
for y range(height):
pix_a = media.get_pixel(picture_a, x, y)
pix_b = media.get_pixel(picture_b, x, y)
diff += abs(intensity(pix_a) - intensity(pix_b))
return diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment