Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ocrolib/psegutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def extract_masked(image,linedesc,pad=5,expand=0):
line = where(mask,line,amax(line))
return line

def reading_order(lines,highlight=None,debug=0):
def reading_order(lines,nocolumns=False,highlight=None,debug=0):
"""Given the list of lines (a list of 2D slices), computes
the partial reading order. The output is a binary 2D array
such that order[i,j] is true if line i comes before line j
Expand All @@ -141,7 +141,7 @@ def separates(w,u,v):
clf(); title("highlight"); imshow(binary); ginput(1,debug)
for i,u in enumerate(lines):
for j,v in enumerate(lines):
if x_overlaps(u,v):
if x_overlaps(u,v) or nocolumns:
if above(u,v):
order[i,j] = 1
else:
Expand Down
5 changes: 4 additions & 1 deletion ocropus-gpageseg
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,10 @@ def process1(job):

if not args.quiet: print_info("finding reading order")
lines = psegutils.compute_lines(segmentation,scale)
order = psegutils.reading_order([l.bounds for l in lines])
if args.maxcolseps>0 or args.blackseps:
order = psegutils.reading_order([l.bounds for l in lines])
else:
order = psegutils.reading_order([l.bounds for l in lines], nocolumns=True)
lsort = psegutils.topsort(order)

# renumber the labels so that they conform to the specs
Expand Down