Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. def checkColor(picture1,picture2,k):
  2.   list1= []
  3.   for pix in (getPixels(picture1)):
  4.     list1.append (getColor(pix))
  5.   list2= []
  6.   for pix2 in (getPixels(picture2)):
  7.    list2.append (getColor(pix2))
  8.    #ho creato due liste contenenti i colori di ogni pixel delle rispettive immagini
  9.   if matchColor(list1,list2,k):
  10.    return true
  11.   return false
  12.  
  13.  
  14.  
  15. def matchColor(list1,list2,k):
  16.   commonColor= []
  17.   for col1 in list1:
  18.    for col2 in list2:
  19.     if col1 == col2 :
  20.      commonColor.append (col1)  
  21.       #ho creato una lista contenente i colori in comune delle due liste prese in considerazione (potrebbero esserci ridondanze,che saranno eliminate con la funzione check
  22.   check (commonColor,k)
  23.  
  24. def   check (list,k):
  25.  common2=[]
  26.  for col2 in list:
  27.   if not exist(col2,common2):
  28.    common2.append (col2)
  29.  if len(common2) == k:
  30.   return true
  31.  ##ho creato una lista contenente tutti i colori in comune, senza ridondanze
  32.  
  33.  
  34.    
  35.    
  36. def exist(col,list):
  37.  for col1 in list:
  38.   if col == col1:
  39.    return true
  40.  return false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement