def main(): # ---- open the reference image rgb_img = Image.open('../../../../img/img01.jpg') n_colors_list = range(1, 21) testimg_list = [] for i in n_colors_list: result = median_cut(rgb_img, i) testimg_list.append(result) # ---- rescale the reference image into [0,1] rgb_raster = np.array(rgb_img) rescale_rgb_raster = rgb_raster / 255.0 # ---- compute 4 IQAs PSNR_score_list = psnr_list(rescale_rgb_raster, testimg_list) SSIM_score_list = ssim_list(rescale_rgb_raster, testimg_list) VIF_score_list = vif_list(rescale_rgb_raster, testimg_list) GMSD_score_list = gmsd_list(rescale_rgb_raster, testimg_list) # ----- build the framework and save csv score_dic = { "PSNR": PSNR_score_list, "SSIM": SSIM_score_list, "VIF": VIF_score_list, "GMSD": GMSD_score_list } score_table = DataFrame(score_dic) score_table.to_csv('rgb_results/01score_table.csv')
def main(): path_pics = '../../../../img/test_image' pic_list = open_pics(path_pics) for pic_nam, pic_path in pic_list: # ---- open the reference image rgb_img = Image.open(pic_path) n_colors_list = range(1, 21) testimg_list = [] for i in n_colors_list: result = octree_quantize(rgb_img, i) testimg_list.append(result) # ---- rescale the reference image into [0,1] rgb_raster = np.array(rgb_img) rescale_rgb_raster = rgb_raster / 255.0 # ---- compute 4 IQAs PSNR_score_list = psnr_list(rescale_rgb_raster, testimg_list) SSIM_score_list = ssim_list(rescale_rgb_raster, testimg_list) VIF_score_list = vif_list(rescale_rgb_raster, testimg_list) GMSD_score_list = gmsd_list(rescale_rgb_raster, testimg_list) # ----- build the framework and save csv score_dic = { "PSNR": PSNR_score_list, "SSIM": SSIM_score_list, "VIF": VIF_score_list, "GMSD": GMSD_score_list } score_table = DataFrame(score_dic) score_table.to_csv('rgb_results/rgb_50/%02dscore_table.csv' % pic_nam)