32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import cv2
|
|
import numpy as np
|
|
from pallete_schema import PalleteSchema
|
|
from common import convert_color, closest_color, create_colored_image
|
|
|
|
class ComparisonComparison:
|
|
def __init__ (self) :
|
|
red = [0, 10, 200]
|
|
green = [5, 250, 5]
|
|
blue = [240, 0, 20]
|
|
comp_colors = [red, green, blue]
|
|
pallete = PalleteSchema('./palletes/printed_pallete.json')
|
|
colors = self.get_colors(pallete.colors)
|
|
for cc in comp_colors :
|
|
ccbgr = convert_color(cc, 'RGB', 'HSV')
|
|
closest = closest_color(colors, ccbgr)
|
|
ccbgr = convert_color(cc, 'RGB', 'BGR')
|
|
#print(f'{convert_color(closest,"BGR","RGB")} for {convert_color(ccbgr,"BGR","RGB")}')
|
|
original = create_colored_image(100, 100, convert_color(closest, 'HSV', 'BGR'))
|
|
chosen = create_colored_image(100, 100, ccbgr)
|
|
combined = np.hstack([original, chosen])
|
|
cv2.imshow("image", combined)
|
|
cv2.waitKey(0)
|
|
|
|
def get_colors (self, pallete) :
|
|
colors = []
|
|
for color in pallete :
|
|
colors.append(convert_color(color['color'], 'BGR', 'HSV'))
|
|
return colors
|
|
|
|
if __name__ == "__main__":
|
|
ComparisonComparison() |