''' Purpose: generate an random colors over random spots on a user-specified selfie ''' from PIL import Image import random import image_support # get selfie of interest reply = input( "Enter computing id: " ) who = reply.strip().lower() img = image_support.get_selfie( who ); # get selfie dimensions w, h = img.size # get number of pixels in img nbr_pixels = w * h # get number of pixel mutations n = nbr_pixels // 2 for i in range( 0, n ) : # change n random pixels of img # generate a random location x = random.randrange( 0, w ) y = random.randrange( 0, h ) spot = (x, y ) # generate a random colors 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 img.putpixel( spot, c ) # show image img.show()