Advertisement
davide1409

caccia errore

Nov 11th, 2019
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. def contaPix(l,k):
  2. #@ param l : sequence of pixel
  3. #@ param k: int
  4. #@ return int
  5.   p = 0
  6.   for i in range(0, len(l)):
  7.     count = 0
  8.     lum1 = lum(l[i])
  9.     for j in range (0, len(l)):
  10.       if i != j:
  11.         lum2 = lum(l[j])
  12.         if lum1 == lum2:
  13.           count = count+1
  14.     if count == k:
  15.       p=p+1
  16.      
  17.   return p
  18.  
  19. def lum(p):
  20. #@ param p : pixel
  21. #@ return int
  22.   return (getRed(p)+getGreen(p)+getBlue(p))/3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement