CS 151: Project #5

Project 5: Cover Photos

Main course page

The purpose of this project is to make a program that processes a list defining a collage and builds the resulting image. The collage list information can specify if the program should apply an effect and/or an alpha blend to each image.


For this assignment you're going to create a couple of new functions. One, buildCollage, should go in your collage.py file and will process the collage list information and build the output image. The other, putPixmapNoBlue, should go in your filter.py file and will be identical to putPixmap, except that it will not transfer blue screen pixels into the destination image.

  1. In your collage.py file, create a function buildCollage, as given below. Each comment is a line of python code in the final function. The indentation of the comments should match the code.
    def buildCollage( clist ):
        # assign to (cols, rows) the result of calling getImageSize with clist
        # assign to dst the result of calling graphics.Pixmap with cols and rows
        # for each item in clist
            # assign to filename the first element in item 
            # assign to x0 the second element in item
            # assign to y0 the third element in item
            # assign to operator the fourth element in item
            # assign to alpha the fifth element in item
    	# assign to noBlue the sixth element in item
            # assign to src the last element in item (index -1)
            # use a set of if/elif statements to apply the correct
            # operator to the image (this is several lines of code)
            # call putPixmap to put src into dst at location x0, y0 with blend alpha
        # return dst

    You can use testbuildcollage.py to test your buildCollage function. The test function assumes that your build collage knows what to do with the operator strings 'rbswap' and 'original', as we went over in lab.

  2. In your filter.py file, create a function putPixmapNoBlue that has the same arguments and does the same thing as putPixmap, but does not copy the src pixel into the destination image if the src pixel is part of the blue screen.
  3. Edit your buildCollage program so that it uses the sixth element in the collage information list, stored in the noBlue variable, to determine whether to call putPixmap or putPixmapNoBlue as the last step in the main for loop.
  4. Make a new python file (e.g. mycollage.py) that contains a single main function. Be sure to put a call to the main function behind a test on __name__.

    if __name__ == "__main__":

    The main function should create a collage information list, call readImages, call buildCollage, then write the image to a file. You can use the testbuildcollage.py file as an example. Your collage should use at least four different source images.

    The collage should include at least five different sub-images. Some of these can be copies of one of the source images with different effects. The collage should use at least 3 effects, at least one alpha blend, and at least one blue-screen image where the blue pixels are not copied into the collage.

    Required image 1 is your first collage.

  5. Make a new python file, coverphoto.py, that takes in at least one image filename from the command line. It should build a collage appropriate for a FB cover photo and write it out to a file.

    The collage should be about three times as wide as it is tall and have at least three sub-images. You can control the height and width of the collage by appropriate selection and placement of your images, or you can fix the relative height and width and change putPixmap to safetly handle images that go outside the image boundaries. You can choose random effects for the three images or pick specific effects. The collage should use at least two effects.

    Required image 2 is your cover photo collage.



Make a new wiki page for your assignment. Put the label cs151f12project5 on the page. Each of you needs to make your own writeup.

In addition to making the wiki page writeup, put the python files you wrote on the Academics server in your handin directory.

Colby Wiki

In general, your writeup should follow the outline below.