Skip to content

Commit dd65ef3

Browse files
Fix corner cases for 3d annotator with stop annotations
1 parent b929d09 commit dd65ef3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

micro_sam/sam_annotator/annotator_3d.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@ def segment_range(z_start, z_stop, increment, stopping_criterion, threshold=None
7676
for z_start, z_stop in zip(segmented_slices[:-1], segmented_slices[1:]):
7777
slice_diff = z_stop - z_start
7878
z_mid = int((z_start + z_stop) // 2)
79+
7980
if slice_diff == 1: # the slices are adjacent -> we don't need to do anything
8081
pass
8182

83+
elif z_start == z0 and stop_lower: # the lower slice is stop: we just segment from upper
84+
segment_range(z_stop, z_start, -1, np.less_equal, verbose=verbose)
85+
86+
elif z_stop == z1 and stop_upper: # the upper slice is stop: we just segment from lower
87+
segment_range(z_start, z_stop, 1, np.greater_equal, verbose=verbose)
88+
8289
elif slice_diff == 2: # there is only one slice in between -> use combined mask
8390
z = z_start + 1
8491
seg_prompt = np.logical_or(seg[z_start] == 1, seg[z_stop] == 1)

0 commit comments

Comments
 (0)