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