This exam is take-home and is due Monday, 19 July, at 5 pm Oxford-time. You may not collaborate with anyone on this exam! It is open-book, open-JES, and open-Web – you are welcome to use any resources that you can find except asking anyone for help. You are welcome to ask questions here on the CoWeb for clarification only. Do not post any part of your answers on the CoWeb, please.
You are to submit your answers to the below questions as a Microsoft Word document. All program code solutions are to be pasted into the document. Please put your name at the top of the document and name the document with your name, e.g., wells-midterm.doc Please state clearly where Parts 1, 2, 3, and 4 are in your answer. Mail it to guzdial@cc.gatech.edu by 5 pm Monday 19 July.
PART 1:
We have discussed in class that an algorithm is a description of a process, and that description goes beyond any language, any particular program, or even a particular medium.
(a) Name one example of an algorithm (process) that can be applied to both pictures and sounds.
(b) Implement two programs (write two functions that do this algorithm), one for sounds and one for images. Use media via getMediaPath from the CD in your examples. (It's okay if these programs come from the book – you just have to pick out two good examples, make them run, then paste the programs into your Word file.)
PART 2:
Below is the base image that you are to manipulate. (You'll need to download this picture and store it in your media directory. Right click on this picture, choose "Save As," then save it in your media directory.)
You are to turn it into this:
(You may notice that the square has a gradient, so that when all four squares are assembled together, a faint image of a circle can be seen in the center of the four squares.)
You will do this by:
Write a function called exam1 in the file exam1.py which will:
Open the base image (square.jpg).
Copy it into the canvas 640x480.jpg starting from the source (1,1). Notice that this is an all-gray image, so each pixel should have red=green=blue.
Mirror it left-to-right but only copy the red! Set the green and blue of each copied pixel to zero.
Mirror it top-to-bottom but only copy the blue! Set the red and green of the target pixels to zero.
Now, mirror the all-red square down, but set the green of each target pixel to the red of the source pixel. Set the red and blue of each target pixel to zero.
RETURN the resultant canvas.
PART 3:
Answer these questions as short-essays, please.
(a) The book presents two different programs that convert from color to gray scale. What's the difference between them? Are they the same algorithm or different?
(b) RGB is a color model that uses 8 bits for each of the Red, Green, and Blue components of a color, providing 24 bits total. Those 24 bits can represent over 16 million patterns, which represent 16 million different colors. CMYK is another color model, popular with printers. Imagine that we used 8 bits to represent each of Cyan, Magenta, Yellow, and blacK in a picture. How many possible colors could we represent in this implementation of the CMYK color model?
(c) What's the difference between vector-based and bit-mapped graphics formats? Please identify one of each.
PART 4:
Write a function that inputs a sound and turns to silence the LAST second of the sound. You may assume that the sound is at least three seconds long. Remember that a sample value of zero is silence, and the sampling rate tells you the number of samples in one second of a sound, and that getLength tells you the total number of samples in a sound, from one to the end.
Paste your resultant function (once it's working) into your Word file.