When printers work with an image, they often have to generate separations where only the cyan, magenta, yellow, and black (CMYK) inks are on each page. You're to do something similar. For Take Home Exam 2, write a function that will take as input a directory and generate a separations.html page that will show miniature versions of each "JPG" (JUST lowercase ".jpg") file in the directory: In its original color, then just the red (green and blue zeroed out), then just the green, then just the blue.
Your resultant page will look something like this (click on the image to see it full-size):
You will do this by:
Write a function called exam2 in the file exam2.py which will:
Accept as input a directory.
Make a file separations.html in that directory.
For each file ending in "JPG" in the directory,
Create a copy of that picture that has only the red components of pixels (in other words, make all green and blue components of all pixels 0). You might call this "red_" plus the original file name (e.g., fred.jpg leads to a red-only picture in the file red_fred.jpg).
Create a green-only copy of the file, maybe named grn_+file.
Create a blue-only copy of the file, maybe named blu_+file.
In the file separations.html, write out HTML so that, for each JPG file, there are links to each of the original picture file, the red-only version, the green-only version, and the blue-only version. Each of these links should be a small version of the file, only 100 pixels high. You are not GENERATING thumbnail files here! You will get smaller versions of the pictures through use of HTML, not by creating SMALLER (scaled) JPEG images. You will simply specify height=100 on the image tags.
Close the file after writing it out.
You will, of course, be generating a bunch of files in doing this. Your directory will go from looking like this:
To this (after running your program):
The solution that we wrote generates HTML like what you see at the bottom of this page.
This is a NON-COLLABORATIVE ACTIVITY! You may not talk to anyone about their code, nor look at anyone else's code, nor allow anyone to see your code. This is a TAKE HOME EXAM. It is an "open book" exam. You may use your book, any slides, any material in the CoWeb, and any programs you've written (even with others). (I'll bet Homework 4 would be useful for this one...)
Ask questions on Spring 2004 Take Home Exam 2 Questions Page but be sure to ask questions only about objectives and process. You are welcome to ask questions about any of the programs in the book or in the slides, or any of the topics in the class (e.g., "I don't understand mirroring – can you help me go through it again?") but you cannot ask anyone (even the TA's or teacher) about your own solution. DO NOT POST ANY OF YOUR CODE ONTO THIS PAGE IN ASKING QUESTIONS!
Turn in your program via JES as "exam2". When you turn in your exam, you are to enter into the Comment area the statement: "I did not provide nor receive any aid on this exam." IF YOU CANNOT MAKE THAT STATEMENT TRUTHFULLY, DO NOT SUBMIT YOUR EXAM! ANY EXAM WITHOUT THAT STATEMENT WILL NOT BE GRADED.
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 will do this by:
Write a function called exam1 in the file exam1.py which will:
Open the base image using getMediaPath("BaseCanvas.jpg")
Mirror it horizontally and vertically (any order should work): left-to-right, and top-to-bottom, for example. NOTE THAT YOU WILL NOT NEED A SEPARATE CANVAS FOR THIS!. You will do all manipulations on this same picture.
Negate the bottom right 1/4 of the image.
RETURN the resultant canvas.
This is a NON-COLLABORATIVE ACTIVITY! You may not talk to anyone about their code, nor look at anyone else's code, nor allow anyone to see your code. This is a TAKE HOME EXAM. It is an "open book" exam. You may use your book, any slides, any material in the CoWeb, and any programs you've written (even with others). (I'll bet Homework 2 would be useful for this one...)
Ask questions on Spring 2004 Take Home Exam 1 Questions Page but be sure to ask questions only about objectives and process. You are welcome to ask questions about any of the programs in the book or in the slides, or any of the topics in the class (e.g., "I don't understand mirroring – can you help me go through it again?") but you cannot ask anyone (even the TA's or teacher) about your own solution. DO NOT POST ANY OF YOUR CODE ONTO THIS PAGE IN ASKING QUESTIONS!
Turn in your program via JES as "exam1". When you turn in your exam, you are to enter into the Comment area the statement: "I did not provide nor receive any aid on this exam." IF YOU CANNOT MAKE THAT STATEMENT TRUTHFULLY, DO NOT SUBMIT YOUR EXAM! ANY EXAM WITHOUT THAT STATEMENT WILL NOT BE GRADED.
Links to this Page
Hotspots #2 last edited on 5 May 2008 at 10:38 am by c-76-17-124-0.hsd1.ga.comcast.net
Announcements-Spring 2004 last edited on 29 April 2004 at 2:04 pm by lawn-199-77-207-34.lawn.gatech.edu