GeoVectorMatrix / Dif-Fusion

Codes for the Dif-Fusion model
96 stars 4 forks source link

作者你好!关于文章中提到的评估指标 #18

Closed salted55 closed 6 months ago

salted55 commented 6 months ago

文章中的评估指标ΔE,有没有具体的代码实现。感谢您的解惑!

GeoVectorMatrix commented 6 months ago

To evaluate, we can use the pyciede2000 package together with skimage. The demo code is as follows:

 from pyciede2000 import ciede2000
 from skimage import io, color

 compared_list = []
 for i in range(len(filenames_fused)):
     fused = io.imread(filepath_fused[i])  # fused-images
     ref = io.imread(filepath_ref[i])      # ref-images
     w, h, d = fused.shape
     l = w*h
     rgb_lab = color.rgb2lab(fused)
     ref_lab = color.rgb2lab(ref)
     rgb_lab = rgb_lab.reshape((l, 3))
     rgb_tp = tuple(map(tuple, rgb_lab))
     ref_lab = ref_lab.reshape((l, 3))
     ref_tp = tuple(map(tuple, ref_lab))
     s = 0
     for j in range(l):
         res = ciede2000(rgb_tp[j], ref_tp[j])
         s = s + res['delta_E_00']  #  ciede2000.delta_e(image1_lab, image2_lab)

     compared_list.append(s/l)

 comapred_array = np.asarray(compared_list)
 print(np.average(comapred_array))
 print(np.var(comapred_array))
 np.savetxt('de.txt', comapred_array, delimiter="\r\n", fmt='%1.8f')