Advertisement
Guest User

esercizio rettangolo

a guest
Apr 27th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def main(A, h, k, c): #A immagine, h e k dimensioni del rettangolo, c colore
  2. #la funzione restituisce true se un rettangolo hxk di colore c è presente in A, false altrimenti
  3. for colonna in range(0, getWidth(A) - h):
  4. for riga in range(0, getHeight(A) - k):
  5. p = getPixel(A, colonna, riga)
  6. if controllo(p, colonna, riga, h, k, c):
  7. return true
  8. return false
  9.  
  10.  
  11. def controllo(pixel, colonna, riga, h, k, colore):
  12. for i in range(colonna, colonna + h):
  13. for j in range(riga, riga + k):
  14. if getColor(pixel) != colore:
  15. return false
  16. return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement