-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheatmapgen.py
More file actions
29 lines (21 loc) · 780 Bytes
/
heatmapgen.py
File metadata and controls
29 lines (21 loc) · 780 Bytes
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
import numpy as np
import os
import cv2
from scipy.misc import imsave
directory = 'E:/OneDrive/EM-Search/MJK-SvJ/Data/A'
os.chdir(directory)
def gen_heatmaps():
for f in os.listdir(os.getcwd()):
out = np.zeros([256, 256])
with open(f) as g:
gazedata = np.genfromtxt(f, dtype=np.int32, delimiter=',', skip_header=1)
gazedata = gazedata[:, 1:3]
gazedata = np.multiply(gazedata, 0.2)
gazedata[gazedata >= 256] = 255
xgazedata = np.int32(gazedata[:,0])
ygazedata = np.int32(gazedata[:,1])
for i in range(len(ygazedata)):
out[ygazedata[i], xgazedata[i]] += 255
out[:, :] = cv2.blur(out[:, :], (3, 3))
imsave("Pics/" + f + '.png', out)
gen_heatmaps()