Skip to content

Commit c39f642

Browse files
refactor: simplify and make more robust the dust operation
1 parent 5562f41 commit c39f642

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

cc3d.pyx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,17 +1136,11 @@ def dust(
11361136
11371137
if len(to_mask) == 0:
11381138
return img
1139-
elif len(to_mask) <= 5:
1140-
for label in to_mask:
1141-
img *= (cc_labels != label)
1142-
return img
11431139
1144-
rns = runs(cc_labels)
1140+
mask = np.isin(cc_labels, to_mask)
11451141
del cc_labels
1146-
1147-
for label in to_mask:
1148-
erase(rns[label], img)
1149-
1142+
np.logical_not(mask, out=mask)
1143+
np.multiply(img, mask, out=img)
11501144
return img.view(orig_dtype)
11511145
11521146
@cython.binding(True)

0 commit comments

Comments
 (0)