Skip to content

Commit 4cea672

Browse files
author
Robert Sachunsky
committed
common: skip image/separator estimation if max=0
1 parent 529f7f5 commit 4cea672

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ocrd_cis/ocropy/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ def compute_images(binary, scale, maximages=5):
460460
461461
Returns a same-size bool array as a mask image.
462462
"""
463+
if maximages == 0:
464+
return binary == -1
463465
images = binary
464466
# d0 = odd(max(2,scale/5))
465467
# d1 = odd(max(2,scale/8))
@@ -599,6 +601,8 @@ def compute_separators_morph(binary, scale,
599601
600602
Returns a same-size bool array as separator mask.
601603
"""
604+
if maxseps == 0:
605+
return binary == -1
602606
LOG.debug("considering at most %g black column separators", maxseps)
603607
## no large vertical dilation here, because
604608
## that would turn letters into lines; but
@@ -663,6 +667,8 @@ def compute_colseps_conv(binary, scale=1.0, csminheight=10, maxcolseps=2):
663667
664668
Returns a same-size bool array as separator mask.
665669
"""
670+
if maxcolseps == 0:
671+
return binary == -1
666672
LOG.debug("considering at most %g whitespace column separators", maxcolseps)
667673
# find vertical whitespace by thresholding
668674
smoothed = filters.gaussian_filter(1.0*binary,(scale,scale*0.5))

0 commit comments

Comments
 (0)