Fehler im Algorithmus gefunden
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!
This commit is contained in:
parent
899580b119
commit
1165dc1e21
18
.idea/workspace.xml
generated
18
.idea/workspace.xml
generated
@ -77,28 +77,28 @@
|
|||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="739" y="275" key="FileChooserDialogImpl/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593535189103" />
|
<state x="739" y="275" key="FileChooserDialogImpl/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593535189103" />
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.bottom" timestamp="1593693833829">
|
<state width="1877" height="282" key="GridCell.Tab.0.bottom" timestamp="1594303176442">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593693833829" />
|
<state width="1877" height="282" key="GridCell.Tab.0.bottom/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1594303176442" />
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.center" timestamp="1593693833829">
|
<state width="1877" height="282" key="GridCell.Tab.0.center" timestamp="1594303176442">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593693833829" />
|
<state width="1877" height="282" key="GridCell.Tab.0.center/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1594303176442" />
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.left" timestamp="1593693833829">
|
<state width="1877" height="282" key="GridCell.Tab.0.left" timestamp="1594303176442">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593693833829" />
|
<state width="1877" height="282" key="GridCell.Tab.0.left/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1594303176442" />
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.right" timestamp="1593693833829">
|
<state width="1877" height="282" key="GridCell.Tab.0.right" timestamp="1594303176442">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1877" height="282" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593693833829" />
|
<state width="1877" height="282" key="GridCell.Tab.0.right/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1594303176442" />
|
||||||
<state x="461" y="165" key="SettingsEditor" timestamp="1593535127245">
|
<state x="461" y="165" key="SettingsEditor" timestamp="1593535127245">
|
||||||
<screen x="0" y="0" width="1920" height="1040" />
|
<screen x="0" y="0" width="1920" height="1040" />
|
||||||
</state>
|
</state>
|
||||||
<state x="461" y="165" key="SettingsEditor/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593535127245" />
|
<state x="461" y="165" key="SettingsEditor/0.0.1920.1040/-1920.109.1920.1040@0.0.1920.1040" timestamp="1593535127245" />
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/Projekt_Dyschromasie$Dyschromasie.coverage" NAME="Dyschromasie Coverage Results" MODIFIED="1593693827197" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Code" />
|
<SUITE FILE_PATH="coverage/Projekt_Dyschromasie$Dyschromasie.coverage" NAME="Dyschromasie Coverage Results" MODIFIED="1594303176426" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/Code" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -3,6 +3,7 @@ import tkinter # Zum Erstellen von GUIs
|
|||||||
import numpy as np # Numpy Import
|
import numpy as np # Numpy Import
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# Einlesen des Bildes
|
# Einlesen des Bildes
|
||||||
script_dir = sys.path[0]
|
script_dir = sys.path[0]
|
||||||
path = script_dir[:-4] + "Beispielbilder\grocery_store.jpg"
|
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
|
cols = image.shape[1] # Auslesen der Spaltenanzahl
|
||||||
kanaele = image.shape[2] # Auslesen der Kanaele (3 fuer RGB, 1 fuer Graubild)
|
kanaele = image.shape[2] # Auslesen der Kanaele (3 fuer RGB, 1 fuer Graubild)
|
||||||
|
|
||||||
|
|
||||||
def gammaCorrection(v):
|
def gammaCorrection(v):
|
||||||
if v <= 0.04045 * 255:
|
if v <= 0.04045 * 255:
|
||||||
return float(((v / 255) / 12.92))
|
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],
|
[-1.1252419, 2.29317094, -0.1678952],
|
||||||
[0.02980165, -0.19318073, 1.16364789]])
|
[0.02980165, -0.19318073, 1.16364789]])
|
||||||
|
|
||||||
# Simulationsmatrizen fuer Protanop
|
|
||||||
|
|
||||||
S_p = np.array([[0, 1.05118294, -0.05116099], #Simulationsmatrix fuer Protanopie
|
S_p = np.array([[0, 1.05118294, -0.05116099], #Simulationsmatrix fuer Protanopie
|
||||||
[0, 1, 0],
|
[0, 1, 0],
|
||||||
[0, 0, 1]])
|
[0, 0, 1]])
|
||||||
@ -80,7 +78,7 @@ S_t = np.array([[1, 0, 0], #Simulationsmatrix fuer Tritanopi
|
|||||||
#Multiplikation der einzelnen Pixel
|
#Multiplikation der einzelnen Pixel
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
for j in range(cols):
|
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 = np.copy(cb_image)
|
||||||
sim_image = sim_image.astype('uint8')
|
sim_image = sim_image.astype('uint8')
|
||||||
@ -91,7 +89,6 @@ for i in range(rows):
|
|||||||
for x in range(3):
|
for x in range(3):
|
||||||
sim_image[i, j, x] = reverseGammaCorrection(cb_image[i, j, x])
|
sim_image[i, j, x] = reverseGammaCorrection(cb_image[i, j, x])
|
||||||
|
|
||||||
|
|
||||||
cv2.namedWindow("Display") # Displaywindow erstellen
|
cv2.namedWindow("Display") # Displaywindow erstellen
|
||||||
cv2.imshow("Display", sim_image) # Bild zeigen
|
cv2.imshow("Display", sim_image) # Bild zeigen
|
||||||
cv2.waitKey(0) # Fenster offen halten
|
cv2.waitKey(0) # Fenster offen halten
|
||||||
|
Loading…
x
Reference in New Issue
Block a user