Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit ecd682ed authored by tekin_g's avatar tekin_g
Browse files

add file to analyse results

parent 1708ee53
No related branches found
No related tags found
No related merge requests found
import os
import cv2
import numpy as np
from helpers.image import show_image
path ="/home/guney/Project/Richardson-Lucy-Net/pic_proc/data/output_from_server/"
a = os.listdir(path)
a = [path+i for i in a if i.split('.')[-1] == 'npz']
display = False
def var_similarity_multiscale(x,y,s):
x = cv2.resize(x, (x.shape[1] // s, x.shape[0] // s))
y = cv2.resize(y, (y.shape[1] // s, y.shape[0] // s))
return var_similarity(x,y)
def var_similarity(x,y):
cov_m = np.cov(x.flatten(),y.flatten())
return cov_m[0,1]/np.sqrt(cov_m[0,0]*cov_m[1,1])
for data in a:
data = np.load(data,allow_pickle=True)
inference = data["f_x"][0]
input = data["x"][0]
gt = data["y"][0]
if display:
show_image(inference,"inference")
show_image(gt,"gt")
show_image(input,"input")
# Compute the absolute difference between the images
diff = inference - gt
diff = np.where(diff<0,0.,diff)
_, thresholded_diff = cv2.threshold(diff, 0.1, 1.0, cv2.THRESH_BINARY)
thresholded_diff_bgr = cv2.cvtColor(thresholded_diff, cv2.COLOR_GRAY2BGR)
thresholded_diff_bgr[np.where((thresholded_diff_bgr == [1.0, 1.0, 1.0]).all(axis=2))] = [0, 0, 1.0]
diff = gt - inference
diff = np.where(diff<0,0.,diff)
_, thresholded_diff = cv2.threshold(diff, 0.1, 1.0, cv2.THRESH_BINARY)
thresholded_diff_bgr_2 = cv2.cvtColor(thresholded_diff, cv2.COLOR_GRAY2BGR)
thresholded_diff_bgr[np.where((thresholded_diff_bgr_2 == [1.0, 1.0, 1.0]).all(axis=2))] += [0, 1.0, 0.0]
highlighted_image = cv2.addWeighted(cv2.cvtColor(inference, cv2.COLOR_GRAY2BGR), 0.1, thresholded_diff_bgr, 0.9, 0)
show_image(highlighted_image,"diff")
show_image(cv2.resize(inference, (inference.shape[1] // 2, inference.shape[0] // 2)), "rescaled")
if cv2.waitKey() == ord('c'):
print("exiting")
cv2.destroyAllWindows()
exit(0)
print()
for s in range(1,6):
print("scale: {} s(gt,f(x)) = {}, s(gt,x) = {}".format(s,var_similarity_multiscale(gt,inference,s),var_similarity_multiscale(gt,input,s)))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment