Skip to content

Commit

Permalink
ocrolib.morph: for CC analysis, use 4-way instead of 8-way connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Mar 3, 2022
1 parent 5e49451 commit e673544
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ocrd_cis/ocropy/ocrolib/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def label(image,**kw):
- same-size Numpy array with integer labels for fg components
- number of components (eq. largest label)
"""
n, labels = cv2.connectedComponents(image.astype(uint8))
# default connectivity in OpenCV: 8 (which is equivalent to...)
# default connectivity in scikit-image: 2
n, labels = cv2.connectedComponents(image.astype(uint8), connectivity=4)
#n, labels = cv2.connectedComponentsWithAlgorithm(image.astype(uint8), connectivity=4, ltype=2, ccltype=cv2.CCL_DEFAULT)
return labels, n-1
# try: return measurements.label(image,**kw)
Expand Down

0 comments on commit e673544

Please sign in to comment.