-
Notifications
You must be signed in to change notification settings - Fork 2
/
together_plot_db_normalorder.py
92 lines (77 loc) · 2.59 KB
/
together_plot_db_normalorder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 正常顺序-溶解实验用
import xlrd #1.2.0
import sys
# import torch
import matplotlib
import math
import matplotlib.pyplot as plt
from operator import itemgetter
item_size = 3 #psnr,bpp,ssim,lpips顺序
y_bias = 0
if len(sys.argv) > 1:
y_bias = int(sys.argv[1])
y_name = ['PSNR (dB)','BPP-no-use','MS-SSIM (dB)','LPIPS'][y_bias]
print(y_name)
name_index = 0
if len(sys.argv) > 2:
name_index = int(sys.argv[2])
database_name = ['Instereo2k', 'KITTI', 'Palace'][name_index]
sheet_index = 0
if len(sys.argv) > 3:
sheet_index = int(sys.argv[3])
plt.rc('font',family='Times New Roman')
# matplotlib.use('Agg') # tmux专用 不报错
fontsize=15
## 统一定义
plt.grid()
plt.xlabel("Bitrate (bpp)",fontsize=fontsize)
plt.ylabel(y_name,fontsize=fontsize)
# plt.title('PSNR (Instereo2k) ',fontsize=fontsize)
plt.title(str(database_name),fontsize=fontsize)
plt.xticks(fontsize=13)
plt.yticks(fontsize=13)
color = ['#f94144','#ffb703','#90be6d','#219ebc','purple','#3d5a80','grey','#e29578','#028f1e','#cb0162','#370617','#ffc6ff','#45c67b']
signal = ['^','d','p','s','H','v','X','o','o','*' ,'^','d','p','s','H','v','X','o','o','o']
## datasheet 读画
wb = xlrd.open_workbook(r'data.xlsx')
#sheet1索引从0开始,得到sheet1表的句柄
sheet1 = wb.sheet_by_index(sheet_index)
if sheet_index != 0:
database_name = wb.sheet_names()[sheet_index]
print("database:",database_name)
plt.title(str(database_name).replace("_","/").replace("ab",""),fontsize=fontsize)
rowNum = sheet1.nrows
colNum = sheet1.ncols
x1 = []
y1 = []
plot_list = []
for ii in range(colNum//item_size):
y1 = sheet1.col_values(ii*item_size+y_bias) #y-val
x1 = sheet1.col_values(ii*item_size+1) #bpp
while len(x1)>1 and x1[-1]=='':
x1.pop()
y1.pop()
#plot
print(x1[1:])
print(y1[1:])
x1, y1 = zip(*sorted(zip(x1[1:], y1[1:]), key=itemgetter(0)))
# if ii==colNum//2-1:
# plt.plot(x1, y1, color=color[ii], marker=signal[ii], markersize='5', lw=1.5,linestyle=':')
# else:
if y_bias == 2:
y1 = list(y1)
# SSIM -> dB
for y_idx in range(len(y1)):
y1[y_idx] = 10*math.log10(1/(1-(float)(y1[y_idx])))
plot_list.append([x1[:],y1[:],color[ii],signal[ii],'5',1.5])
plt.plot(x1, y1, color=color[ii], marker=signal[ii], markersize='5', lw=1.5)
legend_list = sheet1.row_values(0)[0::item_size]
legend = legend_list #只留第一个位置
plt.legend(legend,loc='lower right',fontsize=10)
## save
# plt.xlim(0, 0.8)
# plt.savefig('contrast_ssim.png')
# plt.savefig('contrast_ssim_db.png')
plt.savefig('contrast.png')
plt.show()
print("ok")