From e7eead37ee452c216b6b1741fa85ff71342a2b2c Mon Sep 17 00:00:00 2001 From: Max Sponsel Date: Thu, 9 Jul 2020 16:06:12 +0200 Subject: [PATCH] Fehler im Algorithmus gefunden MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Anders als im Paper werden die RGB Werte nicht in der Reihenfolge Rot Grün Blau (RGB), sondern in OpenCV als Blau grün rot (BGR) abgespeichert. Also ist ein e Funktion zum "Umdrehen" der Matrix nötig! --- .idea/workspace.xml | 18 +++++++++--------- Code/Dyschromasie.py | 7 ++----- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3204be0..4a3f7ba 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -77,28 +77,28 @@ - + - - + + - - + + - - + + - + - + \ No newline at end of file diff --git a/Code/Dyschromasie.py b/Code/Dyschromasie.py index 4c47eae..4060cd5 100644 --- a/Code/Dyschromasie.py +++ b/Code/Dyschromasie.py @@ -3,6 +3,7 @@ import tkinter # Zum Erstellen von GUIs import numpy as np # Numpy Import import sys + # Einlesen des Bildes script_dir = sys.path[0] path = script_dir[:-4] + "Beispielbilder\grocery_store.jpg" @@ -12,7 +13,6 @@ rows = image.shape[0] # Auslesen der Zeilenanzahl cols = image.shape[1] # Auslesen der Spaltenanzahl kanaele = image.shape[2] # Auslesen der Kanaele (3 fuer RGB, 1 fuer Graubild) - def gammaCorrection(v): if v <= 0.04045 * 255: return float(((v / 255) / 12.92)) @@ -62,8 +62,6 @@ T_reversed = np.array([[5.47221206, -4.6419601, 0.16963708], [-1.1252419, 2.29317094, -0.1678952], [0.02980165, -0.19318073, 1.16364789]]) -# Simulationsmatrizen fuer Protanop - S_p = np.array([[0, 1.05118294, -0.05116099], #Simulationsmatrix fuer Protanopie [0, 1, 0], [0, 0, 1]]) @@ -80,7 +78,7 @@ S_t = np.array([[1, 0, 0], #Simulationsmatrix fuer Tritanopi #Multiplikation der einzelnen Pixel for i in range(rows): for j in range(cols): - cb_image[i,j] = T_reversed.dot(S_p).dot(T).dot(cb_image[i,j]) + cb_image[i,j] = T_reversed.dot(S_p).dot(T).dot(cb_image[i,j]) #ToDo Statt RBG ist noch BGR sim_image = np.copy(cb_image) sim_image = sim_image.astype('uint8') @@ -91,7 +89,6 @@ for i in range(rows): for x in range(3): sim_image[i, j, x] = reverseGammaCorrection(cb_image[i, j, x]) - cv2.namedWindow("Display") # Displaywindow erstellen cv2.imshow("Display", sim_image) # Bild zeigen cv2.waitKey(0) # Fenster offen halten