Browse Source

Einfügen eines Sliders

Um den Grad der Faarbblindheit korrekt zu Simulieren, muss ein Widget eingebaut werden, welches den prozentualen Anteil der Differenz zwischen Simulation und echtem Wert vergleicht und mit dem ausgewählten Wert (z. B. 80%) neu gewichtet.
master
Max Sponsel 3 years ago
parent
commit
da88618ce6
1 changed files with 21 additions and 14 deletions
  1. 21
    14
      Code/Dyschromasie-Applikation.py

+ 21
- 14
Code/Dyschromasie-Applikation.py View File

# Einzelne Pixelwertberechnung # Einzelne Pixelwertberechnung
for i in range(self.rows): for i in range(self.rows):
for j in range(self.cols): for j in range(self.cols):
self.cb_image[i, j] = np.flipud(self.T_reversed.dot(self.sim_mat).dot(self.T).dot(np.flipud(self.cb_image[i, j])))
self.cb_image[i, j] = np.flipud(
self.T_reversed.dot(self.sim_mat).dot(self.T).dot(np.flipud(self.cb_image[i, j])))
self.sim_image = np.copy(self.cb_image) self.sim_image = np.copy(self.cb_image)
self.sim_image = self.sim_image.astype('uint8') self.sim_image = self.sim_image.astype('uint8')
# Einzelne Pixelwertberechnung # Einzelne Pixelwertberechnung
for i in range(self.rows): for i in range(self.rows):
for j in range(self.cols): for j in range(self.cols):
self.cb_image[i, j] = np.flipud(self.T_reversed.dot(self.sim_mat).dot(self.T).dot(np.flipud(self.cb_image[i, j])))
self.cb_image[i, j] = np.flipud(
self.T_reversed.dot(self.sim_mat).dot(self.T).dot(np.flipud(self.cb_image[i, j])))
self.sim_image = np.copy(self.cb_image) self.sim_image = np.copy(self.cb_image)
self.sim_image = self.sim_image.astype('uint8') self.sim_image = self.sim_image.astype('uint8')
# Einzelne Pixelwertberechnung # Einzelne Pixelwertberechnung
for i in range(self.rows): for i in range(self.rows):
for j in range(self.cols): for j in range(self.cols):
self.cb_image[i, j] = np.flipud(self.T_reversed.dot(self.sim_mat).dot(self.T).dot(np.flipud(self.cb_image[i, j])))
self.cb_image[i, j] = np.flipud(
self.T_reversed.dot(self.sim_mat).dot(self.T).dot(np.flipud(self.cb_image[i, j])))
self.sim_image = np.copy(self.cb_image) self.sim_image = np.copy(self.cb_image)
self.sim_image = self.sim_image.astype('uint8') self.sim_image = self.sim_image.astype('uint8')
self.sim_image[i, j, x] = self.reverseGammaCorrection(self.cb_image[i, j, x]) self.sim_image[i, j, x] = self.reverseGammaCorrection(self.cb_image[i, j, x])
return self.sim_image return self.sim_image
root = tk.Tk() root = tk.Tk()
root.title("Projekt Dyschromasie") root.title("Projekt Dyschromasie")
cols = 0 cols = 0
kanaele = 0 kanaele = 0
sim_pro = tk.IntVar(root)
sim_deut = tk.IntVar(root)
sim_tri = tk.IntVar(root)
sim_pro = tk.IntVar(root)
sim_deut = tk.IntVar(root)
sim_tri = tk.IntVar(root)
simGrad = tk.IntVar(root)
simulationsGradient = tk.Scale(root, from_=0, to_=100, variable=simGrad, orient='horizontal')
simulationsGradient.grid(column= 0, row = 1, columnspan=10)
def browse(): def browse():
# Auswahl des FilePaths # Auswahl des FilePaths
d = Deuteranopie(img, rows, cols, kanaele) d = Deuteranopie(img, rows, cols, kanaele)
display_array_deut = cv2.cvtColor(np.copy(d.Simulate()), cv2.COLOR_BGR2RGB) display_array_deut = cv2.cvtColor(np.copy(d.Simulate()), cv2.COLOR_BGR2RGB)
T = tk.Text(root,height=1,width=15)
T = tk.Text(root, height=1, width=15)
T.grid(columnspan=5) T.grid(columnspan=5)
T.insert('current',"Deutranopie:")
T.insert('current', "Deutranopie:")
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 = tk.Label(root, image=conv_SimulationPic_deut) sim_pic_deut = tk.Label(root, image=conv_SimulationPic_deut)
sim_pic_pro.grid(columnspan=5) sim_pic_pro.grid(columnspan=5)
btn = tk.Button(root, text="Browse", width=25, command=browse, bg='light blue') btn = tk.Button(root, text="Browse", width=25, command=browse, bg='light blue')
btn.grid(column = 0, row = 0,columnspan=2)
btn.grid(column=0, row=0, columnspan=2)
simulateButton = tk.Button(root, text="Simulate", width=25, command=simulate, bg='light blue') simulateButton = tk.Button(root, text="Simulate", width=25, command=simulate, bg='light blue')
simulateButton.grid(column = 1, row = 0,columnspan=2)
simulateButton.grid(column=1, row=0, columnspan=2)
simulateButton.config(state='disabled') simulateButton.config(state='disabled')
checkButton_p = tk.Checkbutton(root, text="Protanop", variable=sim_pro, onvalue=1, offvalue=0, height=5, width=20) checkButton_p = tk.Checkbutton(root, text="Protanop", variable=sim_pro, onvalue=1, offvalue=0, height=5, width=20)
checkButton_d = tk.Checkbutton(root, text="Deutanop", variable=sim_deut, onvalue=1, offvalue=0, height=5, width=20) checkButton_d = tk.Checkbutton(root, text="Deutanop", variable=sim_deut, onvalue=1, offvalue=0, height=5, width=20)
checkButton_t = tk.Checkbutton(root, text="Tritanop", variable=sim_tri, onvalue=1, offvalue=0, height=5, width=20) checkButton_t = tk.Checkbutton(root, text="Tritanop", variable=sim_tri, onvalue=1, offvalue=0, height=5, width=20)
checkButton_p.grid(column = 0, row = 1)
checkButton_d.grid(column = 1, row = 1)
checkButton_t.grid(column = 2, row = 1)
checkButton_p.grid(column=0, row=2)
checkButton_d.grid(column=1, row=2)
checkButton_t.grid(column=2, row=2)
root.mainloop() root.mainloop()

Loading…
Cancel
Save