Beispiel #1
0
 def calcColor(self,red,green,blue):
     hsl = Hsl()
     color = Color()
     pix = "OTHER"
     HSL = hsl.rgb2hsl(red, green, blue)
     HSL[1] = round(HSL[1],2)
     HSL[2] = round(HSL[2],2)
     grayLevel = self.calcGrayLevel(red,green,blue)
     colorLevel = self.calcColorLevel(red,green,blue)
     grayLumLevel = self.calcGrayLumLevel(red, green, blue)
     for i in range(0,len(Hsl.__hueThresh__)):
         try:
             if(HSL[0]>=Hsl.__hueThresh__[i][0] and HSL[0]<=Hsl.__hueThresh__[i][1]):
                 if(HSL[1]>=Hsl.__satThresh__[i][0] and HSL[1]<Hsl.__satThresh__[i][1]):
                     if(HSL[2]>=Hsl.__lumThresh__[i][0] and HSL[2]<Hsl.__lumThresh__[i][1]):
                         pix = Hsl.__hslColors__[i]
                         if(grayLevel==0):
                             pix = Hsl.__hslColors__[i] + str(int(colorLevel))
                     
                         else:
                             if(pix=="Black" or pix=="White"):
                                 pix += str(colorLevel)
                             elif(pix=="Grey"):
                                 pix += str(colorLevel)
                             else:
                                 pix = "Gray" + str(grayLumLevel) + Hsl.__hslColors__[i] + str(colorLevel)
         
                         if(color.countColors(Hsl.__hslColors__[i])>=2):
                             pix = color.reassignLevels(pix,red,green,blue)
                         return str(int(grayLevel)) + pix 
         except IndexError:
             print "rgb::calcColor2() out of range!\n"
             print "__hueThresh__.Size: {}".format(len(Hsl.__hueThresh__))