Advertisement
MaxDvc

lumLineCheck

Nov 9th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. def lumLineCheck(pict):
  2. #@param:
  3. #   pict: picture;
  4.     height = getHeight(pict)
  5.     width = getWidth(pict)
  6.     count = 0
  7.     for y in range(0,height):
  8.         u = lineList(y,pict)
  9.         a = False
  10.         if not a:
  11.             for i in range(1,len(u)):
  12.                 if univ(u[0],u[i]):
  13.                     a = True
  14.         if a:
  15.             count = count+1
  16.     return count
  17. #-------------------------------------------------------------------------------
  18. def lineList(i,pict):
  19. #@param:
  20. #   i: int, y axis index;
  21. #   pict: picture;
  22.     u = []
  23.     width = getWidth(pict)
  24.     for x in range(0,width):
  25.         u.append(getPixel(pict,x,i))
  26.     return u
  27. #-------------------------------------------------------------------------------
  28. def univ(x,D1):
  29. # Universal quantifier "for every";
  30. #@param:
  31. #   x: item;
  32. #   D: list of items;
  33. #   return: bool;
  34.     for item in D1:
  35.         if not lumCheck(x,item):
  36.             return False
  37.     return True
  38. #-------------------------------------------------------------------------------
  39. def lumCheck(pix1,pix2):
  40. #@param:
  41. #   pix1, pix2: pixel;
  42. #   return: bool;
  43.   if luminance(pix1) == luminance(pix2):
  44.     return True
  45.   else:
  46.     return False
  47. #-------------------------------------------------------------------------------
  48. def luminance(pix):
  49. #@param:
  50. #   pix: pixel
  51. #   return: int, luminance;
  52.     r = getRed(pix)
  53.     g = getGreen(pix)
  54.     b = getBlue(pix)
  55.     luminance = (r+g+b)
  56.     return (luminance)
  57. #-------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement