Skip to content

Commit d05958a

Browse files
perf: faster 26-connected connected_components_stack
1 parent 9af68e8 commit d05958a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cc3d/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,14 @@ def connected_components_stack(
447447
if bottom_cc_labels[x,y] == 0:
448448
continue
449449

450+
if ((not binary_image and bottom_cc_img[x,y] == image[x,y,0])
451+
or (binary_image and bottom_cc_img[x,y] and image[x,y,0])):
452+
453+
equivalences.union(
454+
bottom_cc_labels[x,y], top_cc_labels[x,y]
455+
)
456+
continue
457+
450458
for y0 in range(max(y - 1, 0), min(y + 1, image.shape[1] - 1) + 1):
451459
for x0 in range(max(x - 1, 0), min(x + 1, image.shape[0] - 1) + 1):
452460
if top_cc_labels[x0,y0] == 0:

0 commit comments

Comments
 (0)