Exemplo n.º 1
0
    def draw_csf_pattern(self):
        """
        Limited Range 確認用のパターンを追加。
        """
        lv_0 = np.array([0, 0, 0], dtype=np.uint16)
        lv_64 = np.array([64, 64, 64], dtype=np.uint16)
        lv_940 = np.array([940, 940, 940], dtype=np.uint16)
        lv_1023 = np.array([1023, 1023, 1023], dtype=np.uint16)
        width = int(self.csf_img_size_coef * self.img_width)
        num = 2
        low_img = tpg.make_csf_color_image(width, width, lv_0, lv_64, num)
        high_img = tpg.make_csf_color_image(width, width, lv_940, lv_1023, num)

        high_img = tpg.make_tile_pattern(width=width,
                                         height=width,
                                         h_tile_num=4,
                                         v_tile_num=4,
                                         low_level=lv_940,
                                         high_level=lv_1023)
        low_img = tpg.make_tile_pattern(width=width,
                                        height=width,
                                        h_tile_num=4,
                                        v_tile_num=4,
                                        low_level=lv_0,
                                        high_level=lv_64)

        st_pos_h = int(self.csf_img_low_st_pos_h_coef * self.img_width)
        st_pos_v = int(self.csf_img_st_pos_v_coef * self.img_height)
        csf_img_pos = (st_pos_h, st_pos_v)
        tpg.merge(self.img, low_img, csf_img_pos)

        st_pos_h = int(self.csf_img_high_st_pos_h_coef * self.img_width)
        csf_img_pos = (st_pos_h, st_pos_v)
        tpg.merge(self.img, high_img, csf_img_pos)
Exemplo n.º 2
0
    def draw_color_checker(self):
        # 基本パラメータ算出
        # --------------------------------------
        h_num = 6
        v_num = 4
        patch_width = int(self.color_checker_size_coef * self.img_width)
        patch_height = patch_width
        patch_space = int(self.color_checker_padding_coef * self.img_width)
        img_width = patch_width * h_num + patch_space * (h_num - 1)
        img_height = patch_height * v_num + patch_space * (v_num - 1)
        rgb = self.get_color_checker_rgb_value()
        st_pos_h = int(self.color_checker_st_pos_h_coef * self.img_width)
        st_pos_v = int(self.color_checker_st_pos_v_coef * self.img_height)
        pos = (st_pos_h, st_pos_v)
        text = "▼ Color Checker"
        text_height, font_size = self.get_each_spec_text_height_and_size()
        text_pos = self.get_text_st_pos_for_over_info(pos, text_height)

        # 24ループで1枚の画像に24パッチを描画
        # -------------------------------------------------
        img_all_patch = np.zeros((img_height, img_width, 3))
        for idx in range(h_num * v_num):
            v_idx = idx // h_num
            h_idx = (idx % h_num)
            patch = np.ones((patch_height, patch_width, 3))
            patch[:, :] = rgb[idx]
            st_h = (patch_width + patch_space) * h_idx
            st_v = (patch_height + patch_space) * v_idx
            img_all_patch[st_v:st_v+patch_height, st_h:st_h+patch_width]\
                = patch

        tpg.merge(self.img, img_all_patch, pos)
        self.merge_each_spec_text(text_pos, font_size,
                                  (img_width, text_height), text)
