-
Notifications
You must be signed in to change notification settings - Fork 0
/
FKA_gen.py
54 lines (46 loc) · 1.03 KB
/
FKA_gen.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
50
51
52
53
54
import cv2
import numpy as np
import math
# FKA Algo
I = np.zeros((256, 256), dtype="uint8")
x0 = 129
y0 = 129
W = np.zeros((256, 256), dtype="uint8")
# Calculate distance matrix
for i in range(256):
for j in range(256):
W[i][j] = np.sqrt((i - x0) ** 2 + (j - y0) ** 2)
print(W)
a = 12
b = 40
Rad = []
# Generate radial profiles
for r in range(a, b):
ff = []
for i in range(256):
for j in range(256):
if math.ceil(W[i][j]) == r:
ff.append("I[" + str(i) + "]" + "[" + str(j) + "]")
Rad.append(ff)
# Write radial profile function to file
tt = open("FKA.py", "w")
tt.write("def FKA(I):\n")
tt.write(" R=[]\n")
a = 5
for i in Rad:
ot = False
tt.write(" R.append((")
d = 0
for j in i:
if d < 5000:
if ot:
tt.write("+" + str(j))
d += 1
else:
tt.write(str(j))
ot = True
d += 1
tt.write(")/" + str(d) + ".0)\n")
a += 1
tt.write(" return R")
tt.close()