Skip to content

Commit

Permalink
speed up join close components
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Newman authored and Peter Newman committed Jul 19, 2024
1 parent ed9c117 commit a898991
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ venv.bak/
test.py
.DS_Store

# Itelli J
.idea/

ext/skeletontricks/skeletontricks.cpp
14 changes: 5 additions & 9 deletions kimimaro/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,11 @@ def join_close_components(skeletons, radius=None):
while len(skels) > 1:
N = len(skels)

radii_matrix = np.zeros( (N, N), dtype=np.float32 ) + np.inf
index_matrix = np.zeros( (N, N, 2), dtype=np.uint32 ) + -1

for i in range(len(skels)):
for j in range(len(skels)):
if i == j:
continue
elif radii_matrix[i,j] != np.inf:
continue
radii_matrix = np.full( (N, N), np.inf, dtype=np.float32 )
index_matrix = np.full( (N, N, 2), -1, dtype=np.uint32 )

for i in range(N):
for j in range(i + 1, N): # compute upper triangle only

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

0 comments on commit a898991

Please sign in to comment.