-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontrast.py
38 lines (34 loc) · 964 Bytes
/
contrast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import json
import cv2
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import colors
from matplotlib.ticker import PercentFormatter
prefix = '/home/HDD/bgnn_data/validation_images/'
results = json.load(open('../metadata_enhance.json'))
df = pd.read_csv('/home/HDD/bgnn_data/image_quality_metadata_20210208.csv')
values = []
#d = []
#n = []
#b = []
for file in results.keys():
try:
curr = results[file]
back = curr['fish'][0]['background']['mean']
fore = curr['fish'][0]['foreground']['mean']
diff = back - fore
if diff > 0:
values.append((file, diff))
except:
pass
#values.sort(key=lambda x: x[1], reverse=True)
# print(values)
# exit(0)
print(np.mean([x[1] for x in values]))
print(np.std([x[1] for x in values]))
exit(0)
plt.xlabel('Foreground Background Intensity Difference')
plt.ylabel('Count')
plt.hist([x[1] for x in values], bins=20)
plt.show()