Homework 5

[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]

This assignment will be handed out at the end of class on Wednesday, September 22 and is due (electronically submitted) before class starts on Wednesday September 29.

For the problems dealing with pictures, I suggest trying them out on real life pictures - pictures of people, buildings, nature, etc. The website http://coweb.cc.gatech.edu/mediaComp-teach#Python for the textbook has a mediasources.zip file that you can download with sample pictures, if you want to use some of the same pictures that the textbook uses. You can also use your own pictures, pictures from the web, etc.

You should create a single Python file for your submission. It will include the code for the functions you are turning in, and you can include additional explanations as Python comments. If you do not turn in your homework in this way, I will take off points!

  1. (20 Points) For this question, do something "quite cool and fun" with pictures using what we have learned. You could create a logo, banner, or "art" for the Math and CS department webpage (and if it's really good and you give permission we might use it). You could create a creepy halloween-ish picture of yourself (black ears, purple nose, three eyes). You could do some Photoshop-type effect to a picture. Whatever you want. You should turn in your original picture (or pictures if you are combining multiple pictures), your function (or functions if you use more than one), and the picture(s) that are produced. At a minimum, your function must use for loops, and must do something that is not in the book and was not done in class.

    1. (10 Points) Create a function called gradientWB that creates a picture that is a gradient from white to black from top to bottom. The top row should be white, the bottom row is black, and a smooth transition in between. The function takes two inputs, the width and height of the picture that is being created, and the function returns the picture. If you run these commands
        >>> pic = gradientWB(250, 100)
        >>> repaint(pic)
      Then you would see a picture that looks like this:
    2. (10 Points) Create a function called gradientPic that takes a picture as input and makes a gradient out of the picture, with the pixels getting darker towards the bottom. So the pixels on the top row are just as they were before, the pixels on the bottom row are black, and in between they are darker the closer they are to the bottom. If you load the banner image at the top of this webpage (that can be downloaded from ../include/banner.jpg), the picture starts out looking like this: After you run these commands
        >>> pic = makePicture(pickAFile())
        >>> gradientPic(pic)
        >>> repaint(pic)	
      Then you would see a picture that looks like this: