From 208bde706f6a998af7811372ca80be82d3af95cb Mon Sep 17 00:00:00 2001 From: vahidrezanezhad Date: Wed, 30 Apr 2025 13:55:09 +0200 Subject: [PATCH] resolving issue #158 --- src/eynollah/utils/separate_lines.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/eynollah/utils/separate_lines.py b/src/eynollah/utils/separate_lines.py index 3499c29..6602574 100644 --- a/src/eynollah/utils/separate_lines.py +++ b/src/eynollah/utils/separate_lines.py @@ -214,9 +214,13 @@ def separate_lines(img_patch, contour_text_interest, thetha, x_help, y_help): textline_con_fil=filter_contours_area_of_image(img_patch, textline_con, hierarchy, max_area=1, min_area=0.0008) - y_diff_mean=np.mean(np.diff(peaks_new_tot))#self.find_contours_mean_y_diff(textline_con_fil) - sigma_gaus=int( y_diff_mean * (7./40.0) ) - #print(sigma_gaus,'sigma_gaus') + + if len(np.diff(peaks_new_tot))>0: + y_diff_mean=np.mean(np.diff(peaks_new_tot))#self.find_contours_mean_y_diff(textline_con_fil) + sigma_gaus=int( y_diff_mean * (7./40.0) ) + else: + sigma_gaus=12 + except: sigma_gaus=12 if sigma_gaus<3: @@ -1616,6 +1620,7 @@ def do_work_of_slopes_new( textline_con_fil = filter_contours_area_of_image(img_int_p, textline_con, hierarchy, max_area=1, min_area=0.00008) + y_diff_mean = find_contours_mean_y_diff(textline_con_fil) if len(textline_con_fil) > 1 else np.NaN if np.isnan(y_diff_mean): slope_for_all = MAX_SLOPE @@ -1641,13 +1646,6 @@ def do_work_of_slopes_new( all_text_region_raw = textline_mask_tot_ea[y: y + h, x: x + w].copy() mask_only_con_region = mask_only_con_region[y: y + h, x: x + w] - ##plt.imshow(textline_mask_tot_ea) - ##plt.show() - ##plt.imshow(all_text_region_raw) - ##plt.show() - ##plt.imshow(mask_only_con_region) - ##plt.show() - all_text_region_raw[mask_only_con_region == 0] = 0 cnt_clean_rot = textline_contours_postprocessing(all_text_region_raw, slope_for_all, contour_par, box_text)