''' Purpose: generate random colors over a user-specified selfie ''' from PIL import Image import random from image_support import get_selfie, set_pixel, get_size, show # get selfie of interest img = get_selfie( "jpc" ); # get selfie dimensions w, h = get_size( img ) for x in range( 0, w, 2 ) : # examining pixels in a rightward sweep for y in range( 0, h, 2 ) : # process for a given x from top to bottom # use the x and y combination as spot on the picture spot = ( x, y ) # generate a random color for the spot r = random.randrange( 0, 256 ) g = random.randrange( 0, 256 ) b = random.randrange( 0, 256 ) c = ( r, g, b ) # set the img pixel at spot to color c set_pixel( img, spot, c ) # show image show( img )