Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Sameer Kumar
- #Skumar77@gatech.edu
- #I worked on this assignment alon, using only this semester's course materials.
- #Function One: Border
- def border (pic, color, thickness):
- left = 0 + thickness
- right = getWidth(pic) - thickness
- top = 0 + thickness
- bottom = getHeight(pic) - thickness
- for pixel in getPixels(pic):
- if getX(pixel) >= right:
- setColor(pixel, color)
- if getX(pixel) <= left:
- setColor(pixel, color)
- if getY(pixel) <= top:
- setColor(pixel, color)
- if getY(pixel) >= bottom:
- setColor(pixel, color)
- #Function Two: Background
- def background(pic, color1, color2, threshold):
- half = getWidth(pic) /2
- for pixel in getPixels(pic):
- if getX(pixel) < half:
- if distance(getColor(pixel), green) < threshold:
- setColor(pixel, color1)
- if getX(pixel) >= half:
- if distance(getColor(pixel), green) < threshold:
- setColor(pixel, color2)
- #Function Three: selectivePosterize
- def selectivePosterize(pic, color1, color2, color3, color4, threshold):
- for pixel in getPixels(pic):
- luminance = (getRed(pixel) + getGreen(pixel) + getBlue(pixel))/3
- x = luminance
- if distance(getColor(pixel), green) > threshold:
- if x < 20:
- setColor(pixel, color1)
- if 20 <= x < 80:
- setColor(pixel, color2)
- if 80 <= x < 160:
- setColor(pixel, color3)
- if x >= 160:
- setColor(pixel, color4)
- #Function 4: generatePoster
- def generatePoster(pic):
- color1 = makeColor(255,0,0)
- color2 = makeColor(50,50,50)
- color3 = makeColor(224,238,224)
- color4 = makeColor(0,0,0)
- leftColor = makeColor(25,25,112)
- rightColor = makeColor(150,0,0)
- selectivePosterize(pic,color4,color3,color2,color1,195)
- background(pic,leftColor,rightColor,130)
- border(pic, black, 20)
Add Comment
Please, Sign In to add comment