Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
1,465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. import os
  2. import math
  3. import operator
  4. from PIL import Image
  5.  
  6. original = r"C:\working\exiftool\example\for_checks\cover_original.jpg"
  7. exif_fixed = r"C:\working\exiftool\example\for_checks\cover_exif.jpg"
  8. hand_fixed = r"C:\working\exiftool\example\for_checks\cover_hand_fixed.jpg"
  9. small_line = r"C:\working\exiftool\example\for_checks\small_line.jpg"
  10. all_black = r"C:\working\exiftool\example\for_checks\all_black.jpg"
  11. inverted = r"C:\working\exiftool\example\for_checks\inverted.jpg"
  12.  
  13. def find_rms(image1, image2):
  14.     h1 = Image.open(image1).histogram()
  15.     h2 = Image.open(image2).histogram()
  16.     rms = math.sqrt(reduce(operator.add, map(lambda a,b: (a-b)**2, h1, h2))/len(h1))
  17.     print "rms: {} - Source images: {} and {}".format(rms, os.path.basename(image1), os.path.basename(image2))
  18.  
  19.  
  20. find_rms(original, original)
  21. find_rms(original, exif_fixed)
  22. find_rms(original, hand_fixed)
  23. find_rms(original, small_line)
  24. find_rms(original, all_black)
  25. find_rms(original, inverted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement