Weitere Anpassungen für Tritanopie
Anders als bei den anderen Fehlsichtigkeiten ist ein Überlauf des Wertebereichs möglich. Somit werden Werte, die 255 überschreiten standardmäßig auf diesen Maximalwert gesetzt.
This commit is contained in:
parent
9b76b10e32
commit
ff420dc77c
@ -77,7 +77,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_t).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')
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
|
|
||||||
def gammaCorrection(v):
|
def gammaCorrection(v):
|
||||||
if v <= 0.04045 * 255:
|
if v <= 0.04045 * 255:
|
||||||
return (v / 255) / 12.92
|
return (v / 255) / 12.92
|
||||||
@ -12,14 +13,17 @@ def reverseGammaCorrection(v_reverse):
|
|||||||
if abs(v_reverse) <= 0.0031308:
|
if abs(v_reverse) <= 0.0031308:
|
||||||
return round(255 * (12.92 * abs(v_reverse)))
|
return round(255 * (12.92 * abs(v_reverse)))
|
||||||
elif abs(v_reverse) > 0.0031308:
|
elif abs(v_reverse) > 0.0031308:
|
||||||
return round(255 * (1.055 * abs(v_reverse) ** 0.41666 - 0.055))
|
if (round(255 * (1.055 * abs(v_reverse) ** 0.41666 - 0.055))) > 255:
|
||||||
|
return 255
|
||||||
|
else:
|
||||||
|
return round(255 * (1.055 * abs(v_reverse) ** 0.41666 - 0.055))
|
||||||
|
|
||||||
|
|
||||||
class Dyschromasie:
|
class Dyschromasie:
|
||||||
cb_image = np.array([]).astype('float64')
|
cb_image = np.array([]).astype('float64')
|
||||||
sim_image = np.array([]).astype('uint8')
|
sim_image = np.array([]).astype('uint8')
|
||||||
|
|
||||||
def __init__(self, img_mat=np.array([]), rows=0, cols=0, kanaele=0,sim_faktor=0, sim_kind='d'):
|
def __init__(self, img_mat=np.array([]), rows=0, cols=0, kanaele=0, sim_faktor=0, sim_kind='d'):
|
||||||
self.rows = rows
|
self.rows = rows
|
||||||
self.cols = cols
|
self.cols = cols
|
||||||
self.kanaele = kanaele
|
self.kanaele = kanaele
|
||||||
@ -57,10 +61,12 @@ class Dyschromasie:
|
|||||||
for x in range(3):
|
for x in range(3):
|
||||||
self.cb_image[i, j, x] = gammaCorrection(self.img_mat[i, j, x])
|
self.cb_image[i, j, x] = gammaCorrection(self.img_mat[i, j, x])
|
||||||
|
|
||||||
|
rechen_Mat = np.copy(self.T_reversed.dot(sim_mat).dot(self.T))
|
||||||
|
print(rechen_Mat)
|
||||||
# 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] = self.T_reversed.dot(sim_mat).dot(self.T).dot(self.cb_image[i, j])
|
self.cb_image[i, j] = rechen_Mat.dot(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')
|
||||||
@ -70,6 +76,6 @@ class Dyschromasie:
|
|||||||
for x in range(3):
|
for x in range(3):
|
||||||
self.sim_image[i, j, x] = reverseGammaCorrection(self.cb_image[i, j, x])
|
self.sim_image[i, j, x] = reverseGammaCorrection(self.cb_image[i, j, x])
|
||||||
|
|
||||||
|
print(self.img_mat[78, 86])
|
||||||
|
print(self.sim_image[78, 86])
|
||||||
return self.sim_image
|
return self.sim_image
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user