Created
October 2, 2010 23:59
-
-
Save jamesnvc/608126 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smart_difference(pic1, pic2): | |
'''Take two pictures and tests how similar they are. Excuse the terrible docstrings. They need some work | |
''' | |
h1 = get_height(pic1) | |
h2 = get_height(pic2) | |
w1 = get_width(pic1) | |
w2 = get_width(pic2) | |
if (h1 > h2): | |
pic1 = reduce_height(pic1, h1/h2) | |
elif (h2 > h1): | |
pic2 = reduce_height(pic2, h2/h1) | |
if (w1 > w2): | |
pic1 = reduce_width(pic1, h1/h2) | |
elif (w2 > w1): | |
pic2 = reduce_width(pic2, h2/h1) | |
pic2 = adjust_colours(pic2, pic1) | |
return simple_difference(pic1, pic2) | |
def adjust_colours(target_pic, reference_pic): | |
'''Takes target pic and adjusts it's average RGB values to reference pic's RGB values... | |
''' | |
target_red_avg = red_average(target_picture) | |
reference_red_avg = red_average(reference_picture) | |
target_blue_avg = blue_average(target_picture) | |
reference_blue_avg = blue_average(reference_picture) | |
target_green_avg = green_average(target_picture) | |
reference_green_avg = green_average(reference_picture) | |
# get the difference between avg for r, g, b | |
# adjust target's red by r, g, b for all pixels | |
# do the same for blue, green | |
# get the difference between avg for red, g, b | |
def red_average(picture): | |
sum = 0 | |
for every p picture: | |
sum = get_red(pixel) + sum | |
return sum / (h * w) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment