|
|
@@ -1,6 +1,7 @@ |
|
|
|
import numpy as np
|
|
|
|
import cv2
|
|
|
|
|
|
|
|
|
|
|
|
def gammaCorrection(v):
|
|
|
|
if v <= 0.04045 * 255:
|
|
|
|
return (v / 255) / 12.92
|
|
|
@@ -12,14 +13,17 @@ def reverseGammaCorrection(v_reverse): |
|
|
|
if abs(v_reverse) <= 0.0031308:
|
|
|
|
return round(255 * (12.92 * abs(v_reverse)))
|
|
|
|
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:
|
|
|
|
cb_image = np.array([]).astype('float64')
|
|
|
|
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.cols = cols
|
|
|
|
self.kanaele = kanaele
|
|
|
@@ -57,10 +61,12 @@ class Dyschromasie: |
|
|
|
for x in range(3):
|
|
|
|
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
|
|
|
|
for i in range(self.rows):
|
|
|
|
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 = self.sim_image.astype('uint8')
|
|
|
@@ -70,6 +76,6 @@ class Dyschromasie: |
|
|
|
for x in range(3):
|
|
|
|
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
|
|
|
|
|
|
|
|
|