progress on updateing palete schema
This commit is contained in:
parent
642d53fb42
commit
e8c490c3f3
|
@ -59,7 +59,7 @@ class ComparisonComparison:
|
|||
else :
|
||||
closest, dist = closest_color_euclidean(colors, cccompare)
|
||||
|
||||
colors = remove_from_list(colors, c losest)
|
||||
colors = remove_from_list(colors, closest)
|
||||
|
||||
ccbgr = convert_color(cc, 'RGB', 'BGR')
|
||||
chosenbgr = convert_color(closest, space, 'BGR')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from jsonschema import validate
|
||||
from json import dumps, loads
|
||||
from common import convert_color, closest_color, create_colored_image, remove_from_list, closest_color_euclidean, closest_color_weighted_euclidean, euclidean_distance, weighted_euclidean_distance
|
||||
|
||||
class PalleteSchema :
|
||||
colors = None
|
||||
|
@ -40,4 +41,17 @@ class PalleteSchema :
|
|||
validate( instance = obj, schema = self.schema)
|
||||
jsonstr = dumps(obj, indent = 4)
|
||||
with open(filepath, 'w') as outfile :
|
||||
outfile.write(jsonstr)
|
||||
outfile.write(jsonstr)
|
||||
|
||||
def closest (self, comparison, space = 'BGR', pallete = None) :
|
||||
p = pallete if pallete is not None else self.pallete
|
||||
colors = normalize_colors(space, )
|
||||
|
||||
def normalize_colors (self, space = 'BGR', pallete = None) :
|
||||
colors = []
|
||||
for color in pallete :
|
||||
colors.append(convert_color(color['color'], color['space'], space))
|
||||
return colors
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue