Comparing two images using PIL - Raspberry Pi Forums
i'm trying compare 2 images , number value. googled , found example https://stackoverflow.com/questions/192 ... -linux-way.
valueerror need more 0 values unpack. i'm not sure why. everyone
valueerror need more 0 values unpack. i'm not sure why. everyone
code: select all
import math, operator pil import image def compare(file1, file2): image1 = image.open("/home/pi/desktop/1.jpg) image2 = image.open("/home/pi/desktop/2.jpg") h1 = image1.histogram() h2 = image2.histogram() rms = math.sqrt(reduce(operator.add, map(lambda a,b: (a-b)**2, h1, h2))/len(h1)) return rms if __name__=='__main__': import sys file1, file2 = sys.argv[1:] print compare(file1, file2)
you comparing histograms of 2 images, not images themselves. if take copy of 1 image, rotate it, mirror or randomly permute individual pixels, histogram not change , both images classified identical.
raspberrypi
Comments
Post a Comment