|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +
|
| 4 | +""" |
| 5 | + |
| 6 | +# import standard libraries |
| 7 | +import os |
| 8 | + |
| 9 | +# import third-party libraries |
| 10 | +import numpy as np |
| 11 | +from colour.io import write_image, read_image |
| 12 | + |
| 13 | +# import my libraries |
| 14 | +import test_pattern_generator2 as tpg |
| 15 | +import transfer_functions as tf |
| 16 | +import plot_utility as pu |
| 17 | + |
| 18 | +# information |
| 19 | +__author__ = 'Toru Yoshihara' |
| 20 | +__copyright__ = 'Copyright (C) 2022 - Toru Yoshihara' |
| 21 | +__license__ = 'New BSD License - https://opensource.org/licenses/BSD-3-Clause' |
| 22 | +__maintainer__ = 'Toru Yoshihara' |
| 23 | +__email__ = 'toru.ver.11 at-sign gmail.com' |
| 24 | + |
| 25 | +__all__ = [] |
| 26 | + |
| 27 | + |
| 28 | +def create_pq_based_ramp_exr(): |
| 29 | + width = 1920 |
| 30 | + height = 1080 |
| 31 | + out_fname = "./img/pq_based_ramp_linear.exr" |
| 32 | + x = np.linspace(0, 1, width) |
| 33 | + linear = tf.eotf_to_luminance(x, tf.ST2084) / 100 |
| 34 | + img = tpg.h_mono_line_to_img(linear, height) |
| 35 | + |
| 36 | + write_image(img, out_fname) |
| 37 | + |
| 38 | + |
| 39 | +def plot_Ae_HDR10_out_with_white(graph_name="./img/out_w203.png"): |
| 40 | + width = 1920 |
| 41 | + |
| 42 | + fname_list = [ |
| 43 | + "./img/Ae_out_Chara/Ae_out_chara_ProRes_W-none.tif", |
| 44 | + "./img/Ae_out_Chara/Ae_out_chara_ProRes_W-100.tif", |
| 45 | + "./img/Ae_out_Chara/Ae_out_chara_ProRes_W-203.tif", |
| 46 | + "./img/Ae_out_Chara/Ae_out_chara_ProRes_W-10000.tif"] |
| 47 | + profile_list = [ |
| 48 | + "Rec.2100 PQ", "Rec.2100 PQ W100", "Rec.2100 PQ W203", |
| 49 | + "Rec.2100 PQ W10000"] |
| 50 | + |
| 51 | + def get_linear(fname): |
| 52 | + img = tpg.img_read_as_float(fname) |
| 53 | + x_ae = img[0, :, 1] # extract Green line data |
| 54 | + ae_luminance = tf.eotf_to_luminance(x_ae, tf.ST2084) |
| 55 | + return ae_luminance |
| 56 | + |
| 57 | + chara_list = [get_linear(fname) for fname in fname_list] |
| 58 | + |
| 59 | + x = np.linspace(0, 1, width) |
| 60 | + ref_luminance = tf.eotf_to_luminance(x, tf.ST2084) |
| 61 | + |
| 62 | + fig, ax1 = pu.plot_1_graph( |
| 63 | + fontsize=20, |
| 64 | + figsize=(10, 8), |
| 65 | + bg_color=(0.96, 0.96, 0.96), |
| 66 | + graph_title="Ae In-Out Characteristics (ProRes 4444)", |
| 67 | + graph_title_size=None, |
| 68 | + xlabel="Input Luminance [cd/m2]", |
| 69 | + ylabel="Output LUminance [cd/m2]", |
| 70 | + axis_label_size=None, |
| 71 | + legend_size=17, |
| 72 | + xlim=[0.009, 15000], |
| 73 | + ylim=[0.009, 15000], |
| 74 | + xtick=None, |
| 75 | + ytick=None, |
| 76 | + xtick_size=None, ytick_size=None, |
| 77 | + linewidth=3, |
| 78 | + minor_xtick_num=None, |
| 79 | + minor_ytick_num=None) |
| 80 | + pu.log_scale_settings(ax1=ax1) |
| 81 | + for idx, y in enumerate(chara_list): |
| 82 | + ax1.plot(ref_luminance, y, label=profile_list[idx]) |
| 83 | + pu.show_and_save( |
| 84 | + fig=fig, legend_loc='upper left', save_fname=graph_name, |
| 85 | + show=False) |
| 86 | + |
| 87 | + |
| 88 | +def plot_Ae_HDR10_exr_out_with_white(graph_name="./img/out.png"): |
| 89 | + width = 1920 |
| 90 | + |
| 91 | + fname_list = [ |
| 92 | + "./AfterEffects/Comp 1/Comp 1_W-none_00000.exr", |
| 93 | + "./AfterEffects/Comp 1/Comp 1_W-100_00000.exr", |
| 94 | + "./AfterEffects/Comp 1/Comp 1_W-203_00000.exr", |
| 95 | + "./AfterEffects/Comp 1/Comp 1_W-10000_00000.exr"] |
| 96 | + profile_list = [ |
| 97 | + "Rec.2100 PQ", "Rec.2100 PQ W100", "Rec.2100 PQ W203", |
| 98 | + "Rec.2100 PQ W10000"] |
| 99 | + |
| 100 | + def get_linear(fname): |
| 101 | + img = read_image(fname) |
| 102 | + x_ae = img[0, :, 1] # extract Green line data |
| 103 | + ae_luminance = x_ae * 100 |
| 104 | + return ae_luminance |
| 105 | + |
| 106 | + chara_list = [get_linear(fname) for fname in fname_list] |
| 107 | + |
| 108 | + x = np.linspace(0, 1, width) |
| 109 | + ref_luminance = tf.eotf_to_luminance(x, tf.ST2084) |
| 110 | + |
| 111 | + fig, ax1 = pu.plot_1_graph( |
| 112 | + fontsize=20, |
| 113 | + figsize=(10, 8), |
| 114 | + bg_color=(0.96, 0.96, 0.96), |
| 115 | + graph_title="Ae In-Out Characteristics (EXR Linear)", |
| 116 | + graph_title_size=None, |
| 117 | + xlabel="Input Luminance [cd/m2]", |
| 118 | + ylabel="Output LUminance [cd/m2]", |
| 119 | + axis_label_size=None, |
| 120 | + legend_size=17, |
| 121 | + xlim=[0.009, 15000], |
| 122 | + ylim=[0.009, 15000], |
| 123 | + xtick=None, |
| 124 | + ytick=None, |
| 125 | + xtick_size=None, ytick_size=None, |
| 126 | + linewidth=3, |
| 127 | + minor_xtick_num=None, |
| 128 | + minor_ytick_num=None) |
| 129 | + pu.log_scale_settings(ax1=ax1) |
| 130 | + for idx, y in enumerate(chara_list): |
| 131 | + ax1.plot(ref_luminance, y, label=profile_list[idx]) |
| 132 | + pu.show_and_save( |
| 133 | + fig=fig, legend_loc='upper left', save_fname=graph_name, |
| 134 | + show=False) |
| 135 | + |
| 136 | + |
| 137 | +def plot_Ae_HDR10_exr_nl_out_with_white(graph_name="./img/out.png"): |
| 138 | + width = 1920 |
| 139 | + |
| 140 | + fname_list = [ |
| 141 | + "./AfterEffects/Comp 1/Comp 1_NL_W-none_00000.exr", |
| 142 | + "./AfterEffects/Comp 1/Comp 1_NL_W-100_00000.exr", |
| 143 | + "./AfterEffects/Comp 1/Comp 1_NL_W-203_00000.exr", |
| 144 | + "./AfterEffects/Comp 1/Comp 1_NL_W-10000_00000.exr"] |
| 145 | + profile_list = [ |
| 146 | + "Rec.2100 PQ", "Rec.2100 PQ W100", "Rec.2100 PQ W203", |
| 147 | + "Rec.2100 PQ W10000"] |
| 148 | + |
| 149 | + def get_linear(fname): |
| 150 | + img = read_image(fname) |
| 151 | + x_ae = img[0, :, 1] # extract Green line data |
| 152 | + ae_luminance = tf.eotf_to_luminance(x_ae, tf.ST2084) |
| 153 | + return ae_luminance |
| 154 | + |
| 155 | + chara_list = [get_linear(fname) for fname in fname_list] |
| 156 | + |
| 157 | + x = np.linspace(0, 1, width) |
| 158 | + ref_luminance = tf.eotf_to_luminance(x, tf.ST2084) |
| 159 | + |
| 160 | + fig, ax1 = pu.plot_1_graph( |
| 161 | + fontsize=20, |
| 162 | + figsize=(10, 8), |
| 163 | + bg_color=(0.96, 0.96, 0.96), |
| 164 | + graph_title="Ae In-Out Characteristics (EXR Non-linear)", |
| 165 | + graph_title_size=None, |
| 166 | + xlabel="Input Luminance [cd/m2]", |
| 167 | + ylabel="Output LUminance [cd/m2]", |
| 168 | + axis_label_size=None, |
| 169 | + legend_size=17, |
| 170 | + xlim=[0.009, 15000], |
| 171 | + ylim=[0.009, 15000], |
| 172 | + xtick=None, |
| 173 | + ytick=None, |
| 174 | + xtick_size=None, ytick_size=None, |
| 175 | + linewidth=3, |
| 176 | + minor_xtick_num=None, |
| 177 | + minor_ytick_num=None) |
| 178 | + pu.log_scale_settings(ax1=ax1) |
| 179 | + for idx, y in enumerate(chara_list): |
| 180 | + ax1.plot(ref_luminance, y, label=profile_list[idx]) |
| 181 | + pu.show_and_save( |
| 182 | + fig=fig, legend_loc='upper left', save_fname=graph_name, |
| 183 | + show=False) |
| 184 | + |
| 185 | + |
| 186 | +def plot_Ae_HDR10_exr_nl_out_vari_prj_white(graph_name="./img/out.png"): |
| 187 | + """ |
| 188 | + Plot transfer characteristics of the working color space. |
| 189 | + Output color space is fixed to "Rec.2100 PQ" (with no white point). |
| 190 | + """ |
| 191 | + width = 1920 |
| 192 | + |
| 193 | + fname_list = [ |
| 194 | + "./AfterEffects/Comp 1/prj_w_W-none _00000.exr", |
| 195 | + "./AfterEffects/Comp 1/prj_w_W-100 _00000.exr", |
| 196 | + "./AfterEffects/Comp 1/prj_w_W-203 _00000.exr", |
| 197 | + "./AfterEffects/Comp 1/prj_w_W-10000 _00000.exr", |
| 198 | + ] |
| 199 | + profile_list = [ |
| 200 | + "Rec.2100 PQ", |
| 201 | + "Rec.2100 PQ W100", |
| 202 | + "Rec.2100 PQ W203", |
| 203 | + "Rec.2100 PQ W10000" |
| 204 | + ] |
| 205 | + |
| 206 | + def get_linear(fname): |
| 207 | + img = read_image(fname) |
| 208 | + x_ae = img[0, :, 1] # extract Green line data |
| 209 | + ae_luminance = tf.eotf_to_luminance(x_ae, tf.ST2084) |
| 210 | + return ae_luminance |
| 211 | + |
| 212 | + chara_list = [get_linear(fname) for fname in fname_list] |
| 213 | + |
| 214 | + x = np.linspace(0, 1, width) |
| 215 | + ref_luminance = tf.eotf_to_luminance(x, tf.ST2084) |
| 216 | + |
| 217 | + fig, ax1 = pu.plot_1_graph( |
| 218 | + fontsize=20, |
| 219 | + figsize=(10, 8), |
| 220 | + bg_color=(0.96, 0.96, 0.96), |
| 221 | + graph_title="Transfer characteristics of the working color space", |
| 222 | + graph_title_size=None, |
| 223 | + xlabel="Input Luminance [cd/m2]", |
| 224 | + ylabel="Output LUminance [cd/m2]", |
| 225 | + axis_label_size=None, |
| 226 | + legend_size=17, |
| 227 | + xlim=[0.009, 15000], |
| 228 | + ylim=[0.009, 15000], |
| 229 | + xtick=None, |
| 230 | + ytick=None, |
| 231 | + xtick_size=None, ytick_size=None, |
| 232 | + linewidth=3, |
| 233 | + minor_xtick_num=None, |
| 234 | + minor_ytick_num=None) |
| 235 | + pu.log_scale_settings(ax1=ax1) |
| 236 | + for idx, y in enumerate(chara_list): |
| 237 | + ax1.plot(ref_luminance, y, label=profile_list[idx]) |
| 238 | + pu.show_and_save( |
| 239 | + fig=fig, legend_loc='upper left', save_fname=graph_name, |
| 240 | + show=False) |
| 241 | + |
| 242 | + |
| 243 | +if __name__ == '__main__': |
| 244 | + os.chdir(os.path.dirname(os.path.abspath(__file__))) |
| 245 | + # create_pq_based_ramp_exr() |
| 246 | + # plot_Ae_HDR10_out_with_white( |
| 247 | + # graph_name="./img/Ae_Out_ProRes.png") |
| 248 | + # plot_Ae_HDR10_exr_out_with_white( |
| 249 | + # graph_name="./img/Ae_Out_Exr_L.png") |
| 250 | + # plot_Ae_HDR10_exr_nl_out_with_white( |
| 251 | + # graph_name="./img/Ae_Out_Exr_NL_png") |
| 252 | + plot_Ae_HDR10_exr_nl_out_vari_prj_white( |
| 253 | + graph_name="./img/Ae_working_space_tf.png") |
0 commit comments