Está en la página 1de 2

INF 120:

Programming Assignment 8

For this assignment you will write a program that mimics the artistic style of Andy Warhol. If you are unfamiliar with his work, take some time to look him up on the Internet; he's a famous and influential American artist. Even if you do not recognize his name, you may be familiar with his Marilyn Monroe and Campbell's Soup paintings. For this program, you will write a "warholizer" that will take a black and white picture as input. Your program will then create a new image that is the same height as the original, but twice as wide. This wider image will contain two copies of the original: one on the left in the original orientation and one that is flipped horizontally in the right half. In addition to this composition, the white and black will be replaced by different colors in each of the copies. It is assumed white represents "background" and black represents "foreground," so your color choices will effectively be changing the background and foreground of the pieces. This description may sound confusing but the example below should make it clear what needs to happen.

For this program you will write a program that consists of the following functions: flip: Takes one parameter, the picture. Its purpose is to create a new picture that is the horizontally flipped version of the original picture. Create a new picture Modify the new picture to be a flipped copy of the original picture. Think about pixel locations: in a flip where does a particular pixel start and where does it move to? Return the flipped picture Takes one parameter, the picture. Returns a "warholized" version of a black and white image:

warholize:

def warholize(pic): Let w, h be pic's width and height. Let picFlip be the "flipped" version of the pic. Use your flip function! Let picNew be a new empty white picture of size 2*w * h. # create the left half of the warholized picture. Use nested loops to go over pic's coordinates: let c be the color of the pixel in pic at location (x,y) let px be the pixel in picNew at location (x,y) if c is white, set px to a "light" color, otherwise set it to a "dark" color # create the right half of the warholized picture. Use nested loops to go over picFlip's coordinates let c be the color of the pixel in picFlip at location (x,y) let px be the pixel in picNew at location (x+w,y) if c is white, set px to a "light" color, otherwise set it to a "dark" color return the new picture

main:

This should ask the user to pick a picture, show the original, get the warholized version and then display it as well.

There is a .zip file on Blackboard that contains numerous pictures for you to practice with. You may also practice with any black & white picture of your choosing. Note that they must contain only pure black and white pixels (no grey!!) for the result to look correct. Make sure to test your program thoroughly before submitting!! Make your code clear, using meaningful variable names and judicious commenting. Please remember to have input and output EXACTLY as it is shown in the pictures. Start early, and start on a simplified version first, gradually adding features. Name your main function main and store it in a file named Program8_####.py (remember to include the .py at the end) where #### is replaced by your last name. (e.g. Program8_Baxter.py) DO NOT TURN IN A PROJECT CALLED Program8_Baxterpy Submit the file via Blackboard prior to the due date/time. Output for two pictures of different sizes:

DUE: By the beginning of class on Monday, November 25 by 04:50pm.

También podría gustarte