-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowmanager.py
62 lines (50 loc) · 1.84 KB
/
windowmanager.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
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
# ------------------------------------
# Define display window configure
# ------------------------------------
row = 3
column = 3
gs = gridspec.GridSpec(3, 3)
def create_window(img, result, cdf_normalized, information):
""" open window then separate image for comparison and add their label"""
fig = plt.figure()
fig.suptitle('Mammographic density measurement', fontsize=14, fontweight='bold')
fig.canvas.set_window_title('Mammograpic density measurement - Traisak Traisenee')
'''Show original image'''
plt.subplot(gs[:, 0])
plt.imshow(img) # expects distorted color
plt.title('Original')
plt.xlabel('Input')
'''Show result'''
plt.subplot(gs[:, 1])
plt.imshow(result) # expect true color
plt.title('Threshold')
plt.xlabel('Output')
'''Display calculation part'''
ax = fig.add_subplot(gs[0, 2])
ax.set_title('Calculation')
breast = 'Breast area = ' + str(information[0][1])
tissue = 'Tissue area = ' + str(information[1][1])
t_value = 'Threshold = ' + str(information[3][1])
density = "%10.3f" % information[2][1]
density += " %"
ax.text(0.05, 0.8, t_value, fontsize=9)
ax.text(0.05, 0.6, breast, fontsize=9)
ax.text(0.05, 0.4, tissue, fontsize=9)
ax.text(0.05, 0.2, 'Density =' + density, fontsize=9)
plt.xticks([])
plt.yticks([])
# plt.axis('off') # Remove frame
'''Show histogram'''
plt.subplot(gs[1:, 2]).plot(cdf_normalized, color='b')
plt.hist(img.flatten(), 256, [0, 256], color='r')
plt.xlim([0, 256])
plt.ylim([-50, 150000])
plt.yticks([])
plt.legend(('cdf', 'histogram'), loc='upper right')
'''Maximize window'''
mng = plt.get_current_fig_manager()
# mng.full_screen_toggle() # Full-screen
mng.window.state('zoomed')
plt.show()