-
Notifications
You must be signed in to change notification settings - Fork 0
/
Normalizer.py
49 lines (29 loc) · 1.06 KB
/
Normalizer.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
39
40
41
42
43
44
45
46
47
48
49
from os import listdir
input_path = "E:\Faks\Zavrsni\FullDB\Data\\"
output_path = "E:\Faks\Zavrsni\FullDB\\"
norm = open("E:\Faks\Zavrsni\FullDB\\normalization_data.txt", "r")
mean = {}
stdev = {}
for line in norm:
if line[0] == "$":
spl = line.split('->')
mean[spl[0][1:]] = spl[1]
elif line[0] == "&":
spl = line.split('->')
stdev[spl[0][1:]] = spl[1]
planes = listdir(input_path)
for plane in planes:
cameras = listdir(input_path + plane)
for camera in cameras:
output = ''
file = open(input_path + plane + '\\' + camera + '\\' + 'coefficients.txt', "r")
for line in file:
if line[0] == "*":
spl = line.split("->")
save = (float(spl[1]) - float(mean[spl[0][1:]])) / float(stdev[spl[0][1:]])
output += spl[0] + '->' + str(save) + '\n'
else:
output += line
file.close()
with open(input_path + plane + '\\' + camera + '\\' + 'normal.txt', "w+") as normal:
normal.write(output)