a b/usage/plotter.py
1
import matplotlib.pyplot as plt
2
import cv2
3
import numpy as np
4
5
im_path = 'train_15/ref_Training_phase_1_003.png'
6
img = np.transpose(cv2.imread(im_path),[1,0,2])
7
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
8
t_w = img.shape[0]
9
w = img.shape[0]//5
10
slide = img[4*w:t_w,:,:]
11
gt = img[3*w:4*w,:,:]
12
prob_map = img[1*w:2*w,:,:]
13
prob_map = np.mean(prob_map, axis=2)
14
prob_map/=255
15
pred = img[2*w:3*w,:,:]
16
# raise ValueError
17
18
fig, ax = plt.subplots(2, 2, figsize=(24, 24))
19
fig.tight_layout()
20
im_ = ax[0][0].imshow(slide)
21
ax[0][0].set_xticklabels([])
22
ax[0][0].set_yticklabels([])
23
ax[0][0].set_xticks([])
24
ax[0][0].set_yticks([])
25
ax[0][0].set_aspect('equal')
26
ax[0][0].tick_params(bottom='off', top='off', labelbottom='off', right='off', left='off', labelleft='off' )
27
# ax[0][0].title.set_text("WSI Slide")
28
29
gt_ = ax[0][1].imshow(gt,cmap='gray')
30
ax[0][1].set_xticklabels([])
31
ax[0][1].set_yticklabels([])
32
ax[0][1].set_xticks([])
33
ax[0][1].set_yticks([])
34
ax[0][1].set_aspect('equal')
35
ax[0][1].tick_params(bottom='off', top='off', labelbottom='off', right='off', left='off', labelleft='off' )
36
# ax[0][1].title.set_text("Ground Truth")
37
38
pred_ = ax[1][1].imshow(pred,cmap='gray')
39
ax[1][1].set_xticklabels([])
40
ax[1][1].set_yticklabels([])
41
ax[1][1].set_xticks([])
42
ax[1][1].set_yticks([])
43
ax[1][1].set_aspect('equal')
44
ax[1][1].tick_params(bottom='off', top='off', labelbottom='off', right='off', left='off', labelleft='off' )
45
# ax[1][1].title.set_text("Ground Truth")
46
47
prob_map_ = ax[1][0].imshow(prob_map, cmap=plt.cm.jet)
48
ax[1][0].set_xticklabels([])
49
ax[1][0].set_yticklabels([])
50
ax[1][0].set_xticks([])
51
ax[1][0].set_yticks([])
52
ax[1][0].set_aspect('equal')
53
ax[1][0].tick_params(bottom='off', top='off', labelbottom='off', right='off', left='off', labelleft='off' )
54
# ax[1][0].title.set_text("Probability Map")
55
56
cax = fig.add_axes([ax[1][0].get_position().x1 + 0.01,
57
          ax[1][0].get_position().y0,
58
          0.01,
59
          ax[1][0].get_position().y1-ax[1][0].get_position().y0])
60
fig.colorbar(prob_map_, cax=cax)
61
62
plt.savefig('characteristic-plots/im2.png',bbox_inches = 'tight',pad_inches = 0.1)