Skip to content

Commit e673544

Browse files
author
Robert Sachunsky
committed
ocrolib.morph: for CC analysis, use 4-way instead of 8-way connectivity
1 parent 5e49451 commit e673544

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ocrd_cis/ocropy/ocrolib/morph.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ def label(image,**kw):
1919
- same-size Numpy array with integer labels for fg components
2020
- number of components (eq. largest label)
2121
"""
22-
n, labels = cv2.connectedComponents(image.astype(uint8))
22+
# default connectivity in OpenCV: 8 (which is equivalent to...)
23+
# default connectivity in scikit-image: 2
24+
n, labels = cv2.connectedComponents(image.astype(uint8), connectivity=4)
2325
#n, labels = cv2.connectedComponentsWithAlgorithm(image.astype(uint8), connectivity=4, ltype=2, ccltype=cv2.CCL_DEFAULT)
2426
return labels, n-1
2527
# try: return measurements.label(image,**kw)

0 commit comments

Comments
 (0)