Skip to content

Commit 64083c7

Browse files
author
Robert Sachunsky
committed
ocropy.segment: improve within-region hmerge rule
when merging textlines within text regions horizontally, - do not only respect existing regions and fg separators (in blocking merges), but also bg separators - enlarge the region mask to the newly merged line bg
1 parent 2ee845b commit 64083c7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ocrd_cis/ocropy/segment.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def _process_element(self, element, ignore, image, coords, element_id, file_id,
521521
element_name, element_id)
522522
except Exception as err:
523523
LOG.error('Cannot region-segment %s "%s": %s',
524-
element_name, element_id, err)
524+
element_name, element_id, err)
525525
region_labels = np.where(line_labels > len(ignore), 1 + len(ignore), line_labels)
526526

527527
# prepare reading order group index
@@ -563,7 +563,9 @@ def _process_element(self, element, ignore, image, coords, element_id, file_id,
563563
order[np.setdiff1d(region_line_labels0, element_bin * region_line_labels)] = 0
564564
region_line_labels = order[region_line_labels]
565565
# avoid horizontal gaps
566-
region_line_labels = hmerge_line_seeds(element_bin, region_line_labels, scale, seps=sepmask)
566+
region_line_labels = hmerge_line_seeds(element_bin, region_line_labels, scale,
567+
seps=np.maximum(sepmask, colseps))
568+
region_mask |= region_line_labels > 0
567569
# find contours for region (can be non-contiguous)
568570
regions, _ = masks2polygons(region_mask * region_label, element_bin,
569571
'%s "%s"' % (element_name, element_id),

0 commit comments

Comments
 (0)