|
|
@@ -1,7 +1,6 @@ |
|
|
|
import numpy as np
|
|
|
|
import cv2
|
|
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def createGammaLookup():
|
|
|
|
return np.array([removeGammaCorrection(i) for i in np.arange(0, 256)]).astype("float64")
|
|
|
@@ -87,3 +86,47 @@ class Dyschromasie: |
|
|
|
|
|
|
|
return self.sim_image
|
|
|
|
|
|
|
|
|
|
|
|
script_dir = sys.path[0]
|
|
|
|
path = script_dir[:-4] + "Beispielbilder\Fall_trees.jpg"
|
|
|
|
image = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
|
|
|
|
|
|
|
|
rows, cols, kanaele = image.shape
|
|
|
|
|
|
|
|
p = Dyschromasie(image, rows, cols, kanaele, 1, 'p')
|
|
|
|
|
|
|
|
simulated_image = p.Simulate()
|
|
|
|
|
|
|
|
E = np.copy(simulated_image)
|
|
|
|
for i in range(rows):
|
|
|
|
for j in range(cols):
|
|
|
|
for x in range(3):
|
|
|
|
E[i, j, x] = abs(int(simulated_image[i, j, x]) - int(image[i, j, x]))
|
|
|
|
|
|
|
|
ERR = np.zeros_like(image)
|
|
|
|
|
|
|
|
err2mod = np.array([[0,0,0],[0.7,1,0],[0.7,0,1]])
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
|
for j in range(cols):
|
|
|
|
err = E[i,j,:3]
|
|
|
|
ERR[i,j,:3] = np.dot(err2mod, err)
|
|
|
|
|
|
|
|
dtpn = np.copy(image)
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
|
for j in range(cols):
|
|
|
|
for x in range(3):
|
|
|
|
dtpn[i, j, x] = (int(ERR[i, j, x]) + int(image[i, j, x]))
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
|
for j in range(cols):
|
|
|
|
dtpn[i, j, 0] = max(0, dtpn[i, j, 0])
|
|
|
|
dtpn[i, j, 0] = min(255, dtpn[i, j, 0])
|
|
|
|
dtpn[i, j, 1] = max(0, dtpn[i, j, 1])
|
|
|
|
dtpn[i, j, 1] = min(255, dtpn[i, j, 1])
|
|
|
|
dtpn[i, j, 2] = max(0, dtpn[i, j, 2])
|
|
|
|
dtpn[i, j, 2] = min(255, dtpn[i, j, 2])
|
|
|
|
|
|
|
|
cv2.imshow('Dalt_Img', cv2.cvtColor(dtpn, cv2.COLOR_RGB2BGR))
|
|
|
|
cv2.waitKey(0) |