mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-03-24 08:02:45 +01:00
textline_contours: remove unnecessary resize_image, simplify
This commit is contained in:
parent
3370a3aa85
commit
8ebbe65c17
1 changed files with 8 additions and 22 deletions
|
|
@ -1241,30 +1241,21 @@ class Eynollah:
|
||||||
self.logger.debug("exit get_slopes_and_deskew_new_curved")
|
self.logger.debug("exit get_slopes_and_deskew_new_curved")
|
||||||
return tuple(zip(*results))
|
return tuple(zip(*results))
|
||||||
|
|
||||||
def textline_contours(self, img, use_patches, scaler_h, scaler_w, num_col_classifier=None):
|
def textline_contours(self, img, use_patches, num_col_classifier=None):
|
||||||
self.logger.debug('enter textline_contours')
|
self.logger.debug('enter textline_contours')
|
||||||
|
|
||||||
#img = img.astype(np.uint8)
|
|
||||||
img_org = np.copy(img)
|
|
||||||
img_h = img_org.shape[0]
|
|
||||||
img_w = img_org.shape[1]
|
|
||||||
img = resize_image(img_org, int(img_org.shape[0] * scaler_h), int(img_org.shape[1] * scaler_w))
|
|
||||||
|
|
||||||
prediction_textline = self.do_prediction(use_patches, img, self.model_zoo.get("textline"),
|
prediction_textline = self.do_prediction(use_patches, img, self.model_zoo.get("textline"),
|
||||||
marginal_of_patch_percent=0.15,
|
marginal_of_patch_percent=0.15,
|
||||||
n_batch_inference=3,
|
n_batch_inference=3,
|
||||||
threshold_art_class=self.threshold_art_class_textline)
|
threshold_art_class=self.threshold_art_class_textline)
|
||||||
|
|
||||||
prediction_textline = resize_image(prediction_textline, img_h, img_w)
|
|
||||||
|
|
||||||
#prediction_textline_longshot = self.do_prediction(False, img, self.model_zoo.get("textline"))
|
#prediction_textline_longshot = self.do_prediction(False, img, self.model_zoo.get("textline"))
|
||||||
#prediction_textline_longshot = resize_image(prediction_textline_longshot, img_h, img_w)
|
|
||||||
|
|
||||||
self.logger.debug('exit textline_contours')
|
self.logger.debug('exit textline_contours')
|
||||||
return ((prediction_textline==1).astype(np.uint8),
|
# suppress artificial boundary label
|
||||||
#(prediction_textline_longshot==1).astype(np.uint8),
|
result = (prediction_textline == 1).astype(np.uint8)
|
||||||
None
|
#, (prediction_textline_longshot==1).astype(np.uint8)
|
||||||
)
|
return result
|
||||||
|
|
||||||
def get_regions_light_v(self,img,is_image_enhanced, num_col_classifier):
|
def get_regions_light_v(self,img,is_image_enhanced, num_col_classifier):
|
||||||
self.logger.debug("enter get_regions_light_v")
|
self.logger.debug("enter get_regions_light_v")
|
||||||
|
|
@ -1879,14 +1870,9 @@ class Eynollah:
|
||||||
return img_res, is_image_enhanced, num_col_classifier, num_column_is_classified
|
return img_res, is_image_enhanced, num_col_classifier, num_column_is_classified
|
||||||
|
|
||||||
def run_textline(self, image_page, num_col_classifier=None):
|
def run_textline(self, image_page, num_col_classifier=None):
|
||||||
scaler_h_textline = 1#1.3 # 1.2#1.2
|
textline_mask_tot_ea = self.textline_contours(image_page, True,
|
||||||
scaler_w_textline = 1#1.3 # 0.9#1
|
num_col_classifier)
|
||||||
#print(image_page.shape)
|
#textline_mask_tot_ea = textline_mask_tot_ea.astype(np.int16)
|
||||||
textline_mask_tot_ea, _ = self.textline_contours(image_page, True,
|
|
||||||
scaler_h_textline,
|
|
||||||
scaler_w_textline,
|
|
||||||
num_col_classifier)
|
|
||||||
textline_mask_tot_ea = textline_mask_tot_ea.astype(np.int16)
|
|
||||||
|
|
||||||
if self.plotter:
|
if self.plotter:
|
||||||
self.plotter.save_plot_of_textlines(textline_mask_tot_ea, image_page)
|
self.plotter.save_plot_of_textlines(textline_mask_tot_ea, image_page)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue