Created
September 24, 2010 02:50
-
-
Save jamesnvc/594784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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