Browse Source

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.
master
Max Sponsel 4 years ago
parent
commit
31ed0825c3
3 changed files with 12 additions and 6 deletions
  1. 1
    1
      Code/Dyschromasie.py
  2. 11
    5
      Code/Farbaenderung.py
  3. BIN
      Code/__pycache__/Farbaenderung.cpython-38.pyc

+ 1
- 1
Code/Dyschromasie.py View File

#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')

+ 11
- 5
Code/Farbaenderung.py View File

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
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
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')
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

BIN
Code/__pycache__/Farbaenderung.cpython-38.pyc View File


Loading…
Cancel
Save