Advertisement
Guest User

[Python] Posterize Test Function - Written by Ray Prina

a guest
Nov 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. from Cimpl import *
  2. from Posterize import *
  3.  
  4. def test_posterize(image: Image) -> str:
  5. """
  6. Checks every single pixel in the image and passes or fails. Returns 'Pass' if the value of any of the components is either 223, 195, 95, or 31 and returns 'Fail' if those requirements are not met.
  7.  
  8. >>> test_posterize(posterize(new_image))
  9. """
  10. x = 0
  11. y = 0
  12. z = 0
  13.  
  14. for pixels in image:
  15. x, y, (r,g,b) = pixels
  16. print(r, g, b)
  17.  
  18.  
  19. if (r == 223):
  20. x = True
  21. elif (r == 159):
  22. x = True
  23. elif (r == 95):
  24. x = True
  25. elif (r == 31):
  26. x = True
  27. else :
  28. x = False
  29.  
  30. # --------------------------------------
  31.  
  32. if (g == 223):
  33. y = True
  34. elif (g == 159):
  35. y = True
  36. elif (g == 95):
  37. y = True
  38. elif (g == 31):
  39. y = True
  40. else :
  41. y = False
  42.  
  43. # --------------------------------------
  44.  
  45. if (b == 223):
  46. z = True
  47. elif (b == 159):
  48. z = True
  49. elif (b == 95):
  50. z = True
  51. elif (b == 31):
  52. z = True
  53. else :
  54. z = False
  55.  
  56. if x and y and z == True:
  57. print('Pass')
  58. else :
  59. print('Fail')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement