# Obamicon.py # # By Deepak Kumar (Bryn Mawr) # Create an Obama-icon style image from any given image. # Based on Shepard fairey's iconic Obama "HOPE" poster. # # How it works # # Each pixel is sampled and placed in one of 4 colors depending # upon its total color saturation value...sum of RGB values. # # It assigns roughly equal intervals for each ofthe 4 colors. You can # play with that to get different effects. from myro import * darkBlue = (0, 51, 76) red = (217, 26, 33) lightBlue = (112, 150, 158) yellow = (252, 227, 166) def main(): # get the picture print "Select a picture..." p = makePicture(pickAFile()) show(p) # process it for pixel in getPixels(p): r, g, b = getRGB(pixel) total = r+g+b if total < 182: setRGB(pixel, darkBlue) elif total < 364: setRGB(pixel, red) elif total < 546: setRGB(pixel, lightBlue) else: setRGB(pixel, yellow) # Display resulting picture repaint() main()