-
Read chapter 12 in How to
Think Like a Computer Scientist and work through the examples
there. You will be responsible for understanding what dictionaries
are and how to use them.
-
Write a function that takes a picture object as input and removes
the red from it. Write a similar function for blue and green.
def removeRed(pictureObject):
# uses a loop to remove the red values of
# all the pixels in the picture object
return pictureObject
-
Write a function that adjusts the red value of each pixel in a
picture by a specified amount. Write a similar function for blue
and green.
def adjustRed(pictureObject, amount):
# use a loop to set the red of each pixel (redValue) to
# redValue*amount
return pictureObject
-
Write a function that allows the user to pick which color will be
adjusted and the amount of adjustment.
def adjustColor(pictureObject, color, amount):
# using an if, elif, else construct on color, decide which
# function from the problem above to use to adjust the picture
# object's color by the amount
return pictureObject
-
Using the getPixel function, write a function that prints the
pixel values for a picture object over some specified window into
the picture (i.e. a subpart of the picture).
def printPixels(pictureObject,x0,y0,x1,y1):
# With (x0,y0) defined as the top left corner of the window
# and (x1,y1) defined as the lower right corner, use getPixel
# and a nested for loop using two different range calls to
# print out the pixels in this window
return pictureObject