Ejemplo n.º 1
0
def make_srgb_2015_color_checker():
    # get color checker spectrum
    cc_spectrum, cc_shape = load_colorchecker_spectrum()
    cc_shape = SpectralShape(390, 730, 1)
    cc_spectrum.trim(cc_shape)
    cc_spectrum = cc_spectrum.interpolate(SpectralShape(interval=1),
                                          interpolator=LinearInterpolator)

    # get d65 spd, cie1931 cmfs
    d65_spd = load_d65_spd_1nmdata().trim(cc_shape)
    cmfs_cie2015 =\
        STANDARD_OBSERVERS_CMFS['CIE 2012 2 Degree Standard Observer'].copy()
    cmfs_cie2015.trim(cc_shape)
    d65_spd_1nm = d65_spd.values[:, 1]
    cmfs_cie2015_1nm = cmfs_cie2015.values

    # get large xyz data from spectrum
    large_xyz = colorchecker_spectrum_to_large_xyz_2015(
        d_light=d65_spd_1nm,
        cc_spectrum=cc_spectrum,
        cmfs=cmfs_cie2015_1nm,
        temperature=6500)

    # convert from XYZ to sRGB
    rgb = color_checker_large_xyz_to_rgb(large_xyz)

    rgb[rgb < 0] = 0
    # rgb[rgb > 1] = 1

    rgb = np.uint8(np.round(oetf_sRGB(rgb) * 255))

    # plot
    tpg.plot_color_checker_image(rgb)

    return rgb
Ejemplo n.º 2
0
def compare_spectrum_vs_chromatic_adaptation():
    """
    chromatic adaptation と スペクトルレンダリングの比較を行う。
    """
    src_k = 6500
    dst_k = 20000
    colorchecker_rgb_d65 = make_color_checker_with_temperature(src_k)
    colorchecker_rgb_xx = make_color_checker_with_temperature(dst_k)
    after_chromatic_adaptation = temperature_convert(colorchecker_rgb_d65,
                                                     src_k, dst_k, 'CAT02')
    after_without_chromatic_adaptation = temperature_convert(
        colorchecker_rgb_d65, src_k, dst_k, 'XYZ Scaling')
    max_value = np.max(
        np.array([
            colorchecker_rgb_d65, colorchecker_rgb_xx,
            after_chromatic_adaptation, after_without_chromatic_adaptation
        ]))
    colorchecker_rgb_d65 /= max_value
    colorchecker_rgb_xx /= max_value
    after_chromatic_adaptation /= max_value
    after_without_chromatic_adaptation /= max_value

    # tpg.plot_color_checker_image(linear_to_srgb_8bit(colorchecker_rgb_d65))
    # tpg.plot_color_checker_image(linear_to_srgb_8bit(colorchecker_rgb_xx))
    # tpg.plot_color_checker_image(
    #     linear_to_srgb_8bit(after_chromatic_adaptation))
    # tpg.plot_color_checker_image(
    #     linear_to_srgb_8bit(after_without_chromatic_adaptation))
    tpg.plot_color_checker_image(
        linear_to_srgb_8bit(colorchecker_rgb_xx),
        linear_to_srgb_8bit(after_chromatic_adaptation))
    tpg.plot_color_checker_image(
        linear_to_srgb_8bit(colorchecker_rgb_xx),
        linear_to_srgb_8bit(after_without_chromatic_adaptation))
Ejemplo n.º 3
0
def make_color_checker_from_spectrum():
    # get color checker spectrum
    cc_spectrum, cc_shape = load_colorchecker_spectrum()

    # get d65 spd, cie1931 cmfs
    d65_spd = load_d65_spd_1nmdata().trim(cc_shape)
    cmfs_cie1931 = load_cie1931_1nm_data().trim(cc_shape)
    d65_spd_5nm = d65_spd.values[::5, 1]
    cmfs_cie1931_5nm = cmfs_cie1931.values[::5]

    # get large xyz data from spectrum
    large_xyz = colorchecker_spectrum_to_large_xyz(d_light=d65_spd_5nm,
                                                   cc_spectrum=cc_spectrum,
                                                   cmfs=cmfs_cie1931_5nm,
                                                   temperature=6500)

    # convert from XYZ to sRGB
    rgb = color_checker_large_xyz_to_rgb(large_xyz)

    rgb[rgb < 0] = 0
    # rgb[rgb > 1] = 1

    rgb = np.uint8(np.round(oetf_sRGB(rgb) * 255))
    print(rgb)

    # plot
    tpg.plot_color_checker_image(rgb)
    # tpg.plot_color_checker_image(rgb, rgb2=np.uint8(rgb/1.1))
    return rgb
Ejemplo n.º 4
0
def plot_color_checker(cmfs_name=cm.CIE1931,
                       temperature=6500,
                       color_space=BT709_CS,
                       oetf_name=tf.SRGB):
    rgb = make_color_chekcer_value(cmfs_name=cmfs_name,
                                   temperature=temperature,
                                   color_space=color_space,
                                   oetf_name=oetf_name)
    rgb = np.uint8(np.round(rgb * 0xFF))
    tpg.plot_color_checker_image(rgb)
Ejemplo n.º 5
0
def temperature_convert_test(cmfs_name=cm.CIE1931,
                             temperature=6500,
                             color_space=SRGB_CS,
                             oetf_name=tf.SRGB):
    full_spectrum_rgb = make_color_chekcer_value(cmfs_name=cmfs_name,
                                                 temperature=temperature,
                                                 color_space=color_space,
                                                 oetf_name=oetf_name)

    base_d65_rgb_linear = make_color_chekcer_linear_value(
        cmfs_name=cmfs_name, temperature=6500, color_space=color_space)
    temp_conv_rgb_linear = cm.temperature_convert(base_d65_rgb_linear,
                                                  6500,
                                                  temperature,
                                                  chromatic_adaptation='CAT02',
                                                  color_space=color_space)
    temp_conv_rgb = tf.oetf(temp_conv_rgb_linear, oetf_name)

    full_spectrum_rgb = np.uint8(np.round(full_spectrum_rgb * 0xFF))
    temp_conv_rgb = np.uint8(np.round(temp_conv_rgb * 0xFF))
    tpg.plot_color_checker_image(full_spectrum_rgb, temp_conv_rgb)
Ejemplo n.º 6
0
def compare_1931_2015():
    rgb_1931 = make_color_checker_from_spectrum()
    rgb_2015 = make_srgb_2015_color_checker()
    tpg.plot_color_checker_image(rgb_1931, rgb_2015)