|
|
|
|
|
|
|
|
sim_tri = tk.IntVar(root)
|
|
|
sim_tri = tk.IntVar(root)
|
|
|
|
|
|
|
|
|
simulationsGradient = tk.Scale(SB.frame, from_=0, to_=100, variable=simGrad, orient='horizontal')
|
|
|
simulationsGradient = tk.Scale(SB.frame, from_=0, to_=100, variable=simGrad, orient='horizontal')
|
|
|
simulationsGradient.grid(column= 0, row = 1, columnspan=10)
|
|
|
|
|
|
|
|
|
simulationsGradient.grid(column=0, row=1, columnspan=10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def browse():
|
|
|
def browse():
|
|
|
# Auswahl des FilePaths
|
|
|
# Auswahl des FilePaths
|
|
|
try:
|
|
|
try:
|
|
|
path = tk.filedialog.askopenfilename(filetypes=[("Image File", '.jpg'),("Image File", '.png')])
|
|
|
|
|
|
|
|
|
path = tk.filedialog.askopenfilename(filetypes=[("Image File", '.jpg'), ("Image File", '.png')])
|
|
|
im = Image.open(path)
|
|
|
im = Image.open(path)
|
|
|
except:
|
|
|
except:
|
|
|
tk.messagebox.showerror(title='Datenfehler', message='Kein Bild gefunden/ausgewählt')
|
|
|
tk.messagebox.showerror(title='Datenfehler', message='Kein Bild gefunden/ausgewählt')
|
|
|
global simulateButton
|
|
|
global simulateButton
|
|
|
if len(path) > 0:
|
|
|
if len(path) > 0:
|
|
|
simulateButton.config(state='active')
|
|
|
simulateButton.config(state='active')
|
|
|
|
|
|
daltonButton.config(state='active')
|
|
|
|
|
|
|
|
|
# Anzeigen des Bildes
|
|
|
# Anzeigen des Bildes
|
|
|
tkimage = ImageTk.PhotoImage(im)
|
|
|
tkimage = ImageTk.PhotoImage(im)
|
|
|
|
|
|
|
|
|
def simulate():
|
|
|
def simulate():
|
|
|
global img, rows, cols, kanaele, sim_pro, sim_deut, sim_tri
|
|
|
global img, rows, cols, kanaele, sim_pro, sim_deut, sim_tri
|
|
|
if sim_deut.get():
|
|
|
if sim_deut.get():
|
|
|
d = Dyschromasie(img, rows, cols, kanaele, simGrad.get()/100, 'd')
|
|
|
|
|
|
|
|
|
d = Dyschromasie(img, rows, cols, kanaele, simGrad.get() / 100, 'd')
|
|
|
display_array_deut = np.copy(d.Simulate()).astype('uint8')
|
|
|
display_array_deut = np.copy(d.Simulate()).astype('uint8')
|
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
T.grid(columnspan=5)
|
|
|
T.grid(columnspan=5)
|
|
|
print_string = "Deutranop(" + str(round(d.sim_faktor*100)) + "%)"
|
|
|
|
|
|
|
|
|
print_string = "Deutranop(" + str(round(d.sim_faktor * 100)) + "%)"
|
|
|
T.insert('current', print_string)
|
|
|
T.insert('current', print_string)
|
|
|
|
|
|
|
|
|
conv_SimulationPic_deut = ImageTk.PhotoImage(image=PIL.Image.fromarray(display_array_deut))
|
|
|
conv_SimulationPic_deut = ImageTk.PhotoImage(image=PIL.Image.fromarray(display_array_deut))
|
|
|
|
|
|
|
|
|
sim_pic_deut.Image = conv_SimulationPic_deut
|
|
|
sim_pic_deut.Image = conv_SimulationPic_deut
|
|
|
sim_pic_deut.grid(columnspan=5)
|
|
|
sim_pic_deut.grid(columnspan=5)
|
|
|
elif sim_tri.get():
|
|
|
elif sim_tri.get():
|
|
|
t = Dyschromasie(img, rows, cols, kanaele, simGrad.get()/100, 't')
|
|
|
|
|
|
|
|
|
t = Dyschromasie(img, rows, cols, kanaele, simGrad.get() / 100, 't')
|
|
|
display_array_tri = np.copy(t.Simulate()).astype('uint8')
|
|
|
display_array_tri = np.copy(t.Simulate()).astype('uint8')
|
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
|
|
|
|
|
|
sim_pic_tri.Image = conv_SimulationPic_tri
|
|
|
sim_pic_tri.Image = conv_SimulationPic_tri
|
|
|
sim_pic_tri.grid(columnspan=5)
|
|
|
sim_pic_tri.grid(columnspan=5)
|
|
|
elif sim_pro.get():
|
|
|
elif sim_pro.get():
|
|
|
p = Dyschromasie(img, rows, cols, kanaele, simGrad.get()/100, 'p')
|
|
|
|
|
|
|
|
|
p = Dyschromasie(img, rows, cols, kanaele, simGrad.get() / 100, 'p')
|
|
|
display_array_pro = np.copy(p.Simulate()).astype('uint8')
|
|
|
display_array_pro = np.copy(p.Simulate()).astype('uint8')
|
|
|
|
|
|
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
T = tk.Text(SB.frame, height=1, width=15)
|
|
|
|
|
|
|
|
|
sim_pic_pro.grid(columnspan=5)
|
|
|
sim_pic_pro.grid(columnspan=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btn = tk.Button(SB.frame, text="Browse", width=25, command=browse, bg='light blue')
|
|
|
|
|
|
btn.grid(column=0, row=0, columnspan=2)
|
|
|
|
|
|
|
|
|
def daltonize():
|
|
|
|
|
|
#ToDo
|
|
|
|
|
|
print("working")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
browseButton = tk.Button(SB.frame, text="Browse", width=25, command=browse, bg='light blue')
|
|
|
|
|
|
browseButton.grid(column=0, row=0, columnspan=1)
|
|
|
|
|
|
|
|
|
simulateButton = tk.Button(SB.frame, text="Simulate", width=25, command=simulate, bg='light blue')
|
|
|
simulateButton = tk.Button(SB.frame, text="Simulate", width=25, command=simulate, bg='light blue')
|
|
|
simulateButton.grid(column=1, row=0, columnspan=2)
|
|
|
|
|
|
|
|
|
simulateButton.grid(column=1, row=0, columnspan=1)
|
|
|
simulateButton.config(state='disabled')
|
|
|
simulateButton.config(state='disabled')
|
|
|
|
|
|
|
|
|
|
|
|
daltonButton = tk.Button(SB.frame, text="Daltonize", width=25, command=daltonize, bg='light blue')
|
|
|
|
|
|
daltonButton.grid(column=2, row=0, columnspan=1)
|
|
|
|
|
|
daltonButton.config(state='disabled')
|
|
|
|
|
|
|
|
|
checkButton_p = tk.Checkbutton(SB.frame, text="Protanop", variable=sim_pro, onvalue=1, offvalue=0, height=5, width=20)
|
|
|
checkButton_p = tk.Checkbutton(SB.frame, text="Protanop", variable=sim_pro, onvalue=1, offvalue=0, height=5, width=20)
|
|
|
checkButton_d = tk.Checkbutton(SB.frame, text="Deutanop", variable=sim_deut, onvalue=1, offvalue=0, height=5, width=20)
|
|
|
checkButton_d = tk.Checkbutton(SB.frame, text="Deutanop", variable=sim_deut, onvalue=1, offvalue=0, height=5, width=20)
|
|
|
checkButton_t = tk.Checkbutton(SB.frame, text="Tritanop", variable=sim_tri, onvalue=1, offvalue=0, height=5, width=20)
|
|
|
checkButton_t = tk.Checkbutton(SB.frame, text="Tritanop", variable=sim_tri, onvalue=1, offvalue=0, height=5, width=20)
|