Hey guys, Im working on an assignment for my comp sci class, I dont know where Im going wrong here. The function is supposed to take two pictures, pic1 and pic2, and return how different they are.
Heres what I have
def smart_difference(pic1, pic2):
'''Given two Pictures, pic1 and pic2 of any size and colour, return the
difference'''
red = red_average(pic2)
blue = blue_average(pic2)
green = green_average(pic2)
pic1_height, pic1_width = media.get_height(pic1), media.get_width(pic1)
pic2_height, pic2_width = media.get_height(pic2), media.get_width(pic2)
if (pic1_height > pic2_height) and (pic1_width > pic2_width):
new_pic1 = media.create_picture(pic2_width, pic2_height)
new_pic2 = pic2
elif (pic1_height > pic2_height) and (pic2_width > pic1_width):
new_pic1 = media.create_picture(pic2_width, pic1_height)
new_pic2 = media.create_picture(pic2_width, pic1_height)
elif (pic2_height > pic1_height) and (pic2_width > pic1_width):
new_pic1 = pic1
new_pic2 = media.create_picture(pic1_width, pic1_height)
elif (pic2_height > pic1_height) and (pic1_width > pic2_width):
new_pic1 = media.create_picture(pic2_width, pic1_height)
new_pic2 = media.create_picture(pic2_width, pic1_height)
scale_red(new_pic1, red)
scale_blue(new_pic1, blue)
scale_green(new_pic1, green)
scale_red(new_pic2, red)
scale_blue(new_pic2, blue)
scale_green(new_pic2, green)
return simple_difference(new_pic1, new_pic2)
I run a self_test file (which was given to us for our assignment), but I keep getting an error here, can anyone help?
*Notes:Simple_difference is another function I wrote beforehand that finds the distance between pixels in the two pictures and scales accordingly