Advertisement
MaxDvc

contaPix

Nov 9th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. #La funzione contaPix(l,k) intende calcolare il numero di pixel (prelevati da un'immagine) che
  2. #   hanno esattament k altri pixel con stessa luminosit??, ma contiene un errore. Quale?
  3.  
  4. def contaPix(l,k):
  5. #@ param l : sequence of pixel
  6. #@ param k: int
  7. #@ return int
  8.     p = 0
  9.     for i in range(0, len(l)):
  10.         count = 0
  11.         lum1 = lum(l[i])
  12.         for j in range (0, len(l)):
  13.             if i != j:
  14.                 lum2 = lum(l[j])
  15.             if lum1 == lum2:
  16.                 count = count+1
  17.         if count == k:
  18.             p=p+1
  19.     return p
  20.  
  21. def lum(p):
  22. #@ param p : pixel
  23. #@ return int
  24.     return (getRed(p)+getGreen(p)+getBlue(p))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement