Difference between revisions of "CSC111 Homework 7 2014"

From dftwiki3
Jump to: navigation, search
(Requirements)
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
<br />
 +
<bluebox>This assignment is due on 3/27/14 evening, at midnight.  You can work in pair on this assignment, or individually.  </bluebox>
 +
<br />
 
=Assignment=
 
=Assignment=
 
<br />
 
<br />
Line 16: Line 18:
 
=Requirements=
 
=Requirements=
 
<br />
 
<br />
 +
* Call your program '''hw7a.py'''
 
* You need to write a JES program that contains several functions, one function for each basic transformation.
 
* You need to write a JES program that contains several functions, one function for each basic transformation.
 
* Your program will copy the image of the president in the 3 other quadrants, erasing in the process the orange background and the smiley faces.  We'll refer to these as ''quadrant images.''
 
* Your program will copy the image of the president in the 3 other quadrants, erasing in the process the orange background and the smiley faces.  We'll refer to these as ''quadrant images.''
 +
* The top left image will be the original picture of the president, and will never be affected by any of the transformations.
 +
* The final image will contain four copies of the president's head.  All four heads will be oriented correctly.  In other words, none of the heads will be upside down.
 +
* Your program will put a 5-pixel border all around the full image.  The color of the border is up to you.
 
* Your program will make one of the quadrant images black and white.
 
* Your program will make one of the quadrant images black and white.
 
* Your program will transform one of the quadrant images of the president and divide it into 4 quarters, applying an image transformation to the top-left and bottom-right corners of this image, as illustrated with this picture of the cat below.  The type of color transformation you use is up to you.  But it should be visible.
 
* Your program will transform one of the quadrant images of the president and divide it into 4 quarters, applying an image transformation to the top-left and bottom-right corners of this image, as illustrated with this picture of the cat below.  The type of color transformation you use is up to you.  But it should be visible.
Line 23: Line 29:
 
<center>[[Image:QuadrantCat.png]]</center>
 
<center>[[Image:QuadrantCat.png]]</center>
 
<br />
 
<br />
* The last quadrant image will be a color transformation that will divide the quadrant image into stripes, as illustrated on the cat image  below.  The type of color transformation you use is up to you.  The number of horizontal stripes, and their width are up to you.  The type of color transform is also up to you, but cannot be the same as the transformation used for the image divided into quarters.
+
* The last quadrant image will be a color transformation that will divide the quadrant image into stripes, as illustrated on the cat image  below.  The type of color transformation you use is up to you.  The number of horizontal stripes, and their width are up to you.  While the type of color transform is also up to you, it cannot be the same as the transformation used for the image divided into quarters.
 
<br />
 
<br />
 
<center>[[image:stripedCat.png]]</center>
 
<center>[[image:stripedCat.png]]</center>
 +
<br />
 +
* Make sure you document your program well.  Each function should have its own header explaining what it does.
 +
<br />
 +
* The image below is an ''approximation'' of what your program could output if the top quarter image had been our favorite cat:
 +
<br />
 +
<center>
 +
[[Image:FourCats.png]]
 +
</center>
 +
<br />
 +
 +
=Hints (<font color="red">Added 3/27/14</font>)=
 +
<br />
 +
Some tips for generating stripes...
 +
<br />
 +
<center><videoflash>djlyqdaAOQ0</videoflash></center>
 +
<br />
 +
 +
=Testing=
 +
<br />
 +
Your program will be tested with a file that will not have the same size as the image with the president and the 3 smileys.  But it will have one original photo in the top left corner.  Your program should work for any size image, and adapt to the width and height of the image it is given.
 +
<br />
 +
You may want to test your program on this image of Miss Piggy to verify that it works well on this image as well.
 +
<br />
 +
Be careful that your program should work for images that are taller than they are wider, as well as for images that are wider than they are taller.
 +
<center>[[Image:MissPiggy.jpg]]</center>
 +
<br />
 +
 +
=Submission=
 +
<br />
 +
Submit your '''hw7a.py''' program  [http://cs.smith.edu/~thiebaut/111b/submit7.php here].  Also submit a copy of the final image you created.  It should be called '''hw7.jpg''', or '''hw7.bmp''', or '''hw7.png''', depending on the extension of your image.
 +
<br />
 +
 +
=Optional=
 +
<br />
 +
Feel free to use somebody else's picture if you prefer not to work on our president.  But if you do, the original picture should contain a real picture in the top-left quarter.  This corner picture will be duplicated by your program in the other 3 corners.
 +
 +
<br />
 +
<onlydft>
 +
=Script to print all images on color printer.=
 +
* put all files in same directory, and change name to 111b-xx.jpg or 111b-xx.bmp
 +
* rsync files to xgridmac
 +
* run this Python script
 +
<br />
 +
<source lang="python">
 +
#! /usr/bin/env python3.3
 +
# tagPics.py
 +
# run this on MacPro
 +
# takes a bunch of files, convert the bmp ones to jpg
 +
#
 +
names="""111b-aa Jiayue (Joyce) Xue
 +
111b-ab Julie Richardson
 +
111b-ac Yadira Flores
 +
111b-ad Ella Maxey
 +
111b-ae Diane Chen
 +
111b-af Katerina Popova
 +
111b-ag Danielle Atchison
 +
111b-ah Claire Dudek
 +
111b-ai Shreeya Rajanarayanan
 +
111b-aj Kathleen McLaughlin
 +
111b-ak Jingyang (Judy) Zhang
 +
111b-al Melanie Herscher
 +
111b-am Stephanie Defrank
 +
111b-an Elizabeth Jarrett
 +
111b-ao Lindy Jensen
 +
111b-ap Arcadia Kratkiewicz
 +
111b-aq Laila Phillips
 +
111b-ar Erika Earley
 +
111b-as Grace Burke
 +
111b-at Yungjen Kung
 +
111b-au Marianne Staknis
 +
111b-av Zoe Kendall
 +
111b-aw Halimat Ipesa-Balogun
 +
111b-ax Elyse Mancuso
 +
111b-ay Kimberly Lu
 +
111b-az Kyla Wingrove-Haugland
 +
111b-ba Flora Wang
 +
111b-bb Lizbeth Galvez
 +
111b-bc Yixin (Vera) Bao
 +
111b-bd Yijin Wei
 +
111b-be Christine Hamilton
 +
111b-bf Cecely Ogren
 +
111b-bg Bailey Vaillancourt
 +
111b-bh Yunzhu (Izzy) Chen
 +
111b-bi Julieanna Niu
 +
111b-bj Sophie Herreid
 +
111b-bk Em Brooks
 +
111b-bl Sarah McNeil
 +
111b-bm Youyou Tian
 +
111b-bn Grace Lee
 +
111b-bo Brittney Blokker
 +
111b-bp Anna Render
 +
111b-bq Yi Peng Lai
 +
111b-br Carolyn Meyer
 +
111b-bs Olena Zozulevich
 +
111b-bt Mollie Reich
 +
111b-bu Sarah Sutto-Plunz
 +
111b-bv Colgan Powell
 +
111b-bw Nicole Wong
 +
111b-bx Lujun Jian
 +
111b-by Karen Diaz
 +
111b-bz Elsie Odhiambo
 +
111b-ca Liza Maharjan
 +
111b-cb Xiangyun Xu
 +
111b-cc Sarah Agatoni
 +
111b-cd Jin Rui Yap
 +
111b-ce Thuy Nguyen
 +
111b-cf Yumeng Wang
 +
111b-cg Jizhen Jiang
 +
111b-ch Zoey Sun
 +
111b-ci Jenny Huang
 +
111b-cj Maria Xu
 +
111b-ck Zhiyi Chen
 +
111b-cl Claudia Yun
 +
111b-cm Hera Liu
 +
111b-cn Emily Tizard
 +
111b-co Sara Kanig
 +
111b-cp Chloe Lee
 +
111b-cq Maria Gonzalez
 +
111b-cr Ayliffe Brown
 +
111b-cs Madison Danis
 +
111b-ct Sharla Alegria
 +
111b-cu Jing Zhang
 +
111b-cv Phyllis Chen
 +
111b-cw Jin Rui Yap
 +
111b-cx Jackie Byun
 +
111b-dz Mickey Mouse"""
 +
 +
import glob
 +
 +
dico = {}
 +
for line in names.split( "\n" ):
 +
    words = line.split()
 +
    dico[words[0].strip()] = " ".join( words[1:] )
 +
   
 +
list = []
 +
for extension in [ "bmp", "jpg" ]:
 +
    for file in glob.glob( "*." + extension ):
 +
        #print( file )
 +
        list.append( file )
 +
 +
command = """convert %s  -fill white  -undercolor '#00000080' -pointsize 15  -gravity South  -annotate +0+5 ' %s '  %s"""
 +
imageFiles = []
 +
for file in list:
 +
    #print( file )
 +
    classId = file.split('.')[0]
 +
    try:
 +
        name = dico[classId]
 +
    except:
 +
        continue
 +
 +
    imageFile = "_" + file.replace( "bmp", "jpg" )
 +
    imageFiles.append( imageFile )
 +
 +
    print( command % ( file, classId+" "+name, imageFile ) )
 +
 +
 +
 +
for file in imageFiles:
 +
    print( "lpr -P  OKI_C710 " + file )
 +
 +
</source>
 +
<br />
 +
</onlydft>
 
<br />
 
<br />

Latest revision as of 10:20, 27 March 2014


This assignment is due on 3/27/14 evening, at midnight. You can work in pair on this assignment, or individually.


Assignment


  • First observe how Andy Warhol took a picture of Marilyn Monroe and turned it into a work of art:


MarilynWarhol.jpg


  • You are going to apply similar transformations to this picture of a famous local person:


Pres.jpg


Details

  • The picture of President Cathy McCartney is exactly one quarter the size of the full image. The size of her picture is one half the width of the full image, and the height of the picture one half the full height.
  • The file is coded as a jpg file.


Requirements


  • Call your program hw7a.py
  • You need to write a JES program that contains several functions, one function for each basic transformation.
  • Your program will copy the image of the president in the 3 other quadrants, erasing in the process the orange background and the smiley faces. We'll refer to these as quadrant images.
  • The top left image will be the original picture of the president, and will never be affected by any of the transformations.
  • The final image will contain four copies of the president's head. All four heads will be oriented correctly. In other words, none of the heads will be upside down.
  • Your program will put a 5-pixel border all around the full image. The color of the border is up to you.
  • Your program will make one of the quadrant images black and white.
  • Your program will transform one of the quadrant images of the president and divide it into 4 quarters, applying an image transformation to the top-left and bottom-right corners of this image, as illustrated with this picture of the cat below. The type of color transformation you use is up to you. But it should be visible.


QuadrantCat.png


  • The last quadrant image will be a color transformation that will divide the quadrant image into stripes, as illustrated on the cat image below. The type of color transformation you use is up to you. The number of horizontal stripes, and their width are up to you. While the type of color transform is also up to you, it cannot be the same as the transformation used for the image divided into quarters.


StripedCat.png


  • Make sure you document your program well. Each function should have its own header explaining what it does.


  • The image below is an approximation of what your program could output if the top quarter image had been our favorite cat:


FourCats.png


Hints (Added 3/27/14)


Some tips for generating stripes...


Testing


Your program will be tested with a file that will not have the same size as the image with the president and the 3 smileys. But it will have one original photo in the top left corner. Your program should work for any size image, and adapt to the width and height of the image it is given.
You may want to test your program on this image of Miss Piggy to verify that it works well on this image as well.
Be careful that your program should work for images that are taller than they are wider, as well as for images that are wider than they are taller.

MissPiggy.jpg


Submission


Submit your hw7a.py program here. Also submit a copy of the final image you created. It should be called hw7.jpg, or hw7.bmp, or hw7.png, depending on the extension of your image.

Optional


Feel free to use somebody else's picture if you prefer not to work on our president. But if you do, the original picture should contain a real picture in the top-left quarter. This corner picture will be duplicated by your program in the other 3 corners.



...