0
嘿傢伙們,我正在爲我的comp sci課程做一份作業,我不知道我在哪裏會出錯。該函數應該拍攝兩張圖片pic1和pic2,並返回它們的不同之處。在Python中比較兩張圖片需要幫助
繼承人我有什麼
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)
我運行一個文件SELF_TEST(這是給我們爲我們的任務),但我一直在這裏得到一個錯誤,誰能幫助?
*注:Simple_difference是另一個函數I事先寫的是,在兩個畫面發現像素之間的距離和規模相應
告訴我們那是什麼錯誤,如果你需要一些幫助 – 2010-10-13 20:00:53
你如何量化差異?你會得到什麼錯誤? – JoshD 2010-10-13 20:01:37
你在使用什麼庫?不*看起來*像PIL ... – 2010-10-13 20:04:08