0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

測色計の測定結果をRGBに変換してPC上に色を再現する

0
Last updated at Posted at 2019-07-10

目的

  • 色測定(Lab出力)の結果を感覚的に分かるように保管したかった

結果

  • 実物と比較すると違和感が拭えないが、、、まあいいか!
  • おそらく、測定器、変換式、モニタ再現性、表面の質感データが失われていることが要因なのでこれで手打ちとする

コード


LAB_data = (23.0, 19.2, 30.5)
im = np.full((100,100,3), (int(LAB_data[0] * 255 / 100), int(LAB_data[1]*127/60+128), int(LAB_data[2]*127/60 + 128)), dtype='uint8')

im_cnvrt = cv2.cvtColor(im, cv2.COLOR_LAB2RGB)
plt.imshow(im_cnvrt)


print('Lab測定結果', LAB_data,'-->  Labデータのuint8変換', im[50,50],' --> RGB変換', im_cnvrt[50,50])

sample.PNG


# LAB data
L = 15
r=2
num = 7

LAB_data_list = [(L, r * np.sin(np.pi/num * i), r * np.cos(np.pi/num * i)) for i in range(num + 1)]


# %%
# plot_base

black_patch = np.full((100,100,3), (0, 0, 0), dtype='uint8')
white_patch = np.full((100,100,3), (255, 255, 255), dtype='uint8')


# %%
fig, ax = plt.subplots(5, num+1, dpi=600)
ax = ax.flatten()


def Lab2RBG(LAB_row_data):
    im = np.full((100,100,3), (int(LAB_row_data[0] * 255 / 100), int(LAB_row_data[1]*127/60+128), int(LAB_row_data[2]*127/60 + 128)), dtype='uint8')
    return cv2.cvtColor(im, cv2.COLOR_LAB2RGB)



for k in range(5):
    for i in range(num+1):
        if k == 0:
            temp_img = np.concatenate([black_patch, white_patch, Lab2RBG(LAB_data_list[i])], axis=1)

        elif k == 1:
            temp_img = np.concatenate([white_patch[:,:50], black_patch, Lab2RBG(LAB_data_list[i]), white_patch[:,51:]], axis=1)

        else:
            temp_img = np.concatenate([black_patch, np.full((100, 15 * k -1 ,3), 255, dtype='uint8'), Lab2RBG(LAB_data_list[i])], axis=1)

            for m in range(1, 15 * (k)):
                temp_img[:, 99 + m] = Lab2RBG(LAB_data_list[i])[50,50] / (15 * k) * m

        ax[k * (num+1) + i].imshow(temp_img)
        ax[k * (num+1) + i].set_xticks([])
        ax[k * (num+1) + i].set_yticks([])


0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?