diff --git a/qurator/eynollah/eynollah.py b/qurator/eynollah/eynollah.py index 9bb95c9..d001753 100644 --- a/qurator/eynollah/eynollah.py +++ b/qurator/eynollah/eynollah.py @@ -47,7 +47,7 @@ from .utils.rotate import ( rotation_not_90_func_full_layout) from .utils.separate_lines import ( textline_contours_postprocessing, - seperate_lines_new2, + separate_lines_new2, return_deskew_slop) from .utils.drop_capitals import ( adhere_drop_capital_region_into_cprresponding_textline, @@ -816,7 +816,7 @@ class Eynollah: all_box_coord_per_process = [] index_by_text_region_contours = [] - textline_cnt_seperated = np.zeros(textline_mask_tot_ea.shape) + textline_cnt_separated = np.zeros(textline_mask_tot_ea.shape) for mv in range(len(boxes_text)): @@ -868,19 +868,19 @@ class Eynollah: textline_biggest_region = mask_biggest * textline_mask_tot_ea # print(slope_for_all,'slope_for_all') - textline_rotated_seperated = seperate_lines_new2(textline_biggest_region[y : y + h, x : x + w], 0, num_col, slope_for_all, plotter=self.plotter) + textline_rotated_separated = separate_lines_new2(textline_biggest_region[y : y + h, x : x + w], 0, num_col, slope_for_all, plotter=self.plotter) # new line added - ##print(np.shape(textline_rotated_seperated),np.shape(mask_biggest)) - textline_rotated_seperated[mask_region_in_patch_region[:, :] != 1] = 0 + ##print(np.shape(textline_rotated_separated),np.shape(mask_biggest)) + textline_rotated_separated[mask_region_in_patch_region[:, :] != 1] = 0 # till here - textline_cnt_seperated[y : y + h, x : x + w] = textline_rotated_seperated - textline_region_in_image[y : y + h, x : x + w] = textline_rotated_seperated + textline_cnt_separated[y : y + h, x : x + w] = textline_rotated_separated + textline_region_in_image[y : y + h, x : x + w] = textline_rotated_separated # plt.imshow(textline_region_in_image) # plt.show() - # plt.imshow(textline_cnt_seperated) + # plt.imshow(textline_cnt_separated) # plt.show() pixel_img = 1 diff --git a/qurator/eynollah/utils/__init__.py b/qurator/eynollah/utils/__init__.py index 120dfc5..8edd522 100644 --- a/qurator/eynollah/utils/__init__.py +++ b/qurator/eynollah/utils/__init__.py @@ -1723,7 +1723,7 @@ def return_boxes_of_images_by_order_of_reading_new(spliter_y_new, regions_withou - #check if there is a big seperater in this y_mains_sep_ohne_grenzen + #check if there is a big separater in this y_mains_sep_ohne_grenzen args_early_ys=np.array(range(len(y_type_2))) diff --git a/qurator/eynollah/utils/separate_lines.py b/qurator/eynollah/utils/separate_lines.py index a1095b0..feb8cb1 100644 --- a/qurator/eynollah/utils/separate_lines.py +++ b/qurator/eynollah/utils/separate_lines.py @@ -125,7 +125,7 @@ def dedup_separate_lines(img_patch, contour_text_interest, thetha, axis): return x, y, x_d, y_d, xv, x_min_cont, y_min_cont, x_max_cont, y_max_cont, first_nonzero, y_padded_up_to_down_padded, y_padded_smoothed, peaks, peaks_neg, rotation_matrix -def seperate_lines(img_patch, contour_text_interest, thetha, x_help, y_help): +def separate_lines(img_patch, contour_text_interest, thetha, x_help, y_help): (h, w) = img_patch.shape[:2] center = (w // 2, h // 2) @@ -671,7 +671,7 @@ def seperate_lines(img_patch, contour_text_interest, thetha, x_help, y_help): return peaks, textline_boxes_rot -def seperate_lines_vertical(img_patch, contour_text_interest, thetha): +def separate_lines_vertical(img_patch, contour_text_interest, thetha): thetha = thetha + 90 contour_text_interest_copy = contour_text_interest.copy() @@ -968,7 +968,7 @@ def seperate_lines_vertical(img_patch, contour_text_interest, thetha): return peaks, textline_boxes_rot -def seperate_lines_new_inside_teils2(img_patch, thetha): +def separate_lines_new_inside_teils2(img_patch, thetha): (h, w) = img_patch.shape[:2] center = (w // 2, h // 2) @@ -1183,7 +1183,7 @@ def seperate_lines_new_inside_teils2(img_patch, thetha): img_patch = cv2.erode(img_patch, kernel, iterations=1) return img_patch -def seperate_lines_new_inside_teils(img_path, thetha): +def separate_lines_new_inside_teils(img_path, thetha): (h, w) = img_path.shape[:2] center = (w // 2, h // 2) M = cv2.getRotationMatrix2D(center, -thetha, 1.0) @@ -1326,7 +1326,7 @@ def seperate_lines_new_inside_teils(img_path, thetha): img_path = cv2.erode(img_path, kernel, iterations=2) return img_path -def seperate_lines_vertical_cont(img_patch, contour_text_interest, thetha, box_ind, add_boxes_coor_into_textlines): +def separate_lines_vertical_cont(img_patch, contour_text_interest, thetha, box_ind, add_boxes_coor_into_textlines): kernel = np.ones((5, 5), np.uint8) pixel = 255 min_area = 0 @@ -1451,9 +1451,9 @@ def textline_contours_postprocessing(textline_mask, slope, contour_text_interest # print('juzaa') if abs(slope) > 45: # print(add_boxes_coor_into_textlines,'avval') - _, contours_rotated_clean = seperate_lines_vertical_cont(textline_mask, contours_text_rot[ind_big_con], box_ind, slope, add_boxes_coor_into_textlines=add_boxes_coor_into_textlines) + _, contours_rotated_clean = separate_lines_vertical_cont(textline_mask, contours_text_rot[ind_big_con], box_ind, slope, add_boxes_coor_into_textlines=add_boxes_coor_into_textlines) else: - _, contours_rotated_clean = seperate_lines(dst, contours_text_rot[ind_big_con], slope, x_help, y_help) + _, contours_rotated_clean = separate_lines(dst, contours_text_rot[ind_big_con], slope, x_help, y_help) except: @@ -1461,7 +1461,7 @@ def textline_contours_postprocessing(textline_mask, slope, contour_text_interest return contours_rotated_clean -def seperate_lines_new2(img_path, thetha, num_col, slope_region, plotter=None): +def separate_lines_new2(img_path, thetha, num_col, slope_region, plotter=None): if num_col == 1: num_patches = int(img_path.shape[1] / 200.0) @@ -1555,15 +1555,15 @@ def seperate_lines_new2(img_path, thetha, num_col, slope_region, plotter=None): img_line_rotated = rotate_image(img_resized, slopes_tile_wise[i]) img_line_rotated[:, :][img_line_rotated[:, :] != 0] = 1 - img_patch_seperated = seperate_lines_new_inside_teils2(img_line_rotated, 0) + img_patch_separated = separate_lines_new_inside_teils2(img_line_rotated, 0) - img_patch_seperated_returned = rotate_image(img_patch_seperated, -slopes_tile_wise[i]) - img_patch_seperated_returned[:, :][img_patch_seperated_returned[:, :] != 0] = 1 + img_patch_separated_returned = rotate_image(img_patch_separated, -slopes_tile_wise[i]) + img_patch_separated_returned[:, :][img_patch_separated_returned[:, :] != 0] = 1 - img_patch_seperated_returned_true_size = img_patch_seperated_returned[int(img_int.shape[0] * (0.1)) : int(img_int.shape[0] * (0.1)) + img_int.shape[0], int(img_int.shape[1] * (1)) : int(img_int.shape[1] * (1)) + img_int.shape[1]] + img_patch_separated_returned_true_size = img_patch_separated_returned[int(img_int.shape[0] * (0.1)) : int(img_int.shape[0] * (0.1)) + img_int.shape[0], int(img_int.shape[1] * (1)) : int(img_int.shape[1] * (1)) + img_int.shape[1]] - img_patch_seperated_returned_true_size = img_patch_seperated_returned_true_size[:, margin : length_x - margin] - img_patch_ineterst_revised[:, index_x_d + margin : index_x_u - margin] = img_patch_seperated_returned_true_size + img_patch_separated_returned_true_size = img_patch_separated_returned_true_size[:, margin : length_x - margin] + img_patch_ineterst_revised[:, index_x_d + margin : index_x_u - margin] = img_patch_separated_returned_true_size # plt.imshow(img_patch_ineterst_revised) # plt.show()