예제 #1
0
def convert_to_greyscale_GUI (label):
    '''Implement the function convert_to_gryescale 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 convert_to_greyscale.
    label.picture = img_manip.convert_to_greyscale(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)
예제 #2
0
def test_convert_to_greyscale():
    '''Test the function convert_to_greyscale in img_manip.'''
    
    new_pic = create_pic(4, 4)
    new_pic_grey_scale = img_manip.convert_to_greyscale(new_pic)
    
    #Test if the RGB value of each pixel in new_pic_grey_scale is equal. If not,
    #the boolean grey_scale is made False.
    grey_scale = True
    for pix in new_pic_grey_scale:
	red = pix.get_red()
	green = pix.get_green()
	blue = pix.get_blue()
	if red != green or green != blue or red != blue:
	    grey_scale = False
    
    assert grey_scale, \
           "covert_to_grey_scale failed to equalize the RGB component of each \