Ejemplo n.º 1
0
def test_realpaint_to_munsell():
    for name, spaces in REALPAINT_COLORS:
        r, g, b = spaces['sRGB']
        spec_mlin = mlin.rgb_to_munsell_specification(r, g, b)
        color_mlin = mkit.normalized_color(spec_mlin, out='color')
        spec_mint = mint.rgb_to_munsell_specification(r, g, b)
        color_mint = mkit.normalized_color(spec_mint, out='color')
        print(f'{name} {r:3.1f}, {g:3.1f}, {b:3.1f} -> mlin {color_mlin}')
        print(f'{name} {r:3.1f}, {g:3.1f}, {b:3.1f} -> mint {color_mint}')
Ejemplo n.º 2
0
def to_munsell(name, space, color):
    if space == 'rgb':
        spec = mlin.rgb_to_munsell_specification(color[0], color[1], color[2])
    elif space == 'jch_mint':
        spec = mint.jch_to_munsell_specification(color)
    elif space == 'jch_mlin':
        spec = mlin.jch_to_munsell_specification(color)
    elif space == 'xyy':
        spec = mint.xyY_to_munsell_specification(color)
    munsell_color = mkit.normalized_color(spec, out='color')
    print(f'{name:10s} {space:8s} {munsell_color}')
Ejemplo n.º 3
0
def test_color():
    for name in [
            'N6',
            '2.5R8/4',
            '2.5YR8/4',
            '2.5Y8/4',
            '2.5GY8/4',
            '2.5G8/4',
            '2.5BG8/4',
            '2.5B8/4',
            '2.5PB8/6',
            '2.5P8/4',
            '2.5RP8/4',
            '5RP8/4',
            '7.5RP8/4',
            '10RP8/4',
    ]:
        rgb = mkit.munsell_color_to_rgb(name)
        if np.isnan(rgb[0]):
            print(f'{name} not available')
            continue
        rgb = rgb * 255
        spec1, spec2 = mlin.rgb_to_munsell_specification(rgb[0],
                                                         rgb[1],
                                                         rgb[2],
                                                         with_renotation=True)
        print_spec(name, spec1)
        print_spec(f'{name} RENOTATION', spec2)
    for name, spaces in REALPAINT_COLORS:
        rgb = np.array(spaces['sRGB'])
        spec1, spec2 = mlin.rgb_to_munsell_specification(rgb[0],
                                                         rgb[1],
                                                         rgb[2],
                                                         with_renotation=True)
        print_spec(name, spec1)
        print_spec(f'{name} RENOTATION', spec2)
Ejemplo n.º 4
0
def generate_csv(brand):
    colors = read_jsonline(f'{brand.lower()}.jsonl')
    with open(f'{brand}Munsell.csv', 'w') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(COLUMNS)
        for ni, color in enumerate(colors):
            hex = f'#{color.rgb[0]:02X}{color.rgb[1]:02X}{color.rgb[2]:02X}'
            spec = mlin.rgb_to_munsell_specification(color.rgb[0],
                                                     color.rgb[1],
                                                     color.rgb[2])
            munsell_color, spec, hue = mkit.normalized_color(spec, out='all')
            hue_shade, value, chroma, hue_index = spec
            row = [
                brand, color.name, munsell_color, hue['total_hue'], hue_shade,
                hue['hue_name'], hue['astm_hue'], value, chroma, color.data[0],
                hex
            ]
            print(','.join([str(v) for v in row]))
            writer.writerow(row)
Ejemplo n.º 5
0
def test_grays():
    for r, g, b in [(25 * v, 25 * v, 25 * v) for v in range(0, 11)]:
        spec_mlin = mlin.rgb_to_munsell_specification(r, g, b)
        color_mlin = mkit.normalized_color(spec_mlin, out='color')
        print(f'[{r} {g} {b}] -> {color_mlin}')