mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-06-14 14:49:54 +02:00
remove redundant parentheses
This commit is contained in:
parent
005b6988f4
commit
badf80039f
8 changed files with 18 additions and 18 deletions
|
@ -71,10 +71,10 @@ def machine_based_reading_order(dir_xml, dir_out_modal_image, dir_out_classes, i
|
|||
)
|
||||
|
||||
def binarization(patches, model_dir, input_image, output_image, dir_in, dir_out):
|
||||
if not dir_out and (dir_in):
|
||||
if not dir_out and dir_in:
|
||||
print("Error: You used -di but did not set -do")
|
||||
sys.exit(1)
|
||||
elif dir_out and not (dir_in):
|
||||
elif dir_out and not dir_in:
|
||||
print("Error: You used -do to write out binarized images but have not set -di")
|
||||
sys.exit(1)
|
||||
SbbBinarizer(model_dir).run(image_path=input_image, use_patches=patches, save=output_image, dir_in=dir_in, dir_out=dir_out)
|
||||
|
|
|
@ -4517,9 +4517,9 @@ class Eynollah:
|
|||
textline_mask_tot_ea_org[img_revised_tab==drop_label_in_full_layout] = 0
|
||||
|
||||
|
||||
text_only = ((img_revised_tab[:, :] == 1)) * 1
|
||||
text_only = (img_revised_tab[:, :] == 1) * 1
|
||||
if np.abs(slope_deskew) >= SLOPE_THRESHOLD:
|
||||
text_only_d = ((text_regions_p_1_n[:, :] == 1)) * 1
|
||||
text_only_d = (text_regions_p_1_n[:, :] == 1) * 1
|
||||
|
||||
#print("text region early 2 in %.1fs", time.time() - t0)
|
||||
###min_con_area = 0.000005
|
||||
|
|
|
@ -9,7 +9,7 @@ from .utils import crop_image_inside_box
|
|||
from .utils.rotate import rotate_image_different
|
||||
from .utils.resize import resize_image
|
||||
|
||||
class EynollahPlotter():
|
||||
class EynollahPlotter:
|
||||
"""
|
||||
Class collecting all the plotting and image writing methods
|
||||
"""
|
||||
|
|
|
@ -1255,11 +1255,11 @@ def order_of_regions(textline_mask, contours_main, contours_header, y_ref):
|
|||
top = peaks_neg_new[i]
|
||||
down = peaks_neg_new[i + 1]
|
||||
indexes_in = matrix_of_orders[:, 0][(matrix_of_orders[:, 3] >= top) &
|
||||
((matrix_of_orders[:, 3] < down))]
|
||||
(matrix_of_orders[:, 3] < down)]
|
||||
cxs_in = matrix_of_orders[:, 2][(matrix_of_orders[:, 3] >= top) &
|
||||
((matrix_of_orders[:, 3] < down))]
|
||||
(matrix_of_orders[:, 3] < down)]
|
||||
cys_in = matrix_of_orders[:, 3][(matrix_of_orders[:, 3] >= top) &
|
||||
((matrix_of_orders[:, 3] < down))]
|
||||
(matrix_of_orders[:, 3] < down)]
|
||||
types_of_text = matrix_of_orders[:, 1][(matrix_of_orders[:, 3] >= top) &
|
||||
(matrix_of_orders[:, 3] < down)]
|
||||
index_types_of_text = matrix_of_orders[:, 4][(matrix_of_orders[:, 3] >= top) &
|
||||
|
@ -1397,7 +1397,7 @@ def return_points_with_boundies(peaks_neg_fin, first_point, last_point):
|
|||
|
||||
def find_number_of_columns_in_document(region_pre_p, num_col_classifier, tables, pixel_lines, contours_h=None):
|
||||
t_ins_c0 = time.time()
|
||||
separators_closeup=( (region_pre_p[:,:,:]==pixel_lines))*1
|
||||
separators_closeup= (region_pre_p[:, :, :] == pixel_lines) * 1
|
||||
separators_closeup[0:110,:,:]=0
|
||||
separators_closeup[separators_closeup.shape[0]-150:,:,:]=0
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from collections import Counter
|
|||
REGION_ID_TEMPLATE = 'region_%04d'
|
||||
LINE_ID_TEMPLATE = 'region_%04d_line_%04d'
|
||||
|
||||
class EynollahIdCounter():
|
||||
class EynollahIdCounter:
|
||||
|
||||
def __init__(self, region_idx=0, line_idx=0):
|
||||
self._counter = Counter()
|
||||
|
|
|
@ -71,7 +71,7 @@ def get_marginals(text_with_lines, text_regions, num_col, slope_deskew, light_ve
|
|||
|
||||
peaks, _ = find_peaks(text_with_lines_y_rev, height=0)
|
||||
peaks=np.array(peaks)
|
||||
peaks=peaks[(peaks>first_nonzero) & ((peaks<last_nonzero))]
|
||||
peaks=peaks[(peaks>first_nonzero) & (peaks < last_nonzero)]
|
||||
peaks=peaks[region_sum_0[peaks]<min_textline_thickness ]
|
||||
|
||||
|
||||
|
|
|
@ -1478,9 +1478,9 @@ def separate_lines_new2(img_path, thetha, num_col, slope_region, logger=None, pl
|
|||
img_int = np.zeros((img_xline.shape[0], img_xline.shape[1]))
|
||||
img_int[:, :] = img_xline[:, :] # img_patch_org[:,:,0]
|
||||
|
||||
img_resized = np.zeros((int(img_int.shape[0] * (1.2)), int(img_int.shape[1] * (3))))
|
||||
img_resized[int(img_int.shape[0] * (0.1)) : int(img_int.shape[0] * (0.1)) + img_int.shape[0],
|
||||
int(img_int.shape[1] * (1.0)) : int(img_int.shape[1] * (1.0)) + img_int.shape[1]] = img_int[:, :]
|
||||
img_resized = np.zeros((int(img_int.shape[0] * 1.2), int(img_int.shape[1] * 3)))
|
||||
img_resized[int(img_int.shape[0] * 0.1): int(img_int.shape[0] * 0.1) + img_int.shape[0],
|
||||
int(img_int.shape[1] * 1.0): int(img_int.shape[1] * 1.0) + img_int.shape[1]] = img_int[:, :]
|
||||
# plt.imshow(img_xline)
|
||||
# plt.show()
|
||||
img_line_rotated = rotate_image(img_resized, slopes_tile_wise[i])
|
||||
|
@ -1492,8 +1492,8 @@ def separate_lines_new2(img_path, thetha, num_col, slope_region, logger=None, pl
|
|||
img_patch_separated_returned[:, :][img_patch_separated_returned[:, :] != 0] = 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.0)) : int(img_int.shape[1] * (1.0)) + img_int.shape[1]]
|
||||
int(img_int.shape[0] * 0.1): int(img_int.shape[0] * 0.1) + img_int.shape[0],
|
||||
int(img_int.shape[1] * 1.0): int(img_int.shape[1] * 1.0) + img_int.shape[1]]
|
||||
|
||||
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
|
||||
|
@ -1523,7 +1523,7 @@ def return_deskew_slop(img_patch_org, sigma_des,n_tot_angles=100,
|
|||
img_int[:,:]=img_patch_org[:,:]#img_patch_org[:,:,0]
|
||||
|
||||
max_shape=np.max(img_int.shape)
|
||||
img_resized=np.zeros((int( max_shape*(1.1) ) , int( max_shape*(1.1) ) ))
|
||||
img_resized=np.zeros((int(max_shape * 1.1) , int(max_shape * 1.1)))
|
||||
|
||||
onset_x=int((img_resized.shape[1]-img_int.shape[1])/2.)
|
||||
onset_y=int((img_resized.shape[0]-img_int.shape[0])/2.)
|
||||
|
|
|
@ -21,7 +21,7 @@ from ocrd_models.ocrd_page import (
|
|||
)
|
||||
import numpy as np
|
||||
|
||||
class EynollahXmlWriter():
|
||||
class EynollahXmlWriter:
|
||||
|
||||
def __init__(self, *, dir_out, image_filename, curved_line,textline_light, pcgts=None):
|
||||
self.logger = getLogger('eynollah.writer')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue