## Important Note:

On homeworks, you are encouraged to collaborate with your fellow students. However, if you do work with others, you must list the people you worked with in the "Notes to TA" area of the JES turnin window.

 BE SURE TO TURN IN SOMETHING THAT WORKS! If your program fails with an error, it becomes very hard for the grader to give you any points at all! Turn in something that works, even if it doesn't do EVERYTHING, and you will get partial credit. If your program stops with an error without getting anything done, we are hard pressed to give you any points at all.

### Homework 1:

Write a function named posterize (and save it in a file named posterize.py) to accept a picture as input, and posterize it – reduce the number of colors. You'll do this by changing the picture's pixels as follows:
• If the red channel is greater than or equal to 100, set it to 100
• If the red channel is less than 100, set it to 1.
• If the blue channel is greater than or equal to 128, set it to 128.
• If the blue channel is less than 128, set it to 20.
• If the green channel is greater than or equal to 192, set it to 255.
• If the green channel is less than 192, set it to 32.

Turn in your program via JES as "hw1".

Ask questions on Spring 2005 Homework 1 Questions

### Homework 2:

Write a function named makeCollage in a file named makeCollage.py to create a collage of the same image at least four times fit onto the 7x95in blank JPEG. (You are welcome to add additional images, too.) One of those four copies can be the original picture. The other three should be modified forms. One of these forms MUST BE scaling, cropping, or rotating the image. On the other two, you can do any of
• shifting or altering colors on the image,
• and making it darker or lighter.

After composing all four pictures (or REMOVED), you must mirror the ENTIRE canvas, in some direction: Horizontally, vertically, diagonally.

Your single function should make all of this happen–all of the effects and compositing must occur from the single function makeCollage(). IT IS PERFECTLY OKAY FOR makeCollage() TO USE OTHER FUNCTIONS! Your TA will only setMediaPath() and will put all your input pictures in her mediasources directory, and then execute makeCollage()–and will expect to see a collage get generated

Please share your results by uploading the image to the Fall 2004 HW2 Collages gallery. (This isn't a requirement, but we'd love to see them!)

Ask questions on Fall 2004 Homework 2 Questions

### Homework 3:

Write a function named makeAudioCollage in a file named makeAudioCollage.py to generate an audio collage. You must compose together at least two separate sounds (IN TWO SEPARATE FILES), and your result must be at least FIVE seconds long. One of the sounds must appear at least TWICE where it is changed in some way. We must be able to hear your collage from the returned sound. You must create a sound object that has all these pieces in it.

You have a variety of ways that you can change sounds:
• Increasing, reducing, or normalizing volume.
• Reversing sounds.
• Splicing out parts of a sound.
• Change frequency of a sound
• Blending sounds (not discussed in lecture, but in book)
• Any other sound technique discussed in the book or in class

For example, if I composed the words "Mark" and "Guzdial" so that the sound said "Mark kraM Guzdial" (and lasted at least FIVE seconds) that would meet the requirements of the assignment.

You can use any sounds you want. You can use the sounds in the MediaSources directory, the words in the Speech folder on your class CD, or record your own sounds (with the MediaTools application, or with Windows Sound Recorder). (Hint1: Remember that zeroes for the sample values generate silence or pause.) (Hint2: Remember that the sampling rate is the number of samples per second. From there, you should be able to figure out.)

When you do your turnin, you MUST include your input sounds! It would probably be a good idea to turn in your audio collage, too, so that your TA can hear what it's supposed to sound like, even if your program doesn't work for the TA for some reason.

Turn in your program via JES as "hw3".

Ask questions on Fall 2004 Homework 3 Questions

### Homework 4:

Given a folder with images and sounds in it, create an index HTML page with links to each image and sound.

You will write a function called linksREMOVED that takes a string which is the path to a directory. You will create a page in that folder named index.html. Index.html should be an HTML page containing a link to every JPEG and WAV file in the directory.

For each image, you will display a half-size version of the image (by setting height="someNumberHERE" in the image tags). YOU WILL NOT GENERATE THESE IMAGES! Clicking on these half-size versions should take the viewer to the full-size picture. The anchor in the link to each full-size picture should be the half-size image.

For each sound, create a THREE SECOND version of the sound–just the first 1.5 seconds and the last 1.5 seconds. If the sound is less than or equal to three seconds in length, do not create the shortened form. You should save this shortened form of the sound to the same directory as the actual sound, named something like "short_"+filename. For each sound, have a link to the short form where the anchor says "short", and a link to the long form where the anchor says "full".

Turn in your program via JES as "hw4". The function name should be "linksREMOVED" and the program file name should be "linksREMOVED.py".

Ask questions on Fall 2004 Homework 4 Questions

### Homework 5:

Build an animation of at least three seconds in duration (45 frames at 15 fps, or 75 frames at 25 frame per second–you must use a frame rate exceeding 10 frames per second). You must have at least THREE things in motion during this sequence. You must use at least one composited image (a JPEG image that you scale (if necesary) and copy into the image), one drawn image (a rectangle or line or text or oval or arc – anything that you draw), and a third image of your choice. One of your animated objects must appear MIDWAY through the animation. In other words, something has to START being drawn into the frames start at frame, say, 10, and then continue to the end of the animation.

You may NOT use a blank white background for the frames! You must use a JPEG for a background that has REMOVED than one color in it.

Turn in your program and the composited image(s) (any images that you copied INTO your frames) via JES as "hw5". (You do not have to attach all your frames!) Your file must be named "makeMovie.py" and your function must be named "makeMovie" and accept a directory as input where the frames should be stored.

You must use REMOVED than one function in your solution. The main function will be "makeMovie" that takes input of a string that is a directory path. You must use at least one sub-function, so your file "makeMovie.py" will contain the function makeMovie() and at least one another.

EXTRA CREDIT: Five points extra credit will be awarded to animations where the elements are thematically related. Just moving a red rectangle on a green and white screen is not thematically related. See the Yogi, Hasselhoff, Tiger Woods, Guzdial talking, REMOVED the dog, Mario jumping, whee, dog-on-the-beach, or Pooh and Tigger movies at Fall2003 HW5 Movies as examples of thematically-related movies.

Feel free to post your movies to Student1816 for sharing with others.

Ask questions on Fall 2004 Homework 5 Questions

### Homework 6

http://news.com.com is a popular site that lists headline (mostly technology-oriented) news items. You are to write a function (named "makeNewsTickerTape") that will input a directory as a string then:
• YOUR PROGRAM will visit http://news.com.com and pick out the top three news stories headlines. (Hint: The anchors for the news story headlines come after "News around the Web". Then search for the beginning of the anchor <a, then you can find the anchor text, which is the headline.)
• Create a ticker tape movie on the 640x480 canvas of all three news stories. Have one come across near y=100, another at y=200, and the third at y=300. (+/- 10 pixels is fine, so y=105 for the first one is okay.) Generate 100 frames, and don't have the ticker tapes move REMOVED than 5 pixels per frame. (In 100 frames, you won't make it all the way across the screen – that's fine.) Store the frames to files in the input directory.
 Clarification: You can use the headlines that appear under: "More news from around the Web"

You must use REMOVED than one function in your solution. The main function will be "makeNewsTickerTape" that takes input of a string that is a directory path. You must use at least one sub-function.