|
|
@@ -12,35 +12,44 @@ rows = image.shape[0] # Auslesen der Zeilenanzahl |
|
|
|
cols = image.shape[1] # Auslesen der Spaltenanzahl
|
|
|
|
kanaele = image.shape[2] # Auslesen der Kanaele (3 fuer RGB, 1 fuer Graubild)
|
|
|
|
|
|
|
|
|
|
|
|
def gammaCorrection(v):
|
|
|
|
if (v <= 0.04045 * 255):
|
|
|
|
return ((v / 255) / 12.92)
|
|
|
|
elif (v > 0.04045 * 255):
|
|
|
|
return (((v / 255) + 0.055) / 1.055) ** 2.4
|
|
|
|
if v <= 0.04045 * 255:
|
|
|
|
return float(((v / 255) / 12.92))
|
|
|
|
elif v > 0.04045 * 255:
|
|
|
|
return float((((v / 255) + 0.055) / 1.055) ** 2.4)
|
|
|
|
else:
|
|
|
|
print("Ungültiger Wert!!")
|
|
|
|
return 1
|
|
|
|
|
|
|
|
print(gammaCorrection(image[0,0,0]))
|
|
|
|
|
|
|
|
def reverseGammaCorrection(v_reverse):
|
|
|
|
if (v_reverse <= 0.0031308):
|
|
|
|
return 255 * (12.92 * v_reverse)
|
|
|
|
elif (v_reverse > 0.0031308):
|
|
|
|
return 255 * (1.055 * v_reverse ** 0.41666 - 0.055)
|
|
|
|
if v_reverse <= 0.0031308:
|
|
|
|
return int(255 * (12.92 * v_reverse))
|
|
|
|
elif v_reverse > 0.0031308:
|
|
|
|
return int(255 * (1.055 * v_reverse ** 0.41666 - 0.055))
|
|
|
|
else:
|
|
|
|
print("Ungültiger Wert!!!")
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
cb_image = np.copy(image)
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
|
for j in range(cols):
|
|
|
|
for x in range(3):
|
|
|
|
cb_image[i,j,x] = gammaCorrection(float(image[i,j,x]))
|
|
|
|
|
|
|
|
print(cb_image[0,0])
|
|
|
|
'''
|
|
|
|
0.31399022 0.63951294 0.04649755 Transformationsmatrix zum Konvertieren vom linearen RGB zum LMS Farbraum
|
|
|
|
T = 0.15537241 0.75789446 0.08670142 Multiplikation aus Brucelindbloom und Hunt-Pointer-Estevez Matrixen
|
|
|
|
0.01775239 0.10944209 0.87256922 T*RGB_Farbverktor = LMS_Farbvektor
|
|
|
|
'''
|
|
|
|
|
|
|
|
T = np.array([[0.31399022,0.63951294,0.04649755],
|
|
|
|
[0.15537241,0.75789446,0.08670142],
|
|
|
|
[0.01775239,0.10944209,0.87256922]])
|
|
|
|
T = np.array([[0.31399022, 0.63951294, 0.04649755],
|
|
|
|
[0.15537241, 0.75789446, 0.08670142],
|
|
|
|
[0.01775239, 0.10944209, 0.87256922]])
|
|
|
|
|
|
|
|
'''
|
|
|
|
5.47221206 −4.6419601 0.16963708 Rücktransformationsmatrix (Inverse von T)
|
|
|
@@ -48,15 +57,12 @@ T_reversed = -1.1252419 2.29317094 −0.1678952 T_reversed Ü LMS_Farbvek |
|
|
|
0.02980165 −0.19318073 1.16364789
|
|
|
|
'''
|
|
|
|
|
|
|
|
T_reversed = np.array([[5.47221206,-4.6419601,0.16963708],
|
|
|
|
[-1.1252419,2.29317094,-0.1678952],
|
|
|
|
[0.02980165,-0.19318073,1.16364789]])
|
|
|
|
|
|
|
|
T_reversed = np.array([[5.47221206, -4.6419601, 0.16963708],
|
|
|
|
[-1.1252419, 2.29317094, -0.1678952],
|
|
|
|
[0.02980165, -0.19318073, 1.16364789]])
|
|
|
|
|
|
|
|
# for i in range(rows): #Durchgehen aller Pixel des Bildes
|
|
|
|
# for j in range(cols):
|
|
|
|
# k = image[i,j]
|
|
|
|
# #Umwandlungsalgorithmus
|
|
|
|
# Multiplikation der einzelnen Pixelwerte
|
|
|
|
# T.dot(image[x][y])
|
|
|
|
|
|
|
|
|
|
|
|
cv2.namedWindow("Display") # Displaywindow erstellen
|