Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import math
- import operator
- from PIL import Image
- original = r"C:\working\exiftool\example\for_checks\cover_original.jpg"
- exif_fixed = r"C:\working\exiftool\example\for_checks\cover_exif.jpg"
- hand_fixed = r"C:\working\exiftool\example\for_checks\cover_hand_fixed.jpg"
- small_line = r"C:\working\exiftool\example\for_checks\small_line.jpg"
- all_black = r"C:\working\exiftool\example\for_checks\all_black.jpg"
- inverted = r"C:\working\exiftool\example\for_checks\inverted.jpg"
- def find_rms(image1, image2):
- h1 = Image.open(image1).histogram()
- h2 = Image.open(image2).histogram()
- rms = math.sqrt(reduce(operator.add, map(lambda a,b: (a-b)**2, h1, h2))/len(h1))
- print "rms: {} - Source images: {} and {}".format(rms, os.path.basename(image1), os.path.basename(image2))
- find_rms(original, original)
- find_rms(original, exif_fixed)
- find_rms(original, hand_fixed)
- find_rms(original, small_line)
- find_rms(original, all_black)
- find_rms(original, inverted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement