From da9e00cfe544e162e893ed5fd17fa4552262fae5 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Mon, 27 Apr 2026 13:04:09 +0200 Subject: [PATCH] =?UTF-8?q?consistently=20handle=20textline=20mask=20with?= =?UTF-8?q?=20respect=20to=20drop-capital=20mask=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - suppress drop-capital in textline mask for textline contours - elevate drop-capital in textline mask for reading order boxes --- src/eynollah/eynollah.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/eynollah/eynollah.py b/src/eynollah/eynollah.py index d7b814b..d056d4b 100644 --- a/src/eynollah/eynollah.py +++ b/src/eynollah/eynollah.py @@ -2326,18 +2326,17 @@ class Eynollah: return if num_col_classifier in (1,2): - org_h_l_m = textline_mask_tot_ea.shape[0] - org_w_l_m = textline_mask_tot_ea.shape[1] + img_h_org, img_w_org = text_regions_p.shape if num_col_classifier == 1: img_w_new = 2000 else: img_w_new = 2400 - img_h_new = img_w_new * textline_mask_tot_ea.shape[0] // textline_mask_tot_ea.shape[1] + img_h_new = img_w_new * img_h_org // img_w_org text_regions_p_new = resize_image(text_regions_p, img_h_new, img_w_new) table_prediction_new = resize_image(table_prediction, img_h_new, img_w_new) self.run_marginals(num_col_classifier, slope_deskew, text_regions_p_new, table_prediction_new) - text_regions_p = resize_image(text_regions_p_new, org_h_l_m, org_w_l_m) + text_regions_p = resize_image(text_regions_p_new, img_h_org, img_w_org) if self.plotter: self.plotter.save_plot_of_layout_main_all(text_regions_p, image_page, image['name']) @@ -2353,7 +2352,8 @@ class Eynollah: table_prediction) if self.full_layout: - textline_mask_tot_ea_org[text_regions_p == label_drop_fl] = 0 + textline_mask_tot_ea_org[text_regions_p == label_drop_fl] = 0 # skip for textlines + textline_mask_tot_ea[text_regions_p == label_drop_fl] = 1 # needed for reading order polygons_of_drop_capitals = return_contours_of_interested_region(text_regions_p, label_drop_fl, min_area=0.00003) @@ -2435,7 +2435,7 @@ class Eynollah: else: self.logger.info("Mode: Curved line detection") - textline_mask_tot_ea_erode = cv2.erode(textline_mask_tot_ea, kernel=KERNEL, iterations=2) + textline_mask_tot_ea_erode = cv2.erode(textline_mask_tot_ea_org, kernel=KERNEL, iterations=2) all_found_textline_polygons, slopes = \ self.get_slopes_and_deskew_new_curved( polygons_of_textregions, textline_mask_tot_ea_erode,