Exemplo n.º 3
0
    def draw_dot_mesh(self):
        """
        dot mesh パターンを描画。
        """
        # UHD画像の場合はトリミングを行う
        triming = True if self.img_height != 1080 else False

        kind_num = 2 if self.img_height == 1080 else 3
        fg_color_list = [[1.0, 1.0, 1.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0],
                         [0.0, 0.0, 1.0]]
        fg_color_list = np.uint16(np.array(fg_color_list) * self.img_max)
        bg_color = np.uint16(
            np.array([self.get_bg_code_value() for x in range(3)]))

        args = {'kind_num': kind_num, 'whole_repeat': 1, 'bg_color': bg_color}
        dot_img_list = []
        for idx in range(4):
            args['fg_color'] = fg_color_list[idx]
            temp_img = tpg.complex_dot_pattern(**args)
            if triming:
                length = (temp_img.shape[0] // 3) * 2
                temp_img = temp_img[:length, :length, :]
            dot_img_list.append(temp_img)
        dot_img = np.hstack(dot_img_list)
        st_pos_h = int(self.dot_img_st_pos_h_coef * self.img_width)
        st_pos_v = int(self.dot_img_st_pos_v_coef * self.img_height)
        dot_img_pos = (st_pos_h, st_pos_v)
        tpg.merge(self.img, dot_img, pos=dot_img_pos)
Exemplo n.º 4
0
    def draw_8bit_10bit_checker(self, bit_depth='8bit', pos_v_coef=0.5):
        """
        256~768 の 8bit/10bitのRampパターンを描く
        """
        # パラメータ計算
        width = self.get_bit_depth_checker_grad_width()
        height = int(self.img_height * self.ramp_height_coef)
        grad_st_pos_h, grad_ed_pos_h = self.get_bit_depth_checker_grad_st_ed()
        width_after_trim = grad_ed_pos_h - grad_st_pos_h
        ramp_st_pos_h = self.get_ramp_st_pos_h(width_after_trim)
        ramp_st_pos_v = int(self.img_height * pos_v_coef)
        ramp_pos = (ramp_st_pos_h, ramp_st_pos_v)
        text_height, font_size = self.get_each_spec_text_height_and_size()
        text_8 = "8bit gray ramp (256, 260, 264, ..., 756, 760, 764 level)."
        text_10 = "10bit gray ramp (256, 257, 258, ..., 765, 766, 767 level)."
        text_sub = text_8 if bit_depth == '8bit' else text_10
        text = "▼ " + text_sub
        text_pos = self.get_text_st_pos_for_over_info(ramp_pos, text_height)

        # ramp パターン作成
        step_num = 257 if bit_depth == '8bit' else 1025
        ramp = tpg.gen_step_gradation(width=width,
                                      height=height,
                                      step_num=step_num,
                                      bit_depth=self.bit_depth,
                                      color=(1.0, 1.0, 1.0),
                                      direction='h')
        tpg.merge(self.img, ramp[:, grad_st_pos_h:grad_ed_pos_h], pos=ramp_pos)
        self.merge_each_spec_text(text_pos, font_size,
                                  (width_after_trim, text_height), text)
Exemplo n.º 5
0
    def draw_10bit_ramp(self):
        """
        10bitのRampパターンを描く
        """
        global g_cuurent_pos_v

        # パラメータ計算
        width = (self.img_height // 1080) * 1024
        height = int(self.img_height * self.ramp_height_coef)
        ramp_st_pos_h = self.get_ramp_st_pos_h(width)
        ramp_st_pos_v = int(self.img_height * self.ramp_st_pos_v_coef)
        ramp_pos = (ramp_st_pos_h, ramp_st_pos_v)
        text_height, font_size = self.get_each_spec_text_height_and_size()
        text_sub = " 10bit gray ramp (0, 1, 2, ..., 1021, 1022, 1023 level)."
        text = "▼" + text_sub
        text_pos = self.get_text_st_pos_for_over_info(ramp_pos, text_height)

        # ramp パターン作成
        ramp_10bit = tpg.gen_step_gradation(width=width,
                                            height=height,
                                            step_num=1025,
                                            bit_depth=self.bit_depth,
                                            color=(1.0, 1.0, 1.0),
                                            direction='h')
        tpg.merge(self.img, ramp_10bit, pos=ramp_pos)
        self.merge_each_spec_text(text_pos, font_size, (width, text_height),
                                  text)
Exemplo n.º 6
0
    def draw_ycbcr_err_checker(self):
        width = int(self.ycbcr_img_size_coef * self.img_width)
        img = tpg.make_ycbcr_checker(height=width, v_tile_num=4)

        st_pos_h = int(self.ycbcr_img_st_pos_h_coef * self.img_width)
        st_pos_v = int(self.ycbcr_img_st_pos_v_coef * self.img_height)
        ycbcr_img_pos = (st_pos_h, st_pos_v)
        tpg.merge(self.img, img, ycbcr_img_pos)
Exemplo n.º 7
0
    def draw_wrgbmyc_color_bar_type2(self):
        """
        階段状のカラーバーをプロットする
        """
        scale_step = 257
        color_list = [(1, 1, 1)]
        width = int(self.img_width * self.step_bar_width_coef_type2) * 4
        height = int(self.img_height * self.step_bar_height_coef_type2)
        vspace = int(self.img_height * self.step_bar_v_space_coef_type2)
        color_bar_st_pos_h = int(self.img_width *
                                 self.step_bar_st_pos_h_coef_type2)
        color_bar_st_pos_v = int(self.img_height *
                                 self.step_bar_st_pos_v_coef_type2)
        st_pos = (color_bar_st_pos_h, color_bar_st_pos_v)

        bar_height_list = tpg.equal_devision(height, len(color_list))
        bar_img_list = []
        for color, bar_height in zip(color_list, bar_height_list):
            color_bar = tpg.gen_step_gradation(width=width,
                                               height=bar_height,
                                               step_num=scale_step,
                                               bit_depth=self.bit_depth,
                                               color=color,
                                               direction='h')
            bar_img_list.append(color_bar)
        color_bar = np.vstack(bar_img_list)

        # テキストデータ作成
        txt_img = self.get_video_level_text_img(scale_step, width, type=2)

        # 最終データだけ削除(後で4分割できるように)
        width = int(round(width / 257 * 256))
        color_bar = color_bar[:, :width, :]
        txt_img = txt_img[:, :width, :]

        for idx in range(4):
            img_pos_h = (width // 4) * idx
            img_merge_width = (width // 4)
            color_bar_temp = color_bar[:,
                                       img_pos_h:img_pos_h + img_merge_width]
            txt_img_temp = txt_img[:, img_pos_h:img_pos_h + img_merge_width]
            tpg.merge(self.img, color_bar_temp, st_pos)
            text_pos = self.get_text_st_pos_for_over_info(
                st_pos, txt_img.shape[0])
            self.merge_text(txt_img_temp, text_pos)
            st_pos = (st_pos[0], st_pos[1] + vspace)
Exemplo n.º 8
0
def get_reiwa_color():
    """
    reiwa color を得たい。
    梅:3.4RP7.4/6.8
    菫:7.1P2.9/3
    桜:2.8RP8.8/2.7
    """
    ume = "3.4RP 7.4/6.8"
    sumire = "7.1P 2.9/3"
    sakura = "2.8RP 8.8/2.7"
    reiwa_munsell_colors = [ume, sumire, sakura]
    reiwa_xyY_colors = [munsell_colour_to_xyY(x) for x in reiwa_munsell_colors]
    reiwa_rgb_colors = [
        xyY_to_rgb_with_illuminant_c(xyY) for xyY in reiwa_xyY_colors
    ]
    reiwa_rgb_colors = np.array(
        [np.round((oetf_sRGB(rgb)) * 255) for rgb in reiwa_rgb_colors])
    reiwa_rgb_colors = np.uint8(reiwa_rgb_colors)

    # preview
    img = np.ones((720, 1280, 3), dtype=np.uint8) * 255
    ume = np.ones((200, 200, 3), dtype=np.uint8) * reiwa_rgb_colors[0]
    sumire = np.ones((200, 200, 3), dtype=np.uint8) * reiwa_rgb_colors[1]
    sakura = np.ones((200, 200, 3), dtype=np.uint8) * reiwa_rgb_colors[2]
    tpg.merge(img, ume, (100, 100))
    tpg.merge(img, sumire, (400, 100))
    tpg.merge(img, sakura, (700, 100))
    tpg.preview_image(img)
    print(reiwa_rgb_colors)
Exemplo n.º 9
0
    def draw_wrgbmyc_color_bar(self):
        """
        階段状のカラーバーをプロットする
        """
        scale_step = 65
        color_list = [(1, 1, 1), (1, 1, 1), (1, 0, 0), (0, 1, 0), (0, 0, 1),
                      (1, 0, 1), (1, 1, 0), (0, 1, 1)]
        width = int(self.img_width * self.step_bar_width_coef)
        height = int(self.img_height * self.step_bar_height_coef)
        color_bar_st_pos_h = self.get_color_bar_st_pos_h(width)
        color_bar_st_pos_v = int(self.img_height * self.step_bar_st_pos_v_coef)
        st_pos = (color_bar_st_pos_h, color_bar_st_pos_v)

        bar_height_list = tpg.equal_devision(height, len(color_list))
        bar_img_list = []
        for color, bar_height in zip(color_list, bar_height_list):
            color_bar = tpg.gen_step_gradation(width=width,
                                               height=bar_height,
                                               step_num=scale_step,
                                               bit_depth=self.bit_depth,
                                               color=color,
                                               direction='h')
            bar_img_list.append(color_bar)
        color_bar = np.vstack(bar_img_list)
        tpg.merge(self.img, color_bar, st_pos)

        # ここからテキスト。あらかじめV方向で作っておき、最後に回転させる
        txt_img = self.get_video_level_text_img(scale_step, width)
        text_pos = self.get_text_st_pos_for_over_info(st_pos, txt_img.shape[0])
        self.merge_text(txt_img, text_pos)

        # 説明文を下に追加する
        text_pos_v = st_pos[1] + color_bar.shape[0]
        text_pos = (st_pos[0], text_pos_v)
        text_height, font_size = self.get_each_spec_text_height_and_size()
        level_text = " (0, 16, 32, ..., 992, 1008, 1023 Level)"
        text = "▲ WRGBMYC Color Gradation" + level_text
        self.merge_each_spec_text(text_pos, font_size, (width, text_height),
                                  text)
Exemplo n.º 10
0
def resolve_bt709_checker():
    """
    Davinci Resolve で Linear の
    0.0, 0.18, 0.20, 0.90, 1.00 が
    BT.709 では、どの Code Value にマッピングされるか確認する。
    """
    img = np.zeros((1080, 1920, 3), dtype=np.float64)
    base_patch = np.ones((300, 300, 3), dtype=np.float64)

    p018 = base_patch * 0.18
    p020 = base_patch * 0.20
    p090 = base_patch * 0.90
    p100 = base_patch * 1.00

    tpg.merge(img, p018, (300, 300))
    tpg.merge(img, p020, (700, 300))
    tpg.merge(img, p090, (300, 700))
    tpg.merge(img, p100, (700, 700))

    # tpg.preview_image(img)
    writer = tyio.TyWriter(img, "hoge.exr")
    writer.write(out_img_type_desc=oiio.FLOAT)