Exemplo n.º 1
0
def test_normalize_brightness():
    '''Test the function normalize_brightness in img_manip.'''
    
    new_pic = create_pic(4, 4)
    new_pic_normalized= img_manip.normalize_brightness(new_pic)
    
    #The average brightness of new_pic_normalized will likely not be exactly 128 
    #because the RBG values are rounded to integer values after being multipled 
    #by the normalization factor, so the function tests for a difference of less 
    #than 2 rather than for equality.
    new_avg_brightness = avg_bright.average_brightness(new_pic_normalized)
    assert abs(new_avg_brightness - 128) < 2, \
           "normalize_brightness failed to normalize the picture's average \
Exemplo n.º 2
0
def normalize_brightness_GUI (label):
    '''Implement the function normalize_brightness from img_manip.'''
    
    #Clear all the temp pics in front of the current pic current_pic
    global temp_label
    global current_pic
    temp_label = temp_label[0:current_pic+1]
    #Implement the function normalize_brightness .
    label.picture = img_manip.normalize_brightness(label.picture)
    #Keep a copy of the current pic for the functions Undo and Redo
    temp_label.append(label.picture)
    current_pic += 1
    #update the label
    update_label(label)