Skip to content

Commit d318fa0

Browse files
fixing overflow for stitch3D
1 parent 334fd03 commit d318fa0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cellpose/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ def stitch3D(masks, stitch_threshold=0.25):
529529
mmax = masks[0].max()
530530
empty = 0
531531
for i in trange(len(masks) - 1):
532-
iou = metrics._intersection_over_union(masks[i + 1], masks[i])[1:, 1:]
533-
if mmax > 2**16 - 2:
532+
if masks.dtype == "uint16" and int(mmax) > max(0, 2**16 - 5 - masks[i + 1].max()):
534533
masks = masks.astype("uint32")
534+
iou = metrics._intersection_over_union(masks[i + 1], masks[i])[1:, 1:]
535535
if not iou.size and empty == 0:
536536
masks[i + 1] = masks[i + 1]
537537
mmax = masks[i + 1].max()

0 commit comments

Comments
 (0)