Picture Contrast

from the PIL Import Image 
Import Math
Import operator
the reduce from functools Import
DEF Compare (pic1, pic2):
'' '
: param pic1: Image 1 Path
: pic2 param: Image 2 Path
: return: return results of the comparison
' ''
image1 = Image .Open (pic1)
image2 = Image.open (pic2)

histogram1 = image1.histogram ()
histogram2 = image2.histogram ()

Differ = Math.sqrt (the reduce (operator.add, List (Map (the lambda A, B: (ab & ) ** 2, histogram1, histogram2))) / len (histogram1))

Print (Differ)
return Differ

Compare ( 'D: /1.png', 'D: /1.png')

Guess you like

Origin www.cnblogs.com/Be-your-own-hero/p/11367860.html