OCR (optical character recognition) method and system for high-precision table data structuring
By combining edge detection and Hough transform with ViT and DETR models, an OCR recognition method was developed to solve the problems of misidentification and format misalignment in high-precision tabular data, and to achieve high-precision data extraction in scenarios such as high-density numerical data, formatted financial data, and precise timestamps.
Patent Information
- Application Number
- CN202511014010.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-23
- Publication Date
- 2025-11-18
AI Technical Summary
Existing OCR recognition methods suffer from misidentification, loss of accuracy, and format misalignment issues in high-precision data processing, especially in scenarios involving high-density numerical data, formatted financial data, and precise timestamp data, which cannot guarantee data accuracy and alignment consistency.
A high-precision OCR recognition method for structuring tabular data is adopted. The table edge structure lines are extracted through edge detection and Hough transform. The broken parts are filled by erosion and dilation operations, and the cell regions are divided. The ViT and DETR models are used for end-to-end detection of characters and symbols, dynamically generating table structure templates and optimizing data alignment and format verification.
It improves the accuracy of symbol recognition and data alignment consistency, ensuring the reliability and accuracy of high-precision data, and is suitable for complex data scenarios such as high-density numerical data, formatted financial data, and precise timestamps.
Smart Images

Figure CN120976948A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of optical character recognition, and in particular to an OCR recognition method and system for high-precision table data structuring. BACKGROUND
[0002] In the context of big data analysis and automated information processing, accurate extraction and structured processing of table data are crucial in finance, statistics, healthcare, and other fields, not only affecting decision-making accuracy but also related to compliance and data security. However, existing OCR recognition methods still have problems such as misrecognition, precision loss, and format misalignment in high-precision data processing, affecting the reliability and usability of data.
[0003] Current OCR recognition methods mainly rely on general character detection and table parsing algorithms, but when dealing with high-precision numerical data (such as financial data, scientific calculation results) or precise formats (such as amounts, decimal points, timestamps), recognition errors often occur. OCR may misrecognize decimal points, exponential symbols, or miss negative signs, unit symbols, leading zeros, and other key information, affecting the actual meaning of the data.
[0004] Another problem is data alignment and structured mapping. The values in the table have strict field correspondence, and if cell offset, character sticking, or column misalignment occurs during OCR parsing, even if individual character recognition is accurate, the final extracted data cannot be relied upon.
[0005] In addition, the border and format information of the table also affects the accuracy of OCR. The OCR engine may misrecognize the border lines or separators as characters, or lose character strokes when removing the border, which is particularly serious in high-precision data processing.
[0006] Existing OCR recognition methods have significant limitations in high-precision data extraction, especially in high-density numerical data, formatted financial data, and precise timestamp data application scenarios. Traditional methods often cannot guarantee the accuracy and alignment consistency of data. Therefore, there is an urgent need for a high-precision table data structured extraction method that can consider high-precision data recognition, reduce OCR errors, and optimize data alignment relationships to ensure the accuracy and usability of data in automated processing. SUMMARY
[0007] In order to reduce the impact on data accuracy during table recognition and organize data in a structured form, the present application provides an OCR recognition method for high-precision table data structuring.
[0008] To solve the above technical problems, the present application adopts the following technical solutions: An OCR recognition method for high-precision table data structuring, comprising the following steps: Step 1: convert the original image into a grayscale image and pre-process to obtain a pre-processed image; Step 2: extract the table edge structure line in the pre-processed image by an edge detection algorithm, fill in the broken part of the table edge structure line by combining erosion and expansion operations; use Hough transform to detect the vertical and horizontal lines in the pre-processed image and calculate the intersection points to determine the table row and column structure; Step 3: divide the cell area based on the intersection point coordinates of the horizontal and vertical lines, locate each cell according to the top-left corner and bottom-right corner coordinates, and generate a cell coordinate matrix; Step 4: divide the pixels in the cell into a frame affected area and an effective data area, perform neighborhood mean filtering and weighted fusion operations on the frame affected area; perform end-to-end detection of characters and symbols on the effective data area, and output the OCR recognition results with coordinates; Step 5: based on the cell coordinate matrix and the OCR recognition results with coordinates, dynamically generate a table structure template, match the field type through a rule inference strategy, and process the missing data of the merged cell based on the adjacent cell information, and output the structured data.
[0009] Further, the pre-processing in step 1 includes non-local mean denoising, Gaussian blur background brightness generation, Gamma correction to enhance table lines, and NiBlack adaptive binarization processing, specifically: A non-local mean denoising algorithm is used to remove noise based on global pixel similarity while preserving table lines and text information; A Gaussian blur is used to generate a background brightness image, and normalization is used to balance the brightness; Based on the Gamma correction method, the low-contrast table lines are enhanced by power transformation; Based on the NiBlack adaptive binarization method, the threshold is dynamically adjusted according to the local contrast. Further, the step 2 includes: The Sobel operator is used to calculate the gradient values of the pre-processed image in the horizontal and vertical directions respectively, and the gradient amplitude and gradient direction of each pixel point are obtained; then, the non-maximum suppression algorithm is used, i.e. in the gradient direction of each pixel, the gradient amplitudes of its adjacent two pixels are compared, and only the pixel corresponding to the local maximum value is retained to obtain the edge image; The erosion operation is used to remove small noise in the edge image and reduce the foreground area; then, the dilation operation is used to fill in the gaps in the edge and connect the broken parts; The edge image is input into the Hough transform algorithm, the horizontal and vertical lines in the table are identified by parameterizing the straight lines in the accumulator space, the detected straight line parameters are integrated through coordinate processing, and the intersection points are identified; the table row and column structure is determined based on the intersection points.
[0010] Further, the step 4 of dividing the pixels in the cell into the border influence area and the effective data area includes: For all pixels inside the cell, calculate the distance from each pixel to the four border lines of the cell, and take the minimum value as the nearest distance from the pixel to the border; Calculate the mean and standard deviation of the minimum distances of all pixels, and set a division threshold; If the distance of a pixel to the border is less than the division threshold, it is divided into the border influence area; otherwise, it is considered as the effective data area.
[0011] Further, the step 4 of using the joint model of ViT and DETR for end-to-end detection of characters and symbols in the effective data area includes: Use ViT as a feature extraction network to divide the input image into fixed-size image blocks, and generate corresponding visual Tokens after linear transformation of each image block, and add position encoding information; All Tokens are sent to the Transformer encoder to form a globally aware image representation; The globally aware image representation is further input into the decoder module of the target detection network to obtain the bounding box coordinates of each target and its corresponding class label, and output the OCR recognition result with coordinates.
[0012] Further, the step 5 of dynamically generating a table structure template includes: (a) Column area construction: based on the horizontal coordinate range of the cell coordinate matrix, vertically aggregate to generate the column area boundary; (b) Field binding: extract the first row of OCR recognition results as the table header, and bind the table header text and the column area coordinates; (c) Data mapping: according to the position coordinates of the non-header cell, map its OCR content to the bound field of the corresponding column area.
[0013] Further, the data mapping in step 5 includes: When a cell spans multiple columns, according to the column area range it covers, the same OCR recognition content is copied to all associated fields.
[0014] Further, the rule inference strategy in step 5 includes: Date rule: match the date format based on keywords or regular expressions; Numerical rule: infer the field type based on unit symbols and numerical ranges; Text rule: calculate the cosine similarity between the text and the table header field using BERT semantic vector.
[0015] Further, the step 5 of processing the missing data of the merged cell based on the adjacent cell information comprises: Inherit attributes by field name keyword matching and column content repeatability analysis, and fill the latest valid cell content to the missing position.
[0016] On the other hand, the application provides an OCR recognition system for high-precision table data structuring, comprising: A preprocessing module is used to convert the original image into a grayscale image and obtain a pretreated image through preprocessing; A table row and column structure determination module is used to extract the table edge structure line in the pretreated image through an edge detection algorithm, fill the broken part of the table edge structure line by combining the corrosion and expansion operation, detect the vertical and horizontal lines in the pretreated image by using the Hough transform, calculate the intersection points, and determine the table row and column structure; A coordinate matrix generation module is used to divide the cell area based on the intersection point coordinates of the horizontal and vertical lines, locate each cell according to the upper left corner and lower right corner coordinates, and generate a cell coordinate matrix; An OCR recognition module is used to divide the pixels in the cell into a frame influence area and an effective data area, perform neighborhood mean filtering and weighted fusion operation on the frame influence area, perform end-to-end detection of characters and symbols on the effective data area, and output the OCR recognition result with coordinates; A result output module is used to dynamically generate a table structure template based on the cell coordinate matrix and the OCR recognition result with coordinates, match the field type by a rule inference strategy, process the missing data of the merged cell based on the adjacent cell information, and output the structured data.
[0017] Compared with the prior art, the application has the following beneficial effects: The application optimizes the image processing process, combines target detection with OCR technology in the recognition stage, effectively improves the accuracy of symbol recognition, ensures that the positioning and recognition of symbols are more accurate when processing high-precision data, optimizes the accuracy of character recognition and format checking by introducing a multi-task learning framework, solves the problem of numerical format and symbol accuracy, and innovatively adopts a dynamic table structure template generation strategy to accurately map the OCR recognition result and the table structure, ensuring data alignment consistency. Combined with the rule-based inference strategy, the accuracy of field type inference is further improved. This method greatly improves the reliability and accuracy of OCR technology in complex data scenarios such as high-density numerical data, formatted financial data and accurate time stamps, and meets the demand for high-precision data extraction in automatic information processing. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to make the technical solutions in the present application or the prior art clearer, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative effort on the basis of these drawings.
[0019] Figure 1 is a flowchart of an embodiment of the present application.
[0020] Figure 2 is a flowchart of a preprocessing stage of an embodiment of the present application.
[0021] Figure 3 is a flowchart of an extraction of a frame line stage of an embodiment of the present application.
[0022] Figure 4 is a loss function design diagram of an embodiment of the present application for model optimization of OCR recognition.
[0023] Figure 5 is a matching rule defined when structured sorting of an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below in conjunction with the drawings. In the following description, a large number of specific details are set forth in order to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without departing from the spirit of the present application, so the present application is not limited by the specific embodiments disclosed below. Embodiment 1 The embodiments of the present application use the following open source software and technical tools: OpenCV library for computer vision technology to process images ( https: / / opencv.org / ), optical character recognition (OCR engine Tesseract OCR ( https: / / github.com / tesseract-ocr / tesseract ), BERT model ( https: / / github.com / google- research / bert ) In the process of cell OCR recognition, the present application uses a computer vision Vision Transformer model ( https: / / github.com / google-research / vision_transformer ) to optimize recognition. The training data set covers synthetic and various real scene data, including SynthText ( https: / / www.robots.ox.ac.uk / ~vgg / data / scenetext / ), ICDAR ( https: / / tc11.cvc.uab.es / ) and the like, to ensure that the model is adapted to various formatted data. The target detection task uses DETR ( https: / / github.com / facebookresearch / detr ).
[0025] See Figure 1 The present application comprises the following steps: Step 1: See Figure 2 The main task of this step is to make the table border more clear through accurate preprocessing, while ensuring the integrity of the text information, so as to provide high-quality input for subsequent border extraction and OCR recognition.
[0026] Firstly, the original image is converted to a grayscale image to reduce computational complexity and eliminate color information interference in the processing process. Next, in order to remove noise in the image without blurring table lines and text, the present application adopts a non-local mean denoising algorithm. This algorithm removes noise by analyzing the similarity of pixels in the entire image, rather than relying solely on local pixels. For each pixel, the algorithm searches for similar pixel blocks within a certain range and calculates a weighted average, where the similarity is determined by a Gaussian weight function, and the higher the similarity, the greater the contribution to the denoising result. In this way, the noise in the image is effectively smoothed, while the structured information such as table lines and text is preserved, avoiding the blurring phenomenon that may be caused by traditional filtering methods.
[0027] After denoising processing is completed, the image may still have uneven brightness problems caused by shooting angles or light changes. In order to ensure the uniformity of the contrast of the entire table area and make the border lines clearer, the present application performs brightness equalization processing on the image. Specifically, a smooth background brightness map is generated using Gaussian blur, and then the pixel values are adjusted through normalization method to maintain a relatively balanced brightness distribution. This process can effectively eliminate the interference of shadow or highlight areas on subsequent recognition, thereby significantly improving the visibility of table structure.
[0028] To further enhance the table lines, the present application uses Gamma correction method for non-linear contrast adjustment. Gamma correction adjusts the contrast of different brightness areas by performing power transformation on pixel values, so that low-contrast areas are enhanced, while high-light areas are not overexposed. Compared with traditional histogram equalization methods, Gamma correction provides a more gentle and controllable adjustment effect, which can effectively prevent character edge breakage or blurring while improving contrast, thereby enhancing the clarity of table lines and maintaining the integrity of the text part.
[0029] Finally, the image is binarized using the NiBlack adaptive binarization method. NiBlack method dynamically adjusts the contrast of local regions to make the table lines more prominent while maintaining the clarity of the text information. This method is particularly suitable for processing tables containing large amounts of data, as it can find the best balance between high-density text areas and table borders, ensuring that the structural information of the table is clearly presented without affecting the readability of the text.
[0030] Through this series of processing, the table border is significantly enhanced, while the text information remains complete, providing a stable and reliable foundation for the subsequent recognition process.
[0031] Step 2: Please refer to Figure 3 This step aims to process the image after the previous preprocessing to extract clear table borders.
[0032] In the border extraction stage, the present invention uses the Canny edge detection algorithm to accurately extract the table structure lines in the image. This algorithm first calculates the gradient values of the image in the horizontal and vertical directions through the Sobel operator, and obtains the gradient amplitude and gradient direction of each pixel point based on this. Subsequently, the non-maximum suppression algorithm is used, that is, in the gradient direction of each pixel, the gradient amplitudes of its adjacent two pixels are compared, and only the pixel corresponding to the local maximum value is retained, and non-edge or blurred edge is suppressed, so as to accurately extract fine and narrow continuous edge lines.
[0033] Next, the present invention further processes the edge image through erosion and dilation operations to enhance the coherence of the border. First, the erosion operation is used to remove small noise in the edge image and reduce the foreground area; then, the dilation operation is used to fill the gaps in the edge and connect the broken parts. After this processing, the final image shows a more coherent table border.
[0034] In order to accurately extract the table border, the present invention uses the Hough transform method to accurately identify the vertical and horizontal border lines in the table, and then clearly identifies the row and column structure of the table. Hough transform converts straight lines in image space to polar coordinate space, and uses the straight line representation method of polar coordinates to detect straight lines in the image. Specifically, the edge image is input into the Hough transform algorithm, and the most significant straight lines, especially the horizontal and vertical lines in the table, are identified through the parameterization of straight lines in the accumulator space. Then, through the coordinate processing, the detected straight line parameters are integrated to identify the intersection points. The intersection point of each horizontal line and vertical line is the boundary of the table cell, and based on these intersection points, the position of each cell can be accurately determined, so as to ensure that the subsequent data extraction process can be carried out in the correct area.
[0035] Step 3: After the foregoing steps, the border lines of the table are clearly presented, with obvious horizontal and vertical line structures, from which the coordinates of all horizontal and vertical lines can be extracted.
[0036] The present application determines the distribution of cells in the table based on these line information. In this step, the present application first sorts and groups all horizontal and vertical lines according to their horizontal and vertical coordinates, respectively, and further divides the area of the cells based on this.
[0037] After sorting the horizontal and vertical lines, the next task is to extract the specific location of each cell. The location of a cell is determined by the intersection of horizontal and vertical lines, which is the four corners of the cell. Specifically, for each group of horizontal and vertical lines, the intersection of them can obtain the coordinates of the top-left corner and the bottom-right corner of the cell. These coordinates form a rectangular frame, representing the location of a cell. Through this method, the present application can accurately locate each cell in the table.
[0038] Step 4: In step 2, the present application extracts the outer border and internal horizontal and vertical dividing lines of the table in the image through Canny edge detection and Hough transform, constructing a line frame of the table structure. According to the intersection position of these border lines, the entire image can be divided into several regular cell areas. However, the border lines may interfere with the extraction of the table content, especially the content near the edge is easily affected by the border pixels. Therefore, the present application further performs division of "border influence area" and "effective data area" inside each cell.
[0039] The specific division method is as follows: for all pixel points inside the cell, calculate their distance to the four border lines of the cell one by one, and take the minimum value as the nearest distance of the pixel to the border. Then, calculate the mean and standard deviation of all pixel points, and set the division threshold to "mean plus 0.5 times of standard deviation". If the distance of a pixel to the border is less than the threshold, it is classified into "border influence area"; otherwise, it is considered as "effective data area".
[0040] For the "border influence area", the present application adopts a multiple smoothing strategy combining neighborhood mean filtering, median filtering and bilateral filtering to reduce the strength of the border line and preserve the edge details. The image gradient information is combined during processing to avoid blurring the character outline. After blurring, a weighted fusion method is used to naturally blend the border influence area image with the original image, ensuring no obvious stitching marks. This method effectively eliminates the border interference while maximizing the integrity of the data inside the cell.
[0041] The application performs OCR recognition on the "effective data area" region, constructs an optimized model based on a Vision Transformer (ViT) combined with a DETR target detection network, focuses on high-precision recognition of numbers, symbols and special format content, and improves the recognition accuracy and robustness of table content.
[0042] In a specific implementation, the application first uses ViT as a feature extraction network, divides the input image into fixed-size image blocks (patches), generates corresponding visual Tokens after linear transformation of each patch, and adds position encoding information. All Tokens are sent to the Transformer encoder to form a globally aware image representation. In order to realize the positioning and recognition of key symbols (such as decimal points, operators, parentheses, etc.) in the image, the feature representation is further input into the decoder module of the DETR (DEtection TRansformer) target detection network. In this way, the model can directly output the bounding box coordinates and corresponding class labels of each target, such as "decimal point", "multiplication sign", "parentheses", etc.
[0043] Through the above target detection module, the application can preliminarily obtain the bounding box position and class label of the characters in the image. However, in order to further improve the recognition accuracy and enhance the adaptation ability to the table format, please refer to Figure 4 , the application further introduces a multi-task learning mechanism to jointly optimize the output results for character recognition and format consistency. Specifically, the model loss function consists of two parts: one is the cross-entropy loss function, which is used to minimize the class label prediction error, thereby improving the character recognition accuracy; the other is the L1 loss function, which is used to measure the distance between the predicted bounding box and the true labeled box, in order to enhance the fitting ability of the symbol position and ensure the consistency of the format. In the training stage, the fine-tuning strategy is adopted to update the gradient of the ViT backbone network, so that the model can make more targeted adjustments for the specific task constructed by the application based on the existing pre-training ability.
[0044] Step 5: After completing the OCR recognition, the extracted data needs to be arranged to conform to the format of structured data. To achieve this goal, the application dynamically generates a table structure template in combination with the column items in the table, which is used to map the OCR recognition results to specific column items. Specifically, the known cell layout information is used to analyze the boundary position of each cell in a column (or row), and a column region structure is constructed. Each region is considered as the position of a field, and its column index and coordinate range are recorded. The column titles (field names) are extracted from the top few rows of the table, and a mapping relationship is established between the column titles and the column regions according to their positions in the cells.
[0045] In matching the OCR recognition result, the cell position information is mapped to the table structure template. To improve the accuracy of matching, the present application adopts a column order-based and rule-based speculation strategy. Referring to Figure 5 The present application defines a set of rule-based speculation strategies as follows: 1. Date rule: The present application uses keywords or regular expressions to match common date formats. If the contents of a column mostly conform to these formats, the present application will classify the column as a date field.
[0046] 2. Numerical rule: The present application analyzes and speculates numerical fields based on unit characteristics and numerical ranges, such as classifying large numerical values that may contain decimals or currency symbols as amount fields.
[0047] 3. Text rule: The text rule identifies character field categories through context analysis. The present application first preprocesses the OCR results, including removing special characters, standardizing case, and performing word segmentation. Then, it uses BERT to generate semantic vectors and calculates the matching degree of the text and the table header field categories through cosine similarity, thereby accurately classifying the fields. In the data arrangement process, the problem of merged cells needs to be handled. Since OCR recognition may not accurately segment the contents of merged cells, the present application uses the field mapping relationship in the table structure template and combines the information of adjacent cells to fill in. Specifically, the present application realizes content inheritance and filling by judging whether a column has an inheritance attribute. First, based on the matching of field names and predefined keywords (such as "date", "time", "period", etc.), it preliminarily judges whether the field has an inheritance attribute. Then, it analyzes the repetitiveness of the column field content. If a large number of continuous repeated values are found and the corresponding cells lack explicit content, it usually indicates that there is a merged cell, supporting value inheritance. Finally, combined with the column area information recorded in the dynamic table structure template, it analyzes the position continuity and coverage range of the cells in the column to assist in judging whether there is a merged cell. Based on the above judgment, the system fills the missing cells with the latest valid content of the field, ensuring that the merged cell information is completely recovered, thereby ensuring the accuracy and integrity of the entire table data.
[0048] Finally, the arranged data can be stored in various structured formats, and if it needs to be output in other formats (such as CSV, JSON), it can also be easily converted.
[0049] Embodiment 2 The present embodiment provides an OCR recognition system for high-precision table data structuring, which includes: The preprocessing module is used for converting an original image into a gray image and pre-processing to obtain a pre-processed image. The table row and column structure determination module is used for extracting table edge structure lines in the pre-processed image through an edge detection algorithm, filling in broken parts of the table edge structure lines by combining a corrosion expansion operation, detecting vertical and horizontal lines in the pre-processed image by using a Hough transform and calculating intersection points, and determining a table row and column structure. The coordinate matrix generation module is used for dividing a cell region based on intersection point coordinates of horizontal and vertical lines, positioning each cell according to left top corner and right bottom corner coordinates, and generating a cell coordinate matrix. The OCR recognition module is used for dividing pixels in a cell into a frame influence area and an effective data area, performing a neighborhood mean filtering and weighted fusion operation on the frame influence area, performing end-to-end detection of characters and symbols on the effective data area, and outputting an OCR recognition result with coordinates. The result output module is used for dynamically generating a table structure template based on the cell coordinate matrix and the OCR recognition result with coordinates, matching a field type through a rule inference strategy, processing missing data of a merged cell based on adjacent cell information, and outputting structured data.
[0050] The above description is merely preferred specific embodiments of the present application, and the protection scope of the present application is not limited thereto. Any changes or replacements within the technical scope disclosed by the present application can be easily thought of by those skilled in the art, and should be covered within the protection scope of the present application.
[0051] It should be understood that parts not described in detail in the specification are all prior art.
[0052] It should be understood that the above description of the preferred embodiments is relatively detailed, and should not be considered as limiting the protection scope of the present application. Those skilled in the art can make substitutions or modifications without departing from the scope of the present application, and all such substitutions or modifications should be covered within the protection scope of the present application. The protection scope of the present application should be subject to the appended claims.
Claims
1. A high-precision OCR recognition method for structuring tabular data, characterized in that, Includes the following steps: Step 1: Convert the original image to a grayscale image and perform preprocessing to obtain a preprocessed image; Step 2: Extract the table edge structure lines in the preprocessed image using an edge detection algorithm, and fill the broken parts of the table edge structure lines using erosion and dilation operations; The Hough transform is used to detect vertical and horizontal lines in the preprocessed image and calculate their intersections to determine the row and column structure of the table. Step 3: Divide the cell area based on the coordinates of the intersection of the horizontal and vertical lines, locate each cell according to the coordinates of the top left and bottom right corners, and generate a cell coordinate matrix; Step 4: Divide the pixels within the cell into the border-affected area and the effective data area. Perform neighborhood mean filtering and weighted fusion operations on the border-affected area. Perform end-to-end detection of characters and symbols on the effective data area and output the OCR recognition results with coordinates. Step 5: Based on the cell coordinate matrix and the OCR recognition results with coordinates, dynamically generate a table structure template, use rule-based inference strategies to match field types, process and merge missing cell data based on adjacent cell information, and output structured data.
2. The OCR recognition method for high-precision tabular data structuring according to claim 1, characterized in that, The preprocessing in step 1 includes nonlocal mean denoising, Gaussian blur background brightness generation, Gamma correction to enhance table lines, and NiBlack adaptive binarization, specifically: A nonlocal mean denoising algorithm is used to remove noise based on global pixel similarity, while preserving table lines and text information. A background brightness map is generated using Gaussian blur, and brightness is balanced by normalization. The low-contrast table lines are enhanced by power transformation based on the Gamma correction method; The NiBlack adaptive binarization method dynamically adjusts the threshold based on local contrast.
3. The high-precision OCR recognition method for structuring tabular data according to claim 1, characterized in that, Step 2 includes: The gradient values in the horizontal and vertical directions of the preprocessed image are calculated by the Sobel operator to obtain the gradient magnitude and gradient direction of each pixel. Then, the non-maximum suppression algorithm is used, that is, the gradient magnitude of each pixel is compared with the gradient magnitude of its two neighboring pixels in the gradient direction, and only the pixel corresponding to the local maximum value is retained to obtain the edge image. The erosion operation removes fine noise from the edge image and shrinks the foreground area; then, the dilation operation fills the gaps in the edges and connects the broken parts. The edge image is fed into the Hough transform algorithm, and the horizontal and vertical lines in the table are identified by parameterizing the lines in the accumulator space. The detected line parameters are integrated through coordinate processing to identify the intersection points. The row and column structure of the table is determined based on the intersection points.
4. The high-precision OCR recognition method for structuring tabular data according to claim 1, characterized in that, Step 4, which divides the pixels within a cell into the border-affected area and the valid data area, includes: For each pixel within a cell, calculate its distance to the four border lines of that cell, and take the minimum value as the closest distance from that pixel to the border. Calculate the minimum distance of all pixels, their mean and standard deviation, and set a segmentation threshold; If the distance from a pixel to the border is less than the defined threshold, it is included in the border's influence area; otherwise, it is considered a valid data area.
5. The OCR recognition method for high-precision tabular data structuring according to claim 1, characterized in that, Step 4 involves using a ViT and DETR joint model to perform end-to-end detection of characters and symbols in the valid data area; including: Using ViT as the feature extraction network, the input image is divided into fixed-size image blocks. Each image block is linearly transformed to generate a corresponding visual token, and positional encoding information is added. All tokens are fed into the Transformer encoder to form a globally perceived image representation; The globally perceived image representation is further input into the decoder module of the target detection network to obtain the bounding box coordinates of each target and its corresponding category label, and output the OCR recognition result with coordinates.
6. The OCR recognition method for high-precision tabular data structuring according to claim 1, characterized in that, The dynamic generation of the table structure template in step 5 includes: (a) Column region construction: Based on the horizontal coordinate range of the cell coordinate matrix, vertical aggregation is used to generate column region boundaries; (b) Field binding: Extract the first row of OCR recognition results as the table header, and bind the header text to the column area coordinates; (c) Data mapping: Based on the position coordinates of non-header cells, map their OCR content to the bound fields of their respective column range.
7. The high-precision OCR recognition method for structuring tabular data according to claim 6, characterized in that, The data mapping in step 5 includes: When a cell spans multiple columns, the same OCR-recognized content is copied to all associated fields based on the range of column areas it covers.
8. The high-precision OCR recognition method for structuring tabular data according to claim 1, characterized in that, The rule inference strategy in step 5 includes: Date rules: Match date formats based on keywords or regular expressions; Numerical rules: Infer field type based on unit symbol and numerical range; Text rules: Calculate the cosine similarity between the text and the header field using BERT semantic vectors.
9. The OCR recognition method for high-precision tabular data structuring according to claim 1, characterized in that, Step 5, which involves processing missing data in merged cells based on adjacent cell information, includes: Inherited attributes are determined by keyword matching of field names and analysis of column content repetition, and the content of the most recent valid cell is filled into the missing position.
10. A high-precision OCR recognition system for structuring tabular data, characterized in that, Include: Preprocessing module: It is used to convert the original image into a grayscale image and perform preprocessing to obtain a preprocessed image; Table row and column structure determination module: It is used to extract the table edge structure lines in the preprocessed image through edge detection algorithm, and fill the broken parts of the table edge structure lines by combining erosion and dilation operations; The Hough transform is used to detect vertical and horizontal lines in the preprocessed image and calculate their intersections to determine the row and column structure of the table. Coordinate matrix generation module: It is used to divide the cell area based on the coordinates of the intersection of horizontal and vertical lines, locate each cell according to the coordinates of the top left and bottom right corners, and generate a cell coordinate matrix; OCR recognition module: When enabled, it divides the pixels within a cell into a border-affected area and a valid data area, performs neighborhood mean filtering and weighted fusion operations on the border-affected area, and performs end-to-end detection of characters and symbols on the valid data area, outputting OCR recognition results with coordinates; The results output module is used to dynamically generate table structure templates based on cell coordinate matrices and coordinate-based OCR recognition results, match field types through rule-based inference strategies, process and merge missing cell data based on adjacent cell information, and output structured data. The high-precision tabular data structuring OCR recognition system is used to perform the steps in the high-precision tabular data structuring OCR recognition method according to any one of claims 1-9.
Citation Information
Cited By
Table structure identification method and device and computer readable storage medium
CN121438340A
Financial document intelligent verification method and system
CN121505641A
Method for identifying engineering drawing detail table and generating BOM table
CN121600536A
Complex table recognition method and system
CN121600537A