Guest User

Untitled

a guest
Jan 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #Sameer Kumar
  2. #Skumar77@gatech.edu
  3. #I worked on this assignment alon, using only this semester's course materials.
  4.  
  5. #Function One: Border
  6.  
  7. def border (pic, color, thickness):
  8. left = 0 + thickness
  9. right = getWidth(pic) - thickness
  10. top = 0 + thickness
  11. bottom = getHeight(pic) - thickness
  12. for pixel in getPixels(pic):
  13. if getX(pixel) >= right:
  14. setColor(pixel, color)
  15. if getX(pixel) <= left:
  16. setColor(pixel, color)
  17. if getY(pixel) <= top:
  18. setColor(pixel, color)
  19. if getY(pixel) >= bottom:
  20. setColor(pixel, color)
  21.  
  22. #Function Two: Background
  23. def background(pic, color1, color2, threshold):
  24. half = getWidth(pic) /2
  25. for pixel in getPixels(pic):
  26. if getX(pixel) < half:
  27. if distance(getColor(pixel), green) < threshold:
  28. setColor(pixel, color1)
  29. if getX(pixel) >= half:
  30. if distance(getColor(pixel), green) < threshold:
  31. setColor(pixel, color2)
  32.  
  33. #Function Three: selectivePosterize
  34. def selectivePosterize(pic, color1, color2, color3, color4, threshold):
  35. for pixel in getPixels(pic):
  36. luminance = (getRed(pixel) + getGreen(pixel) + getBlue(pixel))/3
  37. x = luminance
  38. if distance(getColor(pixel), green) > threshold:
  39. if x < 20:
  40. setColor(pixel, color1)
  41. if 20 <= x < 80:
  42. setColor(pixel, color2)
  43. if 80 <= x < 160:
  44. setColor(pixel, color3)
  45. if x >= 160:
  46. setColor(pixel, color4)
  47.  
  48. #Function 4: generatePoster
  49. def generatePoster(pic):
  50. color1 = makeColor(255,0,0)
  51. color2 = makeColor(50,50,50)
  52. color3 = makeColor(224,238,224)
  53. color4 = makeColor(0,0,0)
  54. leftColor = makeColor(25,25,112)
  55. rightColor = makeColor(150,0,0)
  56. selectivePosterize(pic,color4,color3,color2,color1,195)
  57. background(pic,leftColor,rightColor,130)
  58. border(pic, black, 20)
Add Comment
Please, Sign In to add comment