Skip to content

Commit b17db87

Browse files
Improve performance of movement computation (vigra is too slow)
1 parent fe67103 commit b17db87

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

micro_sam/sam_annotator/annotator_tracking.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from napari import Viewer
66
from napari.utils import progress
77
from scipy.ndimage import shift
8-
from vigra.filters import eccentricityCenters
8+
9+
# this is more precise for comuting the centers, but slow!
10+
# from vigra.filters import eccentricityCenters
911

1012
from .. import util
1113
from ..segment_from_prompts import segment_from_mask, segment_from_points
@@ -23,9 +25,16 @@
2325
def _compute_movement(seg, t0, t1):
2426

2527
def compute_center(t):
26-
center = np.array(eccentricityCenters(seg[t].astype("uint32")))
27-
assert center.shape == (2, 2)
28-
return center[1]
28+
29+
# computation with vigra eccentricity centers (too slow)
30+
# center = np.array(eccentricityCenters(seg[t].astype("uint32")))
31+
# assert center.shape == (2, 2)
32+
# return center[1]
33+
34+
# computation with center of mass
35+
center = np.where(seg[t] == 1)
36+
center = np.array(np.mean(center[0]), np.mean(center[1]))
37+
return center
2938

3039
center0 = compute_center(t0)
3140
center1 = compute_center(t1)

0 commit comments

Comments
 (0)