Skip to content

Commit

Permalink
Ensure segmentation data type after connected components (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 authored Nov 20, 2024
1 parent 41de117 commit 1ef4777
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions micro_sam/instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def mask_data_to_segmentation(
object in the output will be mapped to zero (the background value).
min_object_size: The minimal size of an object in pixels.
max_object_size: The maximal size of an object in pixels.
label_masks: Whether to apply connected components to the result before remving small objects.
label_masks: Whether to apply connected components to the result before removing small objects.
Returns:
The instance segmentation.
Expand All @@ -85,7 +85,8 @@ def require_numpy(mask):
seg_id = this_seg_id + 1

if label_masks:
segmentation = label(segmentation)
segmentation = label(segmentation).astype(segmentation.dtype)

seg_ids, sizes = np.unique(segmentation, return_counts=True)

# In some cases objects may be smaller than peviously calculated,
Expand Down

0 comments on commit 1ef4777

Please sign in to comment.