diff --git a/Beispielbilder/corpcolorpalette.png b/Beispielbilder/corpcolorpalette.png new file mode 100644 index 0000000..587f7d0 Binary files /dev/null and b/Beispielbilder/corpcolorpalette.png differ diff --git a/Beispielbilder/corpcolorpalette2.png b/Beispielbilder/corpcolorpalette2.png new file mode 100644 index 0000000..f6e3695 Binary files /dev/null and b/Beispielbilder/corpcolorpalette2.png differ diff --git a/Beispielbilder/farbrad.jpg b/Beispielbilder/farbrad.jpg new file mode 100644 index 0000000..02eae56 Binary files /dev/null and b/Beispielbilder/farbrad.jpg differ diff --git a/Code/Dyschromasie-Applikation.py b/Code/Dyschromasie-Applikation.py index f9381f0..baa7cb6 100644 --- a/Code/Dyschromasie-Applikation.py +++ b/Code/Dyschromasie-Applikation.py @@ -5,6 +5,7 @@ from tkinter import filedialog, messagebox import cv2 import numpy as np from Farbaenderung import gammaCorrection, reverseGammaCorrection +from Scrollbar import ScrollFrame root = tk.Tk() simGrad = tk.IntVar(root) @@ -66,64 +67,6 @@ class Dyschromasie: return self.sim_image -class AutoScrollbar(tk.Scrollbar): - # A scrollbar that hides itself if it's not needed. - # Only works if you use the grid geometry manager! - def set(self, lo, hi): - if float(lo) <= 0.0 and float(hi) >= 1.0: - # grid_remove is currently missing from Tkinter! - self.tk.call("grid", "remove", self) - else: - self.grid() - tk.Scrollbar.set(self, lo, hi) - def pack(self, **kw): - raise TclError("cannot use pack with this widget") - def place(self, **kw): - raise TclError("cannot use place with this widget") - -class ScrollFrame: - def __init__(self, master): - - self.vscrollbar = AutoScrollbar(master) - self.vscrollbar.grid(row=0, column=1, sticky='ns') - self.hscrollbar = AutoScrollbar(master, orient='horizontal') - self.hscrollbar.grid(row=1, column=0, sticky='ew') - - self.canvas = tk.Canvas(master, yscrollcommand=self.vscrollbar.set, - xscrollcommand=self.hscrollbar.set) - self.canvas.grid(row=0, column=0, sticky='nsew') - - self.vscrollbar.config(command=self.canvas.yview) - self.hscrollbar.config(command=self.canvas.xview) - - # make the canvas expandable - master.grid_rowconfigure(0, weight=1) - master.grid_columnconfigure(0, weight=1) - - # create frame inside canvas - self.frame = tk.Frame(self.canvas) - self.frame.rowconfigure(1, weight=1) - self.frame.columnconfigure(1, weight=1) - - # update the frame - self.frame.bind("", self.reset_scrollregion) - - def reset_scrollregion(self, event): - self.canvas.configure(scrollregion=self.canvas.bbox('all')) - - def update(self): - self.canvas.create_window(0, 0, anchor='nw', window=self.frame) - self.frame.update_idletasks() - self.canvas.config(scrollregion=self.canvas.bbox("all")) - - if self.frame.winfo_reqwidth() != self.canvas.winfo_width(): - # update the canvas's width to fit the inner frame - self.canvas.config(width = self.frame.winfo_reqwidth()) - if self.frame.winfo_reqheight() != self.canvas.winfo_height(): - # update the canvas's width to fit the inner frame - self.canvas.config(height = self.frame.winfo_reqheight()) - - root.title("Projekt Dyschromasie") SB = ScrollFrame(root) @@ -143,7 +86,7 @@ simulationsGradient.grid(column= 0, row = 1, columnspan=10) def browse(): # Auswahl des FilePaths try: - path = tk.filedialog.askopenfilename(filetypes=[("Image File", '.jpg')]) + path = tk.filedialog.askopenfilename(filetypes=[("Image File", '.jpg'),("Image File", '.png')]) im = Image.open(path) except: tk.messagebox.showerror(title='Datenfehler', message='Kein Bild gefunden/ausgewählt') @@ -161,6 +104,7 @@ def browse(): global img, rows, cols, kanaele img = cv2.imread(path) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + #img = cv2.GaussianBlur(img, (3, 3), 0) rows, cols, kanaele = img.shape diff --git a/Code/Farbaenderung.py b/Code/Farbaenderung.py index 09a1cbd..e13f593 100644 --- a/Code/Farbaenderung.py +++ b/Code/Farbaenderung.py @@ -9,4 +9,9 @@ def reverseGammaCorrection(v_reverse): if v_reverse <= 0.0031308: return round(255 * (12.92 * v_reverse)) elif v_reverse > 0.0031308: - return round(255 * (1.055 * v_reverse ** 0.41666 - 0.055)) \ No newline at end of file + return round(255 * (1.055 * v_reverse ** 0.41666 - 0.055)) + + + + + diff --git a/Code/Scrollbar.py b/Code/Scrollbar.py new file mode 100644 index 0000000..a3c48f4 --- /dev/null +++ b/Code/Scrollbar.py @@ -0,0 +1,59 @@ +import tkinter as tk +from tkinter import filedialog, messagebox + +class AutoScrollbar(tk.Scrollbar): + # A scrollbar that hides itself if it's not needed. + # Only works if you use the grid geometry manager! + def set(self, lo, hi): + if float(lo) <= 0.0 and float(hi) >= 1.0: + # grid_remove is currently missing from Tkinter! + self.tk.call("grid", "remove", self) + else: + self.grid() + tk.Scrollbar.set(self, lo, hi) + def pack(self, **kw): + raise TclError("cannot use pack with this widget") + def place(self, **kw): + raise TclError("cannot use place with this widget") + +class ScrollFrame: + def __init__(self, master): + + self.vscrollbar = AutoScrollbar(master) + self.vscrollbar.grid(row=0, column=1, sticky='ns') + self.hscrollbar = AutoScrollbar(master, orient='horizontal') + self.hscrollbar.grid(row=1, column=0, sticky='ew') + + self.canvas = tk.Canvas(master, yscrollcommand=self.vscrollbar.set, + xscrollcommand=self.hscrollbar.set) + self.canvas.grid(row=0, column=0, sticky='nsew') + + self.vscrollbar.config(command=self.canvas.yview) + self.hscrollbar.config(command=self.canvas.xview) + + # make the canvas expandable + master.grid_rowconfigure(0, weight=1) + master.grid_columnconfigure(0, weight=1) + + # create frame inside canvas + self.frame = tk.Frame(self.canvas) + self.frame.rowconfigure(1, weight=1) + self.frame.columnconfigure(1, weight=1) + + # update the frame + self.frame.bind("", self.reset_scrollregion) + + def reset_scrollregion(self, event): + self.canvas.configure(scrollregion=self.canvas.bbox('all')) + + def update(self): + self.canvas.create_window(0, 0, anchor='nw', window=self.frame) + self.frame.update_idletasks() + self.canvas.config(scrollregion=self.canvas.bbox("all")) + + if self.frame.winfo_reqwidth() != self.canvas.winfo_width(): + # update the canvas's width to fit the inner frame + self.canvas.config(width = self.frame.winfo_reqwidth()) + if self.frame.winfo_reqheight() != self.canvas.winfo_height(): + # update the canvas's width to fit the inner frame + self.canvas.config(height = self.frame.winfo_reqheight()) diff --git a/Code/__pycache__/Farbaenderung.cpython-38.pyc b/Code/__pycache__/Farbaenderung.cpython-38.pyc index 88e1f28..e87c0da 100644 Binary files a/Code/__pycache__/Farbaenderung.cpython-38.pyc and b/Code/__pycache__/Farbaenderung.cpython-38.pyc differ diff --git a/Code/__pycache__/Scrollbar.cpython-38.pyc b/Code/__pycache__/Scrollbar.cpython-38.pyc new file mode 100644 index 0000000..23d3df3 Binary files /dev/null and b/Code/__pycache__/Scrollbar.cpython-38.pyc differ