diff --git a/generate_color_table.py b/generate_color_table.py index fb0d411..43fa4de 100644 --- a/generate_color_table.py +++ b/generate_color_table.py @@ -73,4 +73,39 @@ for p in palettes: print(f"{prefix}->{len(all_colors)}") for c in all_colors: - c.nn(all_colors) \ No newline at end of file + c.nn(all_colors) + +smallest_dist = 9999999999999 +largest_dist = 0 +for c in all_colors: + dist = rgbdist(c, c.nearest_neighbor) + if dist > largest_dist: largest_dist = dist + if dist < smallest_dist: smallest_dist = dist + #print(f"{c.prefix}:{c.name} -> {c.nearest_neighbor.prefix}:{c.nearest_neighbor.name}\t{rgbdist(c, c.nearest_neighbor):.2f}") +# questions - + +# are there any colors where their nearest neighbor's nearest neighbor isn't them? (There should be) +nonnear_pairs = 0 +for c in all_colors: + neighbor = c.nearest_neighbor + their_neighbor = neighbor.nearest_neighbor + if c is not their_neighbor: + #print(f"{c.prefix}:{c.name} -> {neighbor.prefix}:{neighbor.name} -> {their_neighbor.prefix}:{their_neighbor.name}") + nonnear_pairs += 1 +print("Non-near pairs:", nonnear_pairs) + #print(f"{c.prefix}:{c.name} -> {c.nearest_neighbor.prefix}:{c.nearest_neighbor.name}\t{rgbdist(c, c.nearest_neighbor):.2f}") + +# Are there duplicates? They should be removed from the palette that won't be used +dupes = 0 +for c in all_colors: + for c2 in all_colors: + if c is c2: continue + if c.r == c2.r and c.g == c2.g and c.b == c2.b: + dupes += 1 +print("dupes:", dupes, "this many will need to be removed:", dupes / 2) + +# What order to put them in? Do we want large radiuses first, or some sort of "common color" table? + +# does manhattan distance change any answers over the 16.7M RGB values? + +# What's the worst case lookup? (Checking all 1200 colors to find the name?) \ No newline at end of file