Skip to content

Commit ebd8235

Browse files
authored
Merge pull request #252 from jze/gpageseg
Fix regression in ocropus-gpageseg #251
2 parents d823ba4 + c74d2be commit ebd8235

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ocropus-gpageseg

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ parser.add_argument('files',nargs='+')
106106
args = parser.parse_args()
107107
args.files = ocrolib.glob_all(args.files)
108108

109-
109+
def find(condition):
110+
"Return the indices where ravel(condition) is true"
111+
res, = np.nonzero(np.ravel(condition))
112+
return res
113+
110114
def norm_max(v):
111115
return v/np.amax(v)
112116

@@ -302,7 +306,7 @@ def compute_line_seeds(binary,bottom,top,colseps,scale):
302306
seeds = np.zeros(binary.shape,'i')
303307
delta = max(3,int(scale/2))
304308
for x in range(bmarked.shape[1]):
305-
transitions = sorted([(y,1) for y in np.where(bmarked[:,x])[0]]+[(y,0) for y in np.where(tmarked[:,x][0])])[::-1]
309+
transitions = sorted([(y,1) for y in find(bmarked[:,x])]+[(y,0) for y in find(tmarked[:,x])])[::-1]
306310
transitions += [(0,0)]
307311
for l in range(len(transitions)-1):
308312
y0,s0 = transitions[l]

0 commit comments

Comments
 (0)