Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import os
- import math, operator
- for root_n, dirs_n, filenames_n in os.walk('noisy'):
- for f_n in filenames_n:
- if f_n <> ".DS_Store":
- path_n = os.path.join(root_n, f_n)
- noisy = Image.open(path_n,'r')
- noisy_hist = noisy.histogram()
- for root, dirs, filenames in os.walk('covers'):
- for f in filenames:
- if f <> ".DS_Store":
- path = os.path.join(root, f)
- cover = Image.open(path,'r')
- cover_hist = cover.histogram()
- rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, noisy_hist, cover_hist))/len(noisy_hist))
- if rms == 0.0:
- print("%s %s" % (f_n,f))
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement