Difference between revisions of "CSC111 Homework 5 2011"
(→Your assignment) |
(→Your assignment) |
||
Line 73: | Line 73: | ||
*# Your program will put a border around the picture. The border should be at least 5 pixels wide, and be drawn using 2 different colors (at least). | *# Your program will put a border around the picture. The border should be at least 5 pixels wide, and be drawn using 2 different colors (at least). | ||
*# Your program should use some pixelation operation (similar to what we did with Clooney) to modify the face of the person in the image (but not the border!). You can use one of the methods we demonstrated in class, or come up with your own. | *# Your program should use some pixelation operation (similar to what we did with Clooney) to modify the face of the person in the image (but not the border!). You can use one of the methods we demonstrated in class, or come up with your own. | ||
− | *# Your program will display the caption inside the border, centered relative to the width of the image, and either at the top, or at the bottom of the frame. | + | *# Your program will display the caption inside the border, centered relative to the width of the image, and either at the top, or at the bottom of the frame. The text of the caption is the contents of the '''caption''' variable in the '''userInfo''' module. |
*# Your program will perform some RGB transformation of the image (but not of the frame or the caption). Use your imagination for the type of RGB transformation. The last lab shows you several options. | *# Your program will perform some RGB transformation of the image (but not of the frame or the caption). Use your imagination for the type of RGB transformation. The last lab shows you several options. | ||
* In addition, you will have to make sure that every transformation your program carries out on the image uses only the variables '''width''' and '''height''' that are defined in '''userInfo.py''', because your program will be tested not only with the gif file you will upload, but also with an other gif file that will be defined in a different '''userInfo.py'''. In other words, I will have a gif file different from yours, say '''111test.gif''', and a different '''userInfo.py''' module that will contain the width and height of 111test.gif, with a caption such as '''111a test caption''', and I will put both of them along with your program and will launch your program. If your program is written correctly it will put the right border, right caption, and will apply the right transformations to the test image. | * In addition, you will have to make sure that every transformation your program carries out on the image uses only the variables '''width''' and '''height''' that are defined in '''userInfo.py''', because your program will be tested not only with the gif file you will upload, but also with an other gif file that will be defined in a different '''userInfo.py'''. In other words, I will have a gif file different from yours, say '''111test.gif''', and a different '''userInfo.py''' module that will contain the width and height of 111test.gif, with a caption such as '''111a test caption''', and I will put both of them along with your program and will launch your program. If your program is written correctly it will put the right border, right caption, and will apply the right transformations to the test image. |
Revision as of 11:07, 18 October 2011
--D. Thiebaut 09:05, 18 October 2011 (EDT)
Contents
This assignment is due on Tuesday evening, Oct. 25th, at midnight. You can work on it in pairs, or individually. Make sure you submit 3 files when you are done with this assignment.
Automatic Picture Editor
Overview
- Your assignment is to write a graphics program that takes a picture of you and modify it by apply several different transformations, in fashion similar to what we did to poor George Clooney (see program).
- The challenging part is that your program should work for pictures of different geometry, and with different captions (more on that later).
Preparation
- It will be easier if you do not use beowulf for this assignment. Use a computer in the lab, or your own computer to perform the work on this assignment.
- Select a picture of yourself that is in the area of 300 by 200 pixels (if possible). Don't select something that is 1000 by 1000 or your program will take forever to process it and you will waste a lot of time debugging.
- The picture must have a gif extension, otherwise the graphics.py library will not be able to load it. Very likely the picture you will have of yourself will have a jpg, jpeg, or png extension. That's ok, you can transform it to a gif extension by uploading it to this Web site and downloading the gif version: www.coolutils.com
- Once you have the picture, put it in the same directory (folder) where your python program will reside.
- Make sure the graphics.py library is there as well.
- Find out the width and height of your image (use Google to help you figure out how to do this with Windows or Mac OSX, or use a simple utility I have put together for this purpose).
- Then create a short python module, called userInfo.py. Make sure you spell it exactly as shown, as your program wil be tested with a userInfo.py module of my own.
# userInfo.py
# module containing information about a gif file
# to be process by hw5.py
filename = "alexandra.gif"
caption = "Alexandra"
width = 400
height = 300
- Of course, you will have to replace alexandra in the file name and caption to what you picked for your file name and your caption.
- You are now ready to write hw5.py, a python program that will import everything from the userInfo.py module, and use it to conduct its transformation.
- Here's a debugging version of hw5.py that will help you figure out how things will work.
# hw5.py
# your name
from userInfo import *
from graphics import *
def main():
print( "Gif file: ", filename ) # this will print alexandra.gif
print( "width of gif file: ", width ) # this will print 400
print( "height of gif file: ", height ) # this will print 300
print( "User name: ", caption ) # this will print Alexandra
main()
Your assignment
- You are now ready to start programming
- Here is a list of the different transformations your program will have to perform:
- The demo program I used to pixelate Clooney is not very robust. It will crash if the size of the square (sq) does not divide the width or height exactly. You will have to fix this so that your program can work with any value of width and height.
- Your program will put a border around the picture. The border should be at least 5 pixels wide, and be drawn using 2 different colors (at least).
- Your program should use some pixelation operation (similar to what we did with Clooney) to modify the face of the person in the image (but not the border!). You can use one of the methods we demonstrated in class, or come up with your own.
- Your program will display the caption inside the border, centered relative to the width of the image, and either at the top, or at the bottom of the frame. The text of the caption is the contents of the caption variable in the userInfo module.
- Your program will perform some RGB transformation of the image (but not of the frame or the caption). Use your imagination for the type of RGB transformation. The last lab shows you several options.
- In addition, you will have to make sure that every transformation your program carries out on the image uses only the variables width and height that are defined in userInfo.py, because your program will be tested not only with the gif file you will upload, but also with an other gif file that will be defined in a different userInfo.py. In other words, I will have a gif file different from yours, say 111test.gif, and a different userInfo.py module that will contain the width and height of 111test.gif, with a caption such as 111a test caption, and I will put both of them along with your program and will launch your program. If your program is written correctly it will put the right border, right caption, and will apply the right transformations to the test image.
- You can test your program by creating a second gif file of different width and height as your first image, and a new userInfo.py file, and see if your program works without having you to change it for the new image.
Submission
- You have to submit three files:
- hw5.py,
- userInfo.py,
- and your gif image file.
- If you forget any one of these files, your program will crash when I run it, and your grade will be at most a C-.
- Use the online submission form to submit your files: submit5
Grading
- Up to 2/3 extra points will be given to imaginative designs (both for the graphics, and for the code).
- Up to a point will be removed for missing or incomplete documentation. Look at the posted solutions for previous Homework assignments to see examples of good documentation.
- A program that works on the user-supplied image, but not on the instructor supplied image will be worth at most B.
- A program that crashes when it runs will be worth at most C-.