Skip to content

Instantly share code, notes, and snippets.

@jamesnvc
Created September 24, 2010 02:50
Show Gist options
  • Save jamesnvc/594784 to your computer and use it in GitHub Desktop.
Save jamesnvc/594784 to your computer and use it in GitHub Desktop.
import media
COLOUR_MAX = 255
COLOUR_MIN = 0
def get_picture():
'''Solicit user input to select a file and load it as a Picture.
Return the Picture.
'''
filename= media.choose_file()
pic = media.load_picture(filename)
return pic
def maximize_red(pic):
'''Maximize the red component of every pixel in the Picture pic.
'''
for pix in pic:
media.set_red(pix, COLOUR_MAX)
def remove_blue(pic):
for pix in pic:
media.set_blue(pix, COLOUR_MIN)
def halve_green(pic):
for pix in pic:
media.set_green(pix, COLOUR_MAX/2)
pic = get_picture()
maximize_red(pic)
remove_blue(pic)
halve_green(pic)
media.show(pic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment