Table picture OCR (Optical Character Recognition) method and tool by utilizing Excel template
By parsing the printing information in the Excel template and removing the printed areas from the image, the problem of printing information interference in traditional OCR technology is solved, achieving high efficiency and accuracy in table recognition.
Patent Information
- Application Number
- CN202511651210.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2026-02-10
AI Technical Summary
Traditional OCR technology suffers from low recognition accuracy when recognizing tables due to interference from printed information such as headers, footers, and table lines. Existing methods have not been able to completely eliminate the impact of this interference.
By parsing the printing information in the Excel template, the printing information area in the image is located and removed. After image preprocessing, OCR recognition is performed to retain the main table area.
It improves the accuracy and efficiency of OCR recognition, ensuring accurate extraction of table structures and text data.
Smart Images

Figure CN121505625A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of OCR (Optical Character Recognition) technology, specifically a method and tool for OCR recognition of table images using Excel templates. It aims to improve the accuracy of character recognition in table images, especially by removing interference from printed information, thereby improving recognition efficiency and accuracy. Background Technology
[0002] With the advancement of informatization, the demand for digitized processing of tabular data is increasing. When traditional OCR technology is used for table recognition, the recognition accuracy is low due to interference from printed information such as headers, footers, and table lines in the image. To improve OCR recognition performance, many technologies (such as prior patents CN202510489692.9 and CN202510482620.1) employ complex image processing and table structure analysis methods, but they still fail to completely eliminate the influence of printed information on the recognition results. Summary of the Invention
[0003] To address the deficiencies and shortcomings mentioned in the prior art, this invention provides a method and tool for OCR recognition of table images using Excel templates. This method involves pre-processing the image before OCR recognition by parsing the printing information (such as headers, footers, and page numbers) in the Excel template and removing the printing information area, thereby improving the accuracy and efficiency of OCR recognition.
[0004] The technical solution of the present invention is as follows: A method for OCR recognition of table images using Excel templates, characterized by comprising the following steps: S1. Obtain the target Excel template file and parse its printing information, including header, footer, page number, and margins; S2. Compare the layout of the printed image exported from the Excel file with the image to be recognized to determine the position of the printed information in the image. S3. Preprocess the image to be recognized, delete the printed information area, and retain the main table area; S4. Perform OCR recognition on the preprocessed image to extract the table structure and text content.
[0005] Preferably, the identification of printed information includes font feature matching, position alignment calculation, and region difference analysis.
[0006] Preferably, the image preprocessing step further includes image rotation, denoising, binarization, and edge enhancement operations.
[0007] Preferably, the image preprocessing step further includes table structure recognition: using the row and column identifiers in the template to identify table cells and determine the table structure.
[0008] Preferably, the output of the OCR recognition is structured tabular data, which can be exported as JSON or Excel format.
[0009] Preferably, the recognition method is as follows: after preprocessing the input Excel template and the original scanned image, the table data is extracted using the template information, OCR recognition is completed, and the final result is output; flowchart TB A [Input: Excel template] --> B [Parse Excel template] B --> C {Does it contain print information?} C --> | Yes | D [Identify and locate the printed information area] C --> | No | E [Skip print information processing] D --> F [Remove print information area] E -->F F --> G [Image preprocessing: denoising, rotation] G --> H [Table structure recognition: locating table cells] H --> I [OCR Recognition] I --> J [Extract text data] J --> K [Output as Excel file] A --> K.
[0010] This tool utilizes an Excel template for OCR recognition of table images. The process involves first uploading a scanned image / PDF (if the file is PDF, it will be converted to an image); then selecting the table image to be recognized and uploading / selecting the corresponding Excel template; the default OCR parameters are: cell recognition mode, 0.5 OCR confidence threshold, and rotation correction; the image is first enhanced and rotated, and then the table area is detected; cell detection is performed based on the Excel template; OCR recognition is performed on each cell; finally, the results are filled into the Excel template.
[0011] By adopting the above technical solution, the present invention has the following beneficial effects compared with the prior art: 1. Parse the print information in the Excel template, identify and locate the position of this information in the image; 2. Remove the printed information area, keeping only the main table area, to avoid the printed information interfering with OCR recognition; 3. Improve OCR recognition accuracy by recognizing structured tables and accurately extracting text data. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention, the present invention will be further described below with reference to the accompanying drawings. The accompanying drawings are used to schematically illustrate the basic structure and process of the present invention and do not constitute any limitation on the present invention: Figure 1 This is a flowchart of an OCR recognition method for table images using an Excel template, according to one embodiment of the present invention. Figure 2-13 This is a flowchart illustrating the operation of the Excel template-based OCR recognition tool for table images in this invention. Detailed Implementation
[0013] The embodiments of the present invention are described in detail below: These embodiments are implemented based on the technical solution of the present invention, and provide detailed implementation methods and specific operation processes. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.
[0014] Example 1 Figure 1 As shown, a method for OCR recognition of table images using an Excel template is described, and the specific implementation steps are as follows: 1. Obtain the Excel template and parse the print information: First, obtain the target Excel file and its print template, and parse out the print information (such as headers, footers, page numbers, etc.). This information is obtained by analyzing the layout, margins, and other formatting features in the Excel template to ensure accurate location of the print information area.
[0015] 2. Image Preprocessing: The scanned image undergoes rotation, noise reduction, and other preprocessing operations to ensure image quality. Printing information areas are located and removed using template information.
[0016] 3. Table structure recognition: Using the row and column markers in the template, identify table cells and determine the table structure.
[0017] 4. OCR Recognition: Perform OCR recognition on the preprocessed image to extract text information from the table.
[0018] 5. Output Results: Output the text data recognized by OCR as a structured Excel file or JSON format for easy subsequent processing and analysis.
[0019] Example 2: A method for OCR recognition of table images using an Excel template. After preprocessing the input Excel template and the original scanned image, the table data is extracted using the template information, OCR recognition is completed, and the final result is output.
[0020] flowchart TB A [Input: Excel template] --> B [Parse Excel template] B --> C {Does it contain print information?} C --> | Yes | D [Identify and locate the printed information area] C --> | No | E [Skip print information processing] D --> F [Remove print information area] E -->F F --> G [Image preprocessing: denoising, rotation] G --> H [Table structure recognition: locating table cells] H --> I [OCR Recognition] I --> J [Extract text data] J --> K [Output as Excel file] A --> K.
[0021] Example 3: A table image OCR recognition method using Excel templates, which can be further optimized and expanded to adapt to more application scenarios: Supports multiple templates: Using deep learning and other technologies, it can recognize many different types of Excel templates.
[0022] Error correction function: Post-processes the OCR recognition results to automatically correct recognition errors and ensure high-quality recognition results.
[0023] Batch processing: For a large number of table images, partitioned parallel processing technology can be used to improve processing speed.
[0024] Example 4 An OCR recognition tool for tables using Excel templates, the operation process is as follows: 1. Image upload (e.g., ... Figure 2-5 As shown), 2. Configuration Management (such as...) Figure 6 and 7 As shown), 3. Image processing (such as...) Figure 8 and 9 (As shown), 4. Download results (as shown) Figure 10 5. Correction tools (as shown) Figure 11-13 (As shown).
[0025] Example 5: A table image OCR recognition tool using an Excel template. When using this tool, the scanned image / PDF is uploaded first. If the file type is PDF, it will be converted into an image first. PDF processing technical parameters Resolution: 288 DPI (4x scaling) Color space: RGB Output format: PNG Compression level: 6 (Optimize file size) Transparency channel: Disabled (to improve performance); After selecting the table image you want to recognize, upload / select the corresponding Excel template; Default OCR recognition parameters: cell recognition mode, 0.5 OCR confidence threshold, rotation correction function. First, the image is enhanced and rotated, and then the table area is detected (as shown in Figure 1). Image processing configuration IMAGE_CONFIG = { 'enable_preprocessing': True, # Whether to enable image preprocessing 'enable_enhancement': True, # Whether to enable image enhancement 'enable_rotation': True, # Whether to enable rotation correction 'blur_kernel_size': 3, # Size of the noise reduction kernel 'morphology_kernel_size': (1, 1), # Size of the morphology kernel 'clahe_clip_limit': 4.0, # CLAHE contrast limit 'clahe_tile_grid_size': (8, 8), # CLAHE grid size 'adaptive_thresh_block_size': 15, # Adaptive threshold neighborhood size 'adaptive_thresh_C': 8, # Adaptive threshold constant 'gaussian_blur_kernel': (3, 3), # Gaussian blur kernel size 'morphology_iterations': 1, # Number of iterations for morphological operations 'noise_removal_strength': 10, # Noise reduction strength 'max_image_size': 1200, # Maximum image size for preprocessing } Table detection parameters TABLE_DETECTION_CONFIG = { 'min_table_area_ratio': 0.1, # Minimum table area ratio 'max_table_area_ratio': 0.9, # Maximum table area ratio 'aspect_ratio_range': (0.5, 5.0), # Table aspect ratio range 'corner_detection_method': 'improved', # Corner detection method 'corner_detection_threshold': 0.8, # Corner detection threshold 'contour_approximation_epsilon': 0.02, # Contour Approximation Accuracy 'min_contour_area': 1000, # Minimum outline area 'max_contour_area': 500000, # Maximum outline area } Perspective transformation parameters PERSPECTIVE_TRANSFORM_CONFIG = { 'interpolation_method': 'linear', # Interpolation method 'border_mode': 'constant', # Boundary Mode 'border_value': 255, # Boundary padding value 'auto_size_calculation': True, # Automatically calculate target size 'size_calculation_method':'max', # Size Calculation Method 'corner_order_method': 'clockwise', # Corner sorting method 'transform_matrix_precision': 'double', # Transformation matrix precision }
[0026] Table 1 Cell detection based on Excel templates (as shown in Table 2):
[0027] Table 2 Perform OCR recognition on each cell: OCR Configuration OCR_CONFIG = { 'languages': ['ch_sim', 'en'], # Supported languages 'confidence_threshold': 0.6, # Confidence threshold 'use_gpu': True, # Whether to use the GPU 'use_angle_cls': True, # Whether to use text direction classification 'det_limit_side_len': 960, # Detect side length limit 'det_limit_type': 'max', # Limit type 'rec_batch_num': 6, # Identify batch size 'max_text_length': 25, # Maximum text length 'drop_score': 0.5, # Threshold for dropping scores 'use_space_char': True, # Whether to use the space character 'use_mp': False, # Whether to use multiprocessing 'total_process_num': 1, # Total number of processes } The results are then filled into the template Excel (as shown in Tables 3 and 4). EXCEL_CONFIG = { 'output_directory': 'output', # Output directory 'create_comparison_sheet': True, # Whether to create a comparison worksheet 'highlight_filled_cells': True, # Whether to highlight filled cells 'preserve_formatting': True, # Whether to preserve the original format 'auto_adjust_column_width': False, # Whether to automatically adjust column width 'default_font_size': 11, # Default font size 'default_font_name': 'SimSun', # Default font name 'fill_color': 'FFFF00', # Fill the cell with yellow color. 'confidence_color_coding': True, # Confidence color coding 'low_confidence_color': 'FFB6C1', # Low confidence color (light pink) 'high_confidence_color': '98FB98', # High confidence color (light green) 'confidence_threshold_low': 0.5, # Low confidence threshold 'confidence_threshold_high': 0.8, # High confidence threshold }
[0028] Table 3
[0029] Table 4
[0030] The specific embodiments of the present invention have been described in detail above. It should be understood that the described embodiments are merely one of the preferred embodiments of the present invention and do not constitute a limitation on the scope of protection of the present invention. Those skilled in the art can make various modifications, substitutions, or variations within the scope defined by the claims without departing from the essence of the present invention, and all such modifications, substitutions, or variations should be included within the scope of protection of the present invention.
Claims
1. A method for OCR recognition of table images using Excel templates, characterized in that, Includes the following steps: S1. Obtain the target Excel template file and parse its printing information, including header, footer, page number, and margins; S2. Compare the layout of the printed image exported from the Excel file with the image to be recognized to determine the position of the printed information in the image. S3. Preprocess the image to be recognized, delete the printed information area, and retain the main table area; S4. Perform OCR recognition on the preprocessed image to extract the table structure and text content.
2. The OCR recognition method for table images using Excel templates according to claim 1, characterized in that, The identification of printed information includes font feature matching, position alignment calculation, and region difference analysis.
3. The OCR recognition method for table images using Excel templates according to claim 1, characterized in that, The image preprocessing steps also include image rotation, denoising, binarization, and edge enhancement operations.
4. The OCR recognition method for table images using Excel templates according to claim 1, characterized in that, The image preprocessing steps also include table structure recognition: using the row and column identifiers in the template to identify table cells and determine the table structure.
5. The OCR recognition method for table images using Excel templates according to claim 1, characterized in that, The OCR output is structured tabular data, which can be exported as JSON or Excel format.
6. The OCR recognition method for table images using an Excel template according to claim 1, characterized in that, The recognition method is as follows: After preprocessing the input Excel template and the original scanned image, the table data is extracted using the template information, OCR recognition is completed, and the final result is output. flowchart TB A [Input: Excel template] --> B [Parse Excel template] B --> C {Does it contain print information?} C --> | Yes | D [Identify and locate the printed information area] C --> | No | E [Skip print information processing] D --> F [Remove print information area] E --> F F --> G [Image preprocessing: denoising, rotation] G --> H [Table structure recognition: locating table cells] H --> I [OCR Recognition] I --> J [Extract text data] J --> K [Output as Excel file] A --> K.
7. A table image OCR recognition tool using an Excel template as described in claim 1, characterized in that, When using this tool, first upload the scanned image / PDF. If the file type is PDF, it will be converted into an image first. After selecting the table image to be recognized, upload / select the corresponding Excel template; the default OCR recognition parameters are: cell recognition mode, 0.5 OCR confidence threshold, and rotation correction function; first, the image is enhanced and rotated, and then the table area is detected; cell detection is based on the Excel template; OCR recognition is performed on each cell; then the results are filled into the template Excel.
Citation Information
Patent Citations
OCR (Optical Character Recognition) model training method and OCR method
CN120318835A
An OCR recognition method based on adaptive mapping and perceptual adjustment
CN120340050B
Method and system for recognizing format template
CN102081732A
Text recognition method and device
CN113780229A
Unstructured text table recognition method and system
CN115424282A
