|
|
@@ -51,52 +51,46 @@ def browse(): |
|
|
|
rows, cols, kanaele = img.shape
|
|
|
|
|
|
|
|
|
|
|
|
def showImage(img, rows, cols, kanaele, sim_faktor, sim_kind, sim_art):
|
|
|
|
color_blindness = Dyschromasie(img, rows, cols, kanaele, sim_faktor, sim_kind)
|
|
|
|
if sim_art == 'Sim':
|
|
|
|
color_blindness_mat = np.copy(color_blindness.Simulate()).astype('uint8')
|
|
|
|
else:
|
|
|
|
color_blindness_mat = np.copy(color_blindness.daltonize()).astype('uint8')
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
|
T.grid(columnspan=5)
|
|
|
|
print_string = sim_kind + ' ' + str(round(color_blindness.sim_faktor * 100)) + "%)"
|
|
|
|
T.insert('current', print_string)
|
|
|
|
|
|
|
|
conv_SimulationPic = ImageTk.PhotoImage(image=PIL.Image.fromarray(color_blindness_mat))
|
|
|
|
sim_pic = tk.Label(SB.frame, image=conv_SimulationPic)
|
|
|
|
sim_pic.Image = conv_SimulationPic
|
|
|
|
sim_pic.grid(columnspan=5)
|
|
|
|
|
|
|
|
|
|
|
|
def simulate():
|
|
|
|
global img, rows, cols, kanaele, sim_pro, sim_deut, sim_tri
|
|
|
|
if sim_deut.get():
|
|
|
|
d = Dyschromasie(img, rows, cols, kanaele, simGrad.get() / 100, 'd')
|
|
|
|
display_array_deut = np.copy(d.Simulate()).astype('uint8')
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
|
T.grid(columnspan=5)
|
|
|
|
print_string = "Deutranop(" + str(round(d.sim_faktor * 100)) + "%)"
|
|
|
|
T.insert('current', print_string)
|
|
|
|
|
|
|
|
conv_SimulationPic_deut = ImageTk.PhotoImage(image=PIL.Image.fromarray(display_array_deut))
|
|
|
|
sim_pic_deut = tk.Label(SB.frame, image=conv_SimulationPic_deut)
|
|
|
|
sim_pic_deut.Image = conv_SimulationPic_deut
|
|
|
|
sim_pic_deut.grid(columnspan=5)
|
|
|
|
showImage(img, rows, cols, kanaele, simGrad.get()/100, 'Deuteranop', 'Sim')
|
|
|
|
|
|
|
|
elif sim_tri.get():
|
|
|
|
t = Dyschromasie(img, rows, cols, kanaele, simGrad.get() / 100, 't')
|
|
|
|
display_array_tri = np.copy(t.Simulate()).astype('uint8')
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
|
T.grid(columnspan=5)
|
|
|
|
print_string = "Tritanop(" + str(round(t.sim_faktor * 100)) + "%)"
|
|
|
|
T.insert('current', print_string)
|
|
|
|
|
|
|
|
conv_SimulationPic_tri = ImageTk.PhotoImage(image=PIL.Image.fromarray(display_array_tri))
|
|
|
|
sim_pic_tri = tk.Label(SB.frame, image=conv_SimulationPic_tri)
|
|
|
|
sim_pic_tri.Image = conv_SimulationPic_tri
|
|
|
|
sim_pic_tri.grid(columnspan=5)
|
|
|
|
showImage(img, rows, cols, kanaele, simGrad.get() / 100, 'Tritanop', 'Sim')
|
|
|
|
|
|
|
|
elif sim_pro.get():
|
|
|
|
p = Dyschromasie(img, rows, cols, kanaele, simGrad.get() / 100, 'p')
|
|
|
|
display_array_pro = np.copy(p.Simulate()).astype('uint8')
|
|
|
|
showImage(img, rows, cols, kanaele, simGrad.get() / 100, 'Protanop', 'Sim')
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
|
T.grid(columnspan=5)
|
|
|
|
print_string = "Protanop(" + str(round(p.sim_faktor * 100)) + "%)"
|
|
|
|
T.insert('current', print_string)
|
|
|
|
|
|
|
|
conv_SimulationPic_pro = ImageTk.PhotoImage(image=PIL.Image.fromarray(display_array_pro))
|
|
|
|
sim_pic_pro = tk.Label(SB.frame, image=conv_SimulationPic_pro)
|
|
|
|
sim_pic_pro.Image = conv_SimulationPic_pro
|
|
|
|
sim_pic_pro.grid(columnspan=5)
|
|
|
|
def daltonize():
|
|
|
|
global img, rows, cols, kanaele, sim_pro, sim_deut, sim_tri
|
|
|
|
if sim_deut.get():
|
|
|
|
showImage(img, rows, cols, kanaele, simGrad.get()/100, 'Deuteranop', 'Dalt')
|
|
|
|
|
|
|
|
elif sim_tri.get():
|
|
|
|
showImage(img, rows, cols, kanaele, simGrad.get() / 100, 'Tritanop', 'Dalt')
|
|
|
|
|
|
|
|
def daltonize():
|
|
|
|
#ToDo
|
|
|
|
print("working")
|
|
|
|
elif sim_pro.get():
|
|
|
|
showImage(img, rows, cols, kanaele, simGrad.get() / 100, 'Protanop', 'Dalt')
|
|
|
|
|
|
|
|
|
|
|
|
browseButton = tk.Button(SB.frame, text="Browse", width=25, command=browse, bg='light blue')
|