|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
script_dir = sys.path[0]
|
|
|
script_dir = sys.path[0]
|
|
|
path = script_dir[:-4] + "Beispielbilder\Fall_trees.jpg"
|
|
|
|
|
|
|
|
|
path = script_dir[:-4] + r'Beispielbilder\Fall_trees.jpg'
|
|
|
image = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
|
|
|
image = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
|
|
|
|
|
|
|
|
|
rows, cols, kanaele = image.shape
|
|
|
rows, cols, kanaele = image.shape
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
simulated_image = p.Simulate()
|
|
|
simulated_image = p.Simulate()
|
|
|
|
|
|
|
|
|
E = np.copy(simulated_image)
|
|
|
|
|
|
|
|
|
E = np.copy(simulated_image).astype('int64')
|
|
|
for i in range(rows):
|
|
|
for i in range(rows):
|
|
|
for j in range(cols):
|
|
|
for j in range(cols):
|
|
|
for x in range(3):
|
|
|
for x in range(3):
|
|
|
E[i, j, x] = abs(int(simulated_image[i, j, x]) - int(image[i, j, x]))
|
|
|
|
|
|
|
|
|
E[i, j, x] = abs(int(image[i, j, x]) - int(simulated_image[i, j, x]))
|
|
|
|
|
|
|
|
|
ERR = np.zeros_like(image)
|
|
|
|
|
|
|
|
|
ERR = np.zeros_like(image).astype('int64')
|
|
|
|
|
|
|
|
|
err2mod = np.array([[0,0,0],[0.7,1,0],[0.7,0,1]])
|
|
|
err2mod = np.array([[0,0,0],[0.7,1,0],[0.7,0,1]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = E[i,j,:3]
|
|
|
err = E[i,j,:3]
|
|
|
ERR[i,j,:3] = np.dot(err2mod, err)
|
|
|
ERR[i,j,:3] = np.dot(err2mod, err)
|
|
|
|
|
|
|
|
|
dtpn = np.copy(image)
|
|
|
|
|
|
|
|
|
dtpn = np.copy(image).astype('int64')
|
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
for i in range(rows):
|
|
|
for j in range(cols):
|
|
|
for j in range(cols):
|
|
|
for x in range(3):
|
|
|
for x in range(3):
|
|
|
dtpn[i, j, x] = (int(ERR[i, j, x]) + int(image[i, j, x]))
|
|
|
|
|
|
|
|
|
dtpn[i, j, x] = abs(int(ERR[i, j, x]) + int(image[i, j, x]))
|
|
|
|
|
|
|
|
|
for i in range(rows):
|
|
|
for i in range(rows):
|
|
|
for j in range(cols):
|
|
|
for j in range(cols):
|
|
|
|
|
|
|
|
|
dtpn[i, j, 2] = max(0, dtpn[i, j, 2])
|
|
|
dtpn[i, j, 2] = max(0, dtpn[i, j, 2])
|
|
|
dtpn[i, j, 2] = min(255, dtpn[i, j, 2])
|
|
|
dtpn[i, j, 2] = min(255, dtpn[i, j, 2])
|
|
|
|
|
|
|
|
|
cv2.imshow('Dalt_Img', cv2.cvtColor(dtpn, cv2.COLOR_RGB2BGR))
|
|
|
|
|
|
|
|
|
result = dtpn.astype('uint8')
|
|
|
|
|
|
|
|
|
|
|
|
dalt = Dyschromasie(result,rows,cols, kanaele, 1, 'p')
|
|
|
|
|
|
dalt_p = dalt.Simulate()
|
|
|
|
|
|
|
|
|
|
|
|
cv2.imshow('Dalt_Img', cv2.cvtColor(dalt_p, cv2.COLOR_RGB2BGR))
|
|
|
cv2.waitKey(0) |
|
|
cv2.waitKey(0) |