def make_cinema_picture_on_sRGB(): """ 1000nits と 108nits の Output Transform を当てた画像を sRGB のガンマに載せ替えて普通のモニターで見られるようにする。 """ # 作成済みの TestPattern に OutputTransform を適用 src_img_name = "./src_img/src_bt2020_to_ap0.exr" ctl_108 = [OUTPUT_TRANS_P3D65_108NITS_CTL] ctl_1000 = [OUTPUT_TRANS_BT2020_1000NITS_CTL] ot_108_img = get_after_ctl_image(src_img_name, ctl_108)[:, :, :3] ot_1000_img = get_after_ctl_image(src_img_name, ctl_1000)[:, :, :3] # Linear に戻す ot_108_img = tf.eotf_to_luminance(ot_108_img, tf.ST2084) / 108 ot_1000_img = tf.eotf_to_luminance(ot_1000_img, tf.ST2084) / 1000 # clipping ot_108_img = np.clip(ot_108_img, 0.0, 1.0) ot_1000_img = np.clip(ot_1000_img, 0.0, 1.0) # sRGB がガンマに載せ替える ot_108_img = tf.oetf(ot_108_img, tf.SRGB) ot_1000_img = tf.oetf(ot_1000_img, tf.SRGB) # 保存 cv2.imwrite("./108_sRGB.png", np.uint8(np.round(ot_108_img * 0xFF))[:, :, ::-1]) cv2.imwrite("./1000_sRGB.png", np.uint8(np.round(ot_1000_img * 0xFF))[:, :, ::-1])
def make_primary_value_on_ap0(oetf=tf.GAMMA24): """ 各種カラースペースの RGB Primary値が AP0 ではどの値になるかを計算する。 """ cs_name_list = [cs.BT709, cs.P3_D65, cs.BT2020, cs.ACES_AP1, cs.ACES_AP0] dst_cs = RGB_COLOURSPACES[cs.ACES_AP0] src_primaries = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] src_primaries = np.array(src_primaries) dst_primaries = {} for src_cs_name in cs_name_list: src_cs = RGB_COLOURSPACES[src_cs_name] chromatic_acaptation = "XYZ Scaling" temp = RGB_to_RGB(src_primaries, src_cs, dst_cs, chromatic_acaptation) if src_cs_name == cs.ACES_AP0: cs_name = "ACES_AP0" elif src_cs_name == cs.ACES_AP1: cs_name = "ACES_AP1" else: cs_name = src_cs_name temp = np.clip(temp, 0.0, 1.0) dst_primaries[cs_name] = tf.oetf(temp, oetf) return dst_primaries
def plot_log_stops(): # oetf_list = [tf.LOGC, tf.SLOG3, tf.DLOG, tf.FLOG, tf.NLOG] oetf_list = [tf.LOGC, tf.SLOG3_REF] ax1 = pu.plot_1_graph(fontsize=20, figsize=(16, 10), graph_title="Characteristics of the camera log", graph_title_size=None, xlabel="Exposure [stops].", ylabel="10bit code value", axis_label_size=None, legend_size=19, xlim=[-8, 8], ylim=[0, 1024], xtick=[x for x in range(-8, 9)], ytick=[x * 128 for x in range(9)], xtick_size=None, ytick_size=None, linewidth=3) # centerd_spins(ax1) for oetf_name in oetf_list: x_max = tf.MAX_VALUE[oetf_name] x = get_log_scale_x(sample_num=64, x_max=x_max, stops=20) x2 = x / 0.20 if oetf_name == tf.SLOG3 else x / 0.18 y = tf.oetf(x / x_max, oetf_name) * 1023 ax1.plot(np.log2(x2), y, '-o', label=oetf_name) # Plot A-Log alog = ALOG_DATA x = get_log_scale_x(sample_num=64, x_max=ALOG_MAX, stops=20) x2 = x / 0.18 ax1.plot(np.log2(x2), alog, '-o', label="Astrodesign A-Log??") plt.legend(loc='upper left') plt.savefig('camera_logs.png', bbox_inches='tight', pad_inches=0.1) plt.show()
def plot_from_white_to_primary_rgb_value(primary_color='green', step=5, name=cs.BT709, oetf_name=tf.GAMMA24): xy = calc_xy_from_white_to_primary_n_step(name=name, step=step, color=primary_color) linear_rgb = get_normalize_rgb_value_from_small_xy(xy, cs.ACES_AP1) rgb = tf.oetf(linear_rgb, oetf_name) plot_chromaticity_diagram(rate=480/755.0*2, xmin=-0.1, xmax=0.8, ymin=-0.1, ymax=1.05, test_scatter=(xy, rgb), white_point=D65_WHITE)
def make_color_chekcer_value(cmfs_name=cm.CIE1931, temperature=6500, color_space=SRGB_CS, oetf_name=tf.SRGB): """ color checker を OETF でエンコードしたRGB値を作る。 """ linear_rgb = make_color_chekcer_linear_value(cmfs_name=cmfs_name, temperature=temperature, color_space=color_space) encoded_rgb = tf.oetf(linear_rgb, oetf_name) return encoded_rgb
def get_from_white_to_primary_rgb_value(primary_color='green', step=5, name=cs.BT709, oetf_name=tf.GAMMA24): """ >>> get_from_white_to_primary_rgb_value( >>> 'green', step=5, name=cs.BT709, oetf_name=tf.GAMMA24) [[1023 1023 1023] [ 792 1023 792] [ 603 1023 603] [ 416 1023 416] [ 0 1023 0]] """ xy = calc_xy_from_white_to_primary_n_step(name=name, step=step, color=primary_color) linear_rgb = get_normalize_rgb_value_from_small_xy(xy) rgb = np.int16(np.round(tf.oetf(linear_rgb, oetf_name) * 1023)) return rgb
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)
def get_color_checker_rgb_value(self): """ 24パターンの Color Checker の RGB値を得る """ colour_checker_param = colour.COLOURCHECKERS.get('ColorChecker 2005') # 今回の処理では必要ないデータもあるので xyY と whitepoint だけ抽出 # ------------------------------------------------------------- _name, data, whitepoint = colour_checker_param temp_xyY = [] for key in data.keys(): temp_xyY.append(data[key]) temp_xyY = np.array(temp_xyY) large_xyz = colour.models.xyY_to_XYZ(temp_xyY) rgb_white_point\ = colour.colorimetry.ILLUMINANTS['cie_2_1931'][self.white_point] illuminant_XYZ = whitepoint # ColorCheckerのオリジナルデータの白色点 illuminant_RGB = rgb_white_point # RGBの白色点を設定 chromatic_adaptation_transform = 'CAT02' large_xyz_to_rgb_matrix\ = tpg.get_xyz_to_rgb_matrix(self.color_space.name) # large_xyz_to_rgb_matrix = self.color_space.XYZ_to_RGB_matrix rgb = colour.models.XYZ_to_RGB(large_xyz, illuminant_XYZ, illuminant_RGB, large_xyz_to_rgb_matrix, chromatic_adaptation_transform) # overflow, underflow check # ----------------------------- rgb[rgb < 0.0] = 0.0 rgb[rgb > 1.0] = 1.0 point_100nits = 100 / tf.PEAK_LUMINANCE[self.transfer_function] rgb = tf.oetf(rgb * point_100nits, self.transfer_function) rgb = np.uint16(np.round(rgb * self.img_max)) return rgb