CS106L Introduction to Computing and Programming in Python (Lab)
Summer 2012

Lab 8: Dealing with digital images

Info on Lab 7 assignment
The text from the IDLE shell where we did our work on Lab 7's assignment: lab7.txt
Info on Lab 8 assignment
The text from the IDLE shell where we did our work on Lab 8's assignment: lab8.txt

Installing JES

  1. Go here and download the newest JES zero-based indexing file (or click jes-4-2-1-windows.zip for the current version). Unzip it and follow the next step.
  2. Copy the folder called "JES" from inside the Windows folder onto your C: drive.
  3. Open the new JES folder on your computer.
  4. Note: There is no installation process for JES.
  5. To open JES, double-click on the snake icon titled "JES". It may take a (possibly very long) minute for JES to get started.

Concepts

Assignment

Solution
  1. 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.
  2. 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
    
  3. 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
    
  4. 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
    
  5. 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
    



Last modified: 8/18/09
By: David O'Gwynn