detect nearest colors
This commit is contained in:
parent
3f7391c803
commit
151fb732c8
1 changed files with 9 additions and 0 deletions
9
color.py
9
color.py
|
@ -116,3 +116,12 @@ for i in EXTENDEDCOLORS:
|
||||||
COLORS = colors
|
COLORS = colors
|
||||||
|
|
||||||
|
|
||||||
|
def closestColor(rgb):
|
||||||
|
r, g, b = rgb
|
||||||
|
diss = {}
|
||||||
|
for cc in COLORS:
|
||||||
|
rc, gc, bc = COLORS[cc]
|
||||||
|
distance = abs(r-rc) + abs(g-gc) + abs(b-bc)
|
||||||
|
diss[cc] = distance
|
||||||
|
return min(diss, key=diss.get)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue