mirror of
				https://github.com/qurator-spk/eynollah.git
				synced 2025-10-27 15:54:13 +01:00 
			
		
		
		
	saving enhanced image in org or scaled resolution
This commit is contained in:
		
							parent
							
								
									3b475915c7
								
							
						
					
					
						commit
						9342b76038
					
				
					 3 changed files with 15 additions and 6 deletions
				
			
		|  | @ -116,6 +116,12 @@ def binarization(patches, model_dir, input_image, output_image, dir_in, dir_out) | |||
|     "-ncl", | ||||
|     help="upper limit of columns in document image", | ||||
| ) | ||||
| @click.option( | ||||
|     "--save_org_scale/--no_save_org_scale", | ||||
|     "-sos/-nosos", | ||||
|     is_flag=True, | ||||
|     help="if this parameter set to true, this tool will save the enhanced image in org scale.", | ||||
| ) | ||||
| @click.option( | ||||
|     "--log_level", | ||||
|     "-l", | ||||
|  | @ -123,7 +129,7 @@ def binarization(patches, model_dir, input_image, output_image, dir_in, dir_out) | |||
|     help="Override log level globally to this", | ||||
| ) | ||||
| 
 | ||||
| def enhancement(image, out, overwrite, dir_in, model, num_col_upper, num_col_lower, log_level): | ||||
| def enhancement(image, out, overwrite, dir_in, model, num_col_upper, num_col_lower, save_org_scale,  log_level): | ||||
|     initLogging() | ||||
|     if log_level: | ||||
|         getLogger('enhancement').setLevel(getLevelName(log_level)) | ||||
|  | @ -134,6 +140,7 @@ def enhancement(image, out, overwrite, dir_in, model, num_col_upper, num_col_low | |||
|         dir_out=out, | ||||
|         num_col_upper=num_col_upper, | ||||
|         num_col_lower=num_col_lower, | ||||
|         save_org_scale=save_org_scale, | ||||
|     ) | ||||
|     if dir_in: | ||||
|         enhancer_object.run(dir_in=dir_in, overwrite=overwrite) | ||||
|  |  | |||
|  | @ -5434,10 +5434,9 @@ class Eynollah_ocr: | |||
|                                     img_crop = img_poly_on_img[y:y+h, x:x+w, :] | ||||
|                                      | ||||
| 
 | ||||
|                                          | ||||
|                                     #print(file_name, angle_degrees,w*h , mask_poly[:,:,0].sum(),  mask_poly[:,:,0].sum() /float(w*h) , 'didi') | ||||
|                                     if not self.do_not_mask_with_textline_contour: | ||||
|                                         if angle_degrees > 15: | ||||
|                                         if angle_degrees > 3: | ||||
|                                             better_des_slope = get_orientation_moments(textline_coords) | ||||
|                                              | ||||
|                                             img_crop = rotate_image_with_padding(img_crop, better_des_slope ) | ||||
|  | @ -5484,7 +5483,7 @@ class Eynollah_ocr: | |||
|                                      | ||||
|                                      | ||||
|                                     if not self.export_textline_images_and_text: | ||||
|                                         if w_scaled < 530:#640:#1.5*image_width: | ||||
|                                         if w_scaled < 640:#1.5*image_width: | ||||
|                                             img_fin = preprocess_and_resize_image_for_ocrcnn_model(img_crop, image_height, image_width) | ||||
|                                             cropped_lines.append(img_fin) | ||||
|                                             if angle_degrees > 15: | ||||
|  |  | |||
|  | @ -41,11 +41,13 @@ class Enhancer: | |||
|         dir_out : Optional[str] = None, | ||||
|         num_col_upper : Optional[int] = None, | ||||
|         num_col_lower : Optional[int] = None, | ||||
|         save_org_scale : bool = False, | ||||
|         logger : Optional[Logger] = None, | ||||
|     ): | ||||
|         self.dir_out = dir_out | ||||
|         self.input_binary = False | ||||
|         self.light_version = False | ||||
|         self.save_org_scale = save_org_scale | ||||
|         if num_col_upper: | ||||
|             self.num_col_upper = int(num_col_upper) | ||||
|         else: | ||||
|  | @ -750,7 +752,8 @@ class Enhancer: | |||
|                     continue | ||||
| 
 | ||||
|             image_enhanced = self.run_single() | ||||
|             img_enhanced_org_scale = resize_image(image_enhanced, self.h_org, self.w_org) | ||||
|             if self.save_org_scale: | ||||
|                 image_enhanced = resize_image(image_enhanced, self.h_org, self.w_org) | ||||
|              | ||||
|             cv2.imwrite(self.output_filename, img_enhanced_org_scale) | ||||
|             cv2.imwrite(self.output_filename, image_enhanced) | ||||
|              | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue