|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Einlesen des Bildes
|
|
|
# Einlesen des Bildes
|
|
|
script_dir = sys.path[0]
|
|
|
script_dir = sys.path[0]
|
|
|
path = script_dir[:-4] + "Beispielbilder\lena.jpg"
|
|
|
|
|
|
|
|
|
path = script_dir[:-4] + "Beispielbilder\grocery_store.jpg"
|
|
|
image = cv2.imread(path) # Einlesen des Bildes (noch hardcodiert, sollte dann in GUI gehen)
|
|
|
image = cv2.imread(path) # Einlesen des Bildes (noch hardcodiert, sollte dann in GUI gehen)
|
|
|
|
|
|
|
|
|
rows = image.shape[0] # Auslesen der Zeilenanzahl
|
|
|
rows = image.shape[0] # Auslesen der Zeilenanzahl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Simulationsmatrizen fuer Protanop
|
|
|
# Simulationsmatrizen fuer Protanop
|
|
|
|
|
|
|
|
|
S_b = 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]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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_b.dot(T.dot(cb_image[i, j]))) #T^-1*S*T*RBG_values
|
|
|
|
|
|
|
|
|
cb_image[i,j] = T_reversed.dot(S_p).dot(T).dot(cb_image[i,j])
|
|
|
|
|
|
|
|
|
sim_image = np.copy(cb_image)
|
|
|
sim_image = np.copy(cb_image)
|
|
|
sim_image = sim_image.astype('uint8')
|
|
|
sim_image = sim_image.astype('uint8')
|
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
for i in range(rows):
|
|
|
for j in range(cols):
|
|
|
for j in range(cols):
|
|
|
for x in range(3):
|
|
|
for x in range(3):
|
|
|
sim_image[i, j, x] = int(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
|