Skip to content

Commit ca0c35b

Browse files
peterlionelnewmanPeter Newman
and
Peter Newman
authored
speed up join close components (#90)
Co-authored-by: Peter Newman <peternewman@Peters-MacBook-Pro-4.local>
1 parent 4b42739 commit ca0c35b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,7 @@ venv.bak/
106106
test.py
107107
.DS_Store
108108

109+
# Itelli J
110+
.idea/
111+
109112
ext/skeletontricks/skeletontricks.cpp

kimimaro/postprocess.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,11 @@ def join_close_components(skeletons, radius=None):
107107
while len(skels) > 1:
108108
N = len(skels)
109109

110-
radii_matrix = np.zeros( (N, N), dtype=np.float32 ) + np.inf
111-
index_matrix = np.zeros( (N, N, 2), dtype=np.uint32 ) + -1
112-
113-
for i in range(len(skels)):
114-
for j in range(len(skels)):
115-
if i == j:
116-
continue
117-
elif radii_matrix[i,j] != np.inf:
118-
continue
110+
radii_matrix = np.full( (N, N), np.inf, dtype=np.float32 )
111+
index_matrix = np.full( (N, N, 2), -1, dtype=np.uint32 )
112+
113+
for i in range(N):
114+
for j in range(i + 1, N): # compute upper triangle only
119115

120116
s1, s2 = skels[i], skels[j]
121117
dist_matrix = scipy.spatial.distance.cdist(s1.vertices, s2.vertices)

0 commit comments

Comments
 (0)