Difference between revisions of "CSC111 Homework 5 2011"

From dftwiki3
Jump to: navigation, search
(Submission)
(Overview)
Line 8: Line 8:
  
 
==Overview==
 
==Overview==
* Your assignment is to write a graphics program that takes a picture of you and modify it by apply several different transformations (similar to what we did to poor George Clooney).
+
* 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 [[CSC111_Pixelating_Clooney|program]]).
 
* The challenging part is that your program should work for pictures of different geometry, and with different captions (more on that later).
 
* The challenging part is that your program should work for pictures of different geometry, and with different captions (more on that later).
  

Revision as of 08:34, 18 October 2011

--D. Thiebaut 09:05, 18 October 2011 (EDT)


ClooneyPixelated.png



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.
  • 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).
  • 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.gif by the actual name of your image file.
  • 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
    1. 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).
    2. 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.
    3. 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.
    4. 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 with 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 D.
  • Use the online submission form to submit your files: submit5

Grading

  • Up to 2/3 additional point for imaginative transformation