Method and system for multi-modal document structured information extraction for complex scenarios
By calculating the local variation coefficient of the red-blue spectral ratio and using directional constraint repair techniques, combined with Delaunay triangulation mapping, and adaptively adjusting the fusion weights for optical character recognition, the document image processing problem in complex scenarios is solved, improving the recognition accuracy and field determination efficiency of characters covered by seals.
Patent Information
- Application Number
- CN202611710458.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-11-02
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies struggle to effectively handle document images in complex scenarios, especially when text is covered by stamps, handwriting is mixed, and perspective distortion occurs, resulting in low text recognition accuracy and high costs.
The seal coverage area is identified by calculating the local coefficient of variation of the red-blue spectral ratio. Combined with directional constraint repair and Delaunay triangulation mapping technology, the fusion weights are adaptively adjusted to perform optical character recognition, eliminate isolated noise points, and generate a comprehensive confidence map.
It improved the recognition accuracy of text covered by seals, reduced the model deployment cost, and improved the accuracy and efficiency of field determination.
Smart Images

Figure CN123182249A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of document image processing technology, specifically to a method and system for extracting structured information from multimodal documents in complex scenarios. Background Technology
[0002] In various document processing practices, a large number of documents exist in paper form, becoming static images after scanning or being photographed with a mobile phone. These images often contain a mixture of black laser-printed toner text, blue-black handwritten ink, and red official seal ink. These three elements differ significantly in color, spectral absorption characteristics, and spatial distribution, but they overlap considerably. Current technologies typically employ general-purpose OCR engines to directly recognize text in document images, or use deep learning image segmentation models to attempt to separate the seal from the text.
[0003] However, the above methods have the following shortcomings: when the stamp and text highly overlap, the stamp ink covers the strokes of the text, resulting in increased text brightness and broken strokes; document images are prone to perspective distortion during acquisition, such as tilted shooting angles of mobile phones or uneven pressure of scanner covers, causing field extraction position offsets; when handwritten annotations and printed text are mixed, traditional binarization methods are difficult to retain both types of ink simultaneously, easily losing handwritten content or introducing noise; deep learning-based methods require a large number of labeled samples, have poor model interpretability, and high deployment costs.
[0004] Therefore, there is an urgent need for a document structure information extraction method that can start from the physical level, is highly interpretable, and can effectively deal with stamp coverage, handwriting mixing, and perspective distortion. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to address the shortcomings of the existing technology by providing a method and system for extracting structured information from multimodal documents in complex scenarios.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] A method for extracting structured information from multimodal documents in complex scenarios includes the following steps:
[0008] Step S1: Obtain the image of the document to be processed and perform preprocessing to obtain the preprocessed image;
[0009] Step S2: Calculate the local variation coefficient pixel by pixel for the preprocessed image to generate a binary mask for the text area covered by the stamp;
[0010] Step S3: Merge the binary mask and the toner layer binary mask into a repair foreground, calculate the distance and orientation weight factors for the background pixels in the repair foreground, perform orientation constraint repair based on the distance and orientation weight factors, and obtain the morphology reconstruction matrix;
[0011] Step S4: Extract corner points from the preprocessed image and match them with standard template corner points. Simultaneously map the preprocessed image, the local variation coefficient, and the morphological reconstruction matrix to the standard template coordinate system through Delaunay triangulation and affine transformation.
[0012] Step S5: Determine the fusion weights based on the document type prior, construct three feature maps from the standardized local variation coefficients, standardized morphological reconstruction matrix, and standardized image brightness in the standard template coordinate system, and then fuse them by weight to obtain the comprehensive confidence map.
[0013] Step S6: Determine the field regions according to the standard template, count the proportion of effective text pixels that meet the confidence and spatial clustering conditions in each region to the total pixels in that region, determine whether the field exists based on the proportion, perform optical character recognition on the existing fields and output the structured results.
[0014] Furthermore, in step S1, the preprocessing specifically includes the following steps:
[0015] Step S1.1: Normalize the size of the document image to be processed, scaling the short side of the image to 1024 pixels and scaling the long side proportionally according to the original aspect ratio.
[0016] Step S1.2: Use a 3×3 window mid-range filter to perform noise reduction on the size-normalized image;
[0017] Step S1.3: Histogram equalization is used to perform contrast stretching on the noise-reduced image to obtain the preprocessed image.
[0018] Furthermore, step S2 specifically includes the following steps:
[0019] Step S2.1: Take each pixel in the preprocessed image as the center and take a square window with a side length of 11 pixels as the neighborhood;
[0020] Step S2.2: Traverse each pixel in the neighborhood and divide the red channel brightness value of the pixel by the sum of the blue channel brightness value and the zero constant to obtain the red-blue spectrum ratio of the pixel.
[0021] Step S2.3: Calculate the mean and standard deviation of all red-blue spectral ratios in the neighborhood, and divide the standard deviation by the sum of the mean and the zero constant to obtain the local variation coefficient of the pixel.
[0022] Step S2.4: When the local coefficient of variation is greater than 0.15, the pixel is marked as a text area covered by a stamp; otherwise, it is marked as a text area not covered by a stamp.
[0023] Step S2.5: After traversing all pixels, generate a binary mask for the text area covered by the stamp.
[0024] Furthermore, step S3 specifically includes the following steps:
[0025] Step S3.1: Perform a logical OR operation on the binary mask of the text area covered by the stamp and the binary mask of the toner layer obtained by Otsu's binarization method, and merge them into the repair foreground;
[0026] Step S3.2: For any background pixel with a value of 0 in the repaired foreground, calculate the Euclidean distance from the background pixel to the nearest foreground pixel using the distance transformation algorithm;
[0027] Step S3.3: Calculate the gradient vector of the red-blue spectral ratio at the background pixel using the first-order central difference method;
[0028] Step S3.4: Take a neighborhood window centered on the background pixel, perform principal component analysis on the Harris matrix of each pixel in the neighborhood window, and take the eigenvector corresponding to the largest eigenvalue as the stroke direction vector.
[0029] Step S3.5: Calculate the direction weight factor based on the angle between the gradient vector and the stroke direction vector. The direction weight factor is calculated as follows: calculate the absolute value of the dot product of the gradient vector and the stroke direction vector, divide it by the product of the Euclidean norm of the gradient vector and the Euclidean norm of the stroke direction vector, and then take the negative value of the exponential function with the natural constant as the base.
[0030] Step S3.6: When the Euclidean distance is less than 2.5 pixels and the orientation weight factor is greater than 0.5, the background pixel is converted into the text foreground.
[0031] Step S3.7: After traversing all background pixels, the shape reconstruction matrix is obtained.
[0032] Furthermore, step S4 specifically includes the following steps:
[0033] Step S4.1: Extract visual corner points from the preprocessed image using the FAST corner detection algorithm. After non-maximum suppression, obtain a set of distorted image corner points. Then, match the set of distorted image corner points with the predefined set of corner points in the standard template according to the index.
[0034] Step S4.2: Using the set of corner points in the standard template as vertices, construct a triangulation network using the Delaunay triangulation algorithm;
[0035] Step S4.3: For each triangle, use affine transformation to calculate the affine transformation matrix of the standard template triangle to the corresponding triangle in the preprocessed image;
[0036] Step S4.4: For each pixel in the standard template coordinate system, determine the triangle to which the pixel belongs, and use the affine transformation matrix of the triangle to calculate the corresponding coordinates of the pixel in the preprocessed image.
[0037] Step S4.5: Using bilinear interpolation, the preprocessed image, the local coefficient of variation, and the morphological reconstruction matrix are synchronously mapped to the standard template coordinate system to obtain the standardized image, the standardized local coefficient of variation, and the standardized morphological reconstruction matrix, respectively.
[0038] Furthermore, step S5 specifically includes the following steps:
[0039] Step S5.1: Determine the fusion weights of the three feature maps based on the type of the current document;
[0040] Step S5.2: Construct the standardized local variation coefficients into a first feature map;
[0041] Step S5.3: Directly use the standardized morphological reconstruction matrix as the second feature map;
[0042] Step S5.4: Calculate the brightness of each pixel in the standardized image, normalize the brightness to the 0 to 1 range, and then take the complement to obtain the third feature map;
[0043] Step S5.5: Perform a weighted summation of the first feature map, the second feature map, and the third feature map according to the fusion weights to obtain the comprehensive confidence map.
[0044] Furthermore, step S6 specifically includes the following steps:
[0045] Step S6.1: Determine the pixel range of each field area in the standard template coordinate system according to the standard template template of the document;
[0046] Step S6.2: For each field area, count the pixels with a comprehensive confidence score greater than 0.6 in that area, and count the number of pixels with a comprehensive confidence score greater than 0.6 in its 3×3 neighborhood centered on that pixel. When the number is greater than or equal to 3, the pixel is counted as a valid text pixel.
[0047] Step S6.3: Calculate the percentage of the effective text pixels to the total pixels in the field area;
[0048] Step S6.4: When the percentage is greater than 0.12, it is determined that the field exists in the current document; otherwise, it is determined that the field does not exist and an empty value is output.
[0049] Step S6.5: For fields that are determined to exist, perform optical character recognition on the connected pixel regions within the field area that meet the confidence condition and spatial clustering condition;
[0050] Step S6.6: Combine the recognition results with the field names into key-value pairs. After all fields have been processed, output the structured results in JSON format.
[0051] A multimodal document structured information extraction system for complex scenarios, used to implement any one of the multimodal document structured information extraction methods for complex scenarios, including:
[0052] The image acquisition module is used to acquire images of the document to be processed.
[0053] The preprocessing module is used to perform size normalization, median filtering for noise reduction, histogram equalization, and contrast stretching on the document image to be processed, so as to obtain the preprocessed image.
[0054] The physical tomography module is used to calculate the local coefficient of variation pixel by pixel in the preprocessed image and generate a binary mask for the text area covered by the stamp.
[0055] The morphology restoration module is used to merge the binary mask and the toner layer binary mask into a restoration foreground, calculate the distance and orientation weight factors for the background pixels in the restoration foreground, perform orientation constraint restoration based on the distance and orientation weight factors, and obtain the morphology reconstruction matrix.
[0056] The normalization mapping module is used to extract corner points from the preprocessed image and match them with corner points of a standard template. It synchronously maps the preprocessed image, the local variation coefficients, and the morphological reconstruction matrix to the standard template coordinate system through Delaunay triangulation and affine transformation.
[0057] The confidence fusion module is used to determine the fusion weights based on the prior document type. It constructs three feature maps by combining the standardized local variation coefficients, the standardized morphological reconstruction matrix, and the standardized image brightness in the standard template coordinate system. The weighted fusion results in a comprehensive confidence map.
[0058] The structured output module is used to determine the field regions according to the standard template, count the proportion of effective text pixels that meet the confidence condition and spatial clustering condition in each region to the total pixels in that region, determine whether the field exists based on the proportion, perform optical character recognition on the existing fields, and output the structured results.
[0059] A storage medium storing instructions that, when read by a computer, cause the computer to execute any of the multimodal document structured information extraction methods for complex scenarios described above.
[0060] An electronic device includes a processor and the storage medium, the processor executing instructions in the storage medium.
[0061] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0062] 1. This invention calculates the local variation coefficient of the red-blue spectrum ratio and utilizes the essential differences in spectral absorption and spatial distribution between stamp ink and toner text. It can accurately identify the area of text covered by the stamp without pre-separating the stamp and text, effectively solving the problem of difficulty in extracting text when the stamp and text are highly overlapping.
[0063] 2. This invention uses directional constraint repair, allowing only background pixels along the stroke direction to be filled with text, avoiding misfilling across strokes, effectively repairing broken character strokes covered by stamps, and significantly improving the accuracy of subsequent optical character recognition.
[0064] 3. This invention determines the fusion weights based on the prior document type, and constructs three feature maps by weighting and fusing the standardized local variation coefficient, morphological reconstruction matrix and brightness. This can adaptively adjust to the degradation characteristics of different document types, thereby improving the accuracy of the comprehensive confidence map.
[0065] 4. This invention uses the spatial clustering degree of high-confidence pixels as the criterion for field existence, which effectively eliminates the interference of isolated noise points, avoids field omissions caused by the dilution of average confidence by background pixels, and improves the accuracy of field determination. Attached Figure Description
[0066] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0067] Figure 1 This is a flowchart illustrating an embodiment of the present invention;
[0068] Figure 2 This is a schematic diagram of the system modules according to an embodiment of the present invention;
[0069] Figure 3 This is a flowchart illustrating the field determination and output process in an embodiment of the present invention. Detailed Implementation
[0070] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0071] like Figure 1 As shown, the method for extracting structured information from multimodal documents in complex scenarios includes the following steps:
[0072] Step S1: Obtain the image of the document to be processed and perform preprocessing to obtain the preprocessed image;
[0073] Step S2: Calculate the local variation coefficient pixel by pixel for the preprocessed image to generate a binary mask for the text area covered by the stamp;
[0074] Step S3: Merge the binary mask and the toner layer binary mask into a repair foreground, calculate the distance and orientation weight factors for the background pixels in the repair foreground, perform orientation constraint repair based on the distance and orientation weight factors, and obtain the morphology reconstruction matrix;
[0075] Step S4: Extract corner points from the preprocessed image and match them with standard template corner points. Simultaneously map the preprocessed image, the local variation coefficient, and the morphological reconstruction matrix to the standard template coordinate system through Delaunay triangulation and affine transformation.
[0076] Step S5: Determine the fusion weights based on the document type prior, construct three feature maps from the standardized local variation coefficients, standardized morphological reconstruction matrix, and standardized image brightness in the standard template coordinate system, and then fuse them by weight to obtain the comprehensive confidence map.
[0077] Step S6: Determine the field regions according to the standard template, count the proportion of effective text pixels that meet the confidence and spatial clustering conditions in each region to the total pixels in that region, determine whether the field exists based on the proportion, perform optical character recognition on the existing fields and output the structured results.
[0078] In various document processing practices, a large number of documents exist in paper form, becoming static images after scanning or photographing. These images simultaneously contain black laser-printed toner text, blue-black handwritten ink, and red official seal ink. These three types of ink differ fundamentally in their physical and optical properties: toner absorbs red and blue light proportionally; red ink is a semi-transparent film that strongly absorbs blue light and weakly absorbs red light; and blue-black handwritten ink absorbs blue light more strongly than red light. Furthermore, seal ink is spatially uniform and continuous, while toner text occupies only a narrow area of the strokes. This invention utilizes these differences to propose a method for information decoupling and structured extraction directly from the physical and optical level, without relying on deep learning black-box models.
[0079] First, the input document image is normalized by scaling the shorter side to a preset pixel size of 1024 pixels, while the longer side is scaled proportionally to its original aspect ratio. This operation ensures that the physical size of subsequent neighboring windows is consistent, avoiding changes in window coverage due to different resolutions.
[0080] A 3×3 window mid-range filter is used to denoise the image, removing salt-and-pepper noise introduced by scanning or photography, while preserving the sharpness of the text edges.
[0081] Finally, histogram equalization is used to stretch the contrast of the image, improving local overexposure or underexposure caused by uneven lighting, and making the overall brightness distribution of the image uniform.
[0082] The preprocessed image is denoted as , where (x, y) are pixel coordinates, and each pixel contains brightness values for three channels: R, G, and B, all of which are integers from 0 to 255.
[0083] The red ink film strongly absorbs blue light and weakly absorbs red light, resulting in a significantly greater than 1 R / B ratio in the stamp-covered area. Furthermore, due to the uniform coating of the ink film, this ratio remains spatially continuous and smooth within the stamp area. Carbon ink characters absorb red and blue light proportionally, with an R / B ratio close to 1, and occupy only a narrow area within the strokes. When the stamp covers the text, the R / B ratio at the stamp background is approximately 2-3, while the R / B ratio at the strokes is approximately 1. These two ratios alternate within a local space, leading to a significantly increased dispersion of the R / B ratio within this neighborhood. Therefore, the local coefficient of variation of the red-blue spectral ratio is calculated within the neighborhood of each pixel, and this coefficient is used to identify the areas where the stamp background and text strokes alternate.
[0084] For a pixel (x, y), define its neighborhood. A square window centered at (x, y) with a side length of 11 pixels is defined. The window size is determined by combining the width of the Chinese character strokes (usually 2-4 pixels) and the ink diffusion width of the stamp (usually 5-10 pixels) to ensure that the window simultaneously contains both the strokes and the ink background. For each neighboring pixel, its red-blue spectral ratio is calculated using the following formula:
[0085]
[0086] in, This represents the red-to-blue spectral ratio of a neighboring pixel (i, j). Typical values are 2.0–3.0 for red stamp regions and 0.8–1.2 for toner text regions. This represents the red channel brightness value of pixel (i, j), ranging from 0 to 255. This represents the blue channel brightness value of pixel (i, j), ranging from 0 to 255. This represents the zero constant, which is usually taken as 1.
[0087] Calculate the mean and standard deviation of all red-blue spectral ratios within the neighborhood. The mean reflects the average level of the red-blue spectral ratios within the neighborhood, and the standard deviation reflects the dispersion of each pixel relative to the average level. Dividing the standard deviation by the mean yields the dimensionless relative dispersion, i.e., the coefficient of variation. The specific formula for the local coefficient of variation is:
[0088]
[0089] in, The coefficient of variation (COP) represents the local variation coefficient, with a range of [0, +∞). It increases significantly when both stamp ink and toner strokes are present in the neighborhood; it approaches 0 when the neighborhood consists entirely of stamps, toner, or blank areas. Therefore, the COP is an effective indicator of the area of text covered by stamps. This represents the standard deviation of all red-blue spectral ratios within the neighborhood. This represents the arithmetic mean of all red-blue spectral ratios within the neighborhood;
[0090] when If the value is greater than 0.15, the pixel is marked as a text area covered by a stamp; otherwise, it is marked as a text area not covered by a stamp. After traversing all pixels, a binary mask of the text area covered by a stamp is generated, where the pixel marked as a text area covered by a stamp has a value of 1, and the rest have a value of 0.
[0091] After identifying the areas where the stamp covers the text, the brightness of the character strokes within these areas is increased due to the semi-transparent red ink covering them. In conventional binarization, this can easily be misidentified as background, leading to breaks in the toner layer's binary mask. Therefore, the inherent geometric characteristics of character strokes can be utilized: the grayscale changes are gradual along the stroke's direction but drastic along the vertical direction. Directional constraint repair allows only background pixels along the stroke's direction to be filled as text, thus preventing misfilling across strokes.
[0092] The obtained binary mask of the stamp-covered text area is logically ORed with the binary mask of the toner layer obtained by Otsu's binarization method, and then merged into the repair foreground. Pixels belonging to the stamp-covered text area or the toner text area are set to 1, and the rest are set to 0.
[0093] For any background pixel (x, y) with a value of 0 in the foreground, the distance transformation algorithm is used to calculate its Euclidean distance d(x, y) to the nearest foreground pixel. The closer the distance, the closer the background pixel is to the text area, and the more likely it is to be a break or gap.
[0094] Simultaneously, a direction weighting factor is defined to determine whether the background pixel lies on the extension line of the stroke direction. The specific formula is as follows:
[0095]
[0096] in, This represents the direction weighting factor, with a value range of (0, 1]. A value closer to 1 indicates that the pixel is located on the extension line of the stroke direction and is suitable for filling; a value closer to 0 indicates that the pixel is located across the stroke direction and should not be filled. This represents the gradient vector of the red-blue spectral ratio at pixel (x, y). The gradient direction points in the direction of the fastest change in the red-blue spectral ratio, and in scenes where a stamp covers text, it is usually perpendicular to the stroke edge. This represents the stroke direction vector, obtained by performing principal component analysis on the Harris matrix of each pixel within the pixel's neighborhood window, and taking the eigenvector corresponding to the largest eigenvalue. Its physical meaning is the main direction of the potential stroke at that location. The Euclidean norm of a vector. This represents the zero constant, usually taken as 10. -8 .
[0097] The repair decision requires both distance and direction conditions to be met simultaneously. The specific formula is as follows:
[0098]
[0099] in, This indicates the reconstruction decision result. A value of 1 converts the background pixel into the text foreground, while a value of 0 leaves the background unchanged. This represents the Euclidean distance from the background pixel to the nearest foreground pixel. 2.5 is the distance threshold, in pixels, set according to the commonly used Chinese stroke width of about 2 to 4 pixels. Gaps smaller than this value are considered stroke breaks. 0.5 is the direction weight threshold, ensuring that repair is only performed along the direction of the stroke.
[0100] After traversing all background pixels, a shape reconstruction matrix is obtained, with the same size as the original image. Pixels with a value of 1 represent newly added text pixels after restoration. Merging this matrix with the original toner layer foreground results in a complete text area.
[0101] When document images are captured, perspective distortion may occur due to mobile phone shooting or uneven pressure of the scanner cover plate, causing the fixed coordinate area positioning to fail. Therefore, it is necessary to use flexible image registration technology to synchronously map the distorted image to the standard template space.
[0102] First, the FAST corner detection algorithm is used to extract visual corners from the preprocessed image. The threshold parameter is set to 20. The main corners include the intersection of table lines, the right-angle inflection point of the title bar, and the intersection of the seal arc and the text. After non-maximum suppression, the distorted image corner set is obtained and corresponds one-to-one with the predefined corner set in the standard template according to the index.
[0103] The Delaunay triangulation algorithm is used to construct a triangulation network using the set of corner points in the standard template as vertices, with an empty circle threshold of 10. -6The distorted image contains isomorphic triangulations; then, for each pair of corresponding triangles, an affine transformation is used to calculate the affine transformation matrix that maps the standard template triangle to the corresponding triangle in the preprocessed image;
[0104] Finally, for each pixel in the standard template coordinate system, its corresponding triangle is determined. The affine transformation matrix of this triangle is used to calculate its corresponding coordinates in the preprocessed image. A bilinear interpolation method is then used to synchronously map the preprocessed image, local coefficients of variation, and morphological reconstruction matrix to the standard template coordinate system, resulting in a standardized image, standardized local coefficients of variation, and standardized morphological reconstruction matrix. All three use the exact same mapping relationship, maintaining precise spatial alignment in the standard template space.
[0105] In the standard template space, each pixel (u, v) possesses three independent pieces of evidence: the standardized local coefficient of variation, the standardized morphological reconstruction matrix, and the brightness information of the standardized image. The standardized local coefficient of variation is most sensitive to the area of text covered by the stamp, reflecting the dispersion of the red-blue spectral ratio in the local space; the standardized morphological reconstruction matrix is most sensitive to the toner text skeleton, recording the pixel position determined as text after directional constraint repair; the brightness information of the standardized image is indicative of all ink marks, with darker ink marks having lower brightness, but for text covered by a red stamp, the brightness has been distorted by the ink.
[0106] This invention determines the fusion weights of three features based on the document type prior. The system pre-sets several document types, each with a corresponding set of weights. Features corresponding to the most significant degradation factors in a particular document type are assigned higher weights. For example, for business licenses heavily covered with red stamps, the local coefficient of variation has a higher weight; for enterprise registration application forms with many handwritten annotations, the morphological reconstruction matrix has a higher weight; and for high-definition standard scans, the brightness feature has a higher weight.
[0107] The standardized local variation coefficients are used to construct the first feature map, the standardized morphological reconstruction matrix is directly used as the second feature map, and the complement of the ITU-R BT.601 brightness of each pixel in the standardized image is taken after normalization as the third feature map. The specific formula for the comprehensive text confidence score is as follows:
[0108]
[0109] in, This represents the overall text confidence score, with a value range of [0, 1]. The closer the score is to 1, the higher the probability that the pixel belongs to text. The fusion weights of the three feature maps are dimensionless, non-negative real numbers determined by the current document type, and their sum equals 1. The first feature map is obtained by normalizing the standardized local variation coefficients. This represents the second feature map, i.e., the standardized morphological reconstruction matrix. The third feature map is obtained by taking the complement of the brightness normalized image.
[0110] As an example, for business license type documents, the fusion weights are set as follows: first feature map 0.40, second feature map 0.25, and third feature map 0.35; for enterprise registration application form type documents, the fusion weights are set as follows: first feature map 0.30, second feature map 0.40, and third feature map 0.30; for high-definition standard scan document type documents, the fusion weights are set as follows: first feature map 0.20, second feature map 0.30, and third feature map 0.50.
[0111] According to the standard template of the document, each field region has a predefined pixel range in the standard template coordinate system. For the k-th field region, the average confidence score cannot be simply used as the existence criterion because text strokes usually only occupy 10% to 25% of the region area, and a large number of background pixels will dilute the average value. This invention uses the degree of clustering of high-confidence pixels as the criterion: it not only requires high pixel confidence, but also requires that they form a cluster in space to eliminate isolated noise.
[0112] For each pixel (u, v), count the number of pixels with a comprehensive confidence score greater than 0.6 within a 3×3 neighborhood, with a value range of 0 to 8. When the score is greater than or equal to 3, the pixel is considered a valid text pixel and not isolated noise. The formula for the clustered high confidence density of the k-th field region is:
[0113]
[0114] in, This represents the high-confidence clustering density of the k-th field region, with a value range of [0, 1]. It also represents the proportion of pixels meeting the criteria to the total number of pixels in that region. This represents the set of pixels in the k-th field region within the standard template coordinate system. This indicates the total number of pixels in the field area. This represents the number of pixels with a combined confidence level greater than 0.6 within a 3×3 neighborhood of pixel (u, v). This indicates an indicator function that takes the value 1 when the condition is true and 0 when the condition is false.
[0115] when If the value is greater than 0.12, the field is considered to exist in the current document; otherwise, the field is considered not to exist and an empty value is output. For fields determined to exist, the overall text confidence score within the field range must be greater than 0.6 and... Optical character recognition (OCR) is performed on connected components with 3 or more pixels. The recognition results are combined with the field names to form key-value pairs. After all fields have been processed, structured data in JSON format is output, using the field name as the key and the recognition result as the value. For fields determined to be non-existent, the output value is null. The output JSON data can be directly interfaced with the database fields of business systems to complete a fully automated extraction process from raw images to structured information.
[0116] like Figure 3 As shown, the field determination and output process includes: First, based on the standard template of the document, determine the pixel range of each field region in the standard template coordinate system; second, for each field region, count the pixels with a comprehensive confidence score greater than 0.6 within that region, and count the number of pixels with a comprehensive confidence score greater than 0.6 within its 3×3 neighborhood centered on that pixel. When this number is greater than or equal to 3, the pixel is counted as a valid text pixel; then, calculate the proportion of valid text pixels to the total pixels of the field region; next, determine whether this proportion is greater than 0.12. If so, determine that the field exists in the current document, perform optical character recognition on the connected components of pixels within the field region that meet the confidence score condition and spatial clustering condition, and combine the recognition result with the field name into a key-value pair; otherwise, determine that the field does not exist and output an empty value; finally, after all fields have been processed, output a structured result in JSON format.
[0117] like Figure 2 As shown, a multimodal document structured information extraction system for complex scenarios is used to implement any of the multimodal document structured information extraction methods for complex scenarios, including:
[0118] The image acquisition module is used to acquire images of the document to be processed.
[0119] The preprocessing module is used to perform size normalization, median filtering for noise reduction, histogram equalization, and contrast stretching on the document image to be processed, so as to obtain the preprocessed image.
[0120] The physical tomography module is used to calculate the local coefficient of variation pixel by pixel in the preprocessed image and generate a binary mask for the text area covered by the stamp.
[0121] The morphology restoration module is used to merge the binary mask and the toner layer binary mask into a restoration foreground, calculate the distance and orientation weight factors for the background pixels in the restoration foreground, perform orientation constraint restoration based on the distance and orientation weight factors, and obtain the morphology reconstruction matrix.
[0122] The normalization mapping module is used to extract corner points from the preprocessed image and match them with corner points of a standard template. It synchronously maps the preprocessed image, the local variation coefficients, and the morphological reconstruction matrix to the standard template coordinate system through Delaunay triangulation and affine transformation.
[0123] The confidence fusion module is used to determine the fusion weights based on the prior document type. It constructs three feature maps by combining the standardized local variation coefficients, the standardized morphological reconstruction matrix, and the standardized image brightness in the standard template coordinate system. The weighted fusion results in a comprehensive confidence map.
[0124] The structured output module is used to determine the field regions according to the standard template, count the proportion of effective text pixels that meet the confidence condition and spatial clustering condition in each region to the total pixels in that region, determine whether the field exists based on the proportion, perform optical character recognition on the existing fields, and output the structured results.
[0125] The modules described above can be integrated into the same computing device or distributed across multiple computing devices. Data transmission between modules can be achieved via memory bus, network interface, or file system. In a preferred embodiment, the image acquisition module, preprocessing module, physical tomography module, morphological restoration module, normalization mapping module, confidence fusion module, and structured output module are sequentially connected in series, with the output of the previous module serving as the input of the next module, forming a complete pipelined processing architecture.
[0126] A caching unit can be set up between the physical tomography module and the morphology restoration module to temporarily store local variation coefficients and binary masks, so that the continuous processing of the physical tomography module is not affected when the morphology restoration module takes a long time. A template library unit can be set up in the standardization mapping module to store standard templates for various document types and their predefined corner point sets. When the input document type changes, the standardization mapping module calls the corresponding template from the template library unit to achieve batch processing of multiple document types.
[0127] The confidence level fusion module allows for the configuration of weights, which stores the fusion weight combinations for each document type. Operators can update the weight values in the weight configuration unit via configuration files or a graphical interface to adapt to changes in document formats across different regions and time periods. The structured output module allows for the configuration of output format settings, which maps field names in the JSON output to match the database field names of the target business system, enabling direct data import without secondary conversion.
[0128] The system may also include a quality assessment module, connected to the structured output module, for evaluating the quality of the output structured results. The quality assessment module calculates the field completeness rate as the ratio of the number of successfully identified fields to the total number of fields, and the field confidence rate as the ratio of the number of fields with an average confidence level higher than a preset threshold to the total number of fields. When either the field completeness rate or the field confidence rate falls below the preset threshold, an alarm message is output, prompting manual review. This module effectively monitors the system's operational quality and promptly identifies abnormal documents.
[0129] The system may also include a model update module, used to update the corner point set and field area range in the standard template based on the results of manual review. When operators discover that the field positioning of a certain type of document is offset, they can adjust the pixel range of the corresponding field area in the standard template through the model update module, or add or delete corner points in the standard template, so that the standardization mapping module and the structured output module can adapt to the new document format.
[0130] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0131] The examples described herein are merely preferred embodiments of the invention and are not intended to limit the concept and scope of the invention. Any modifications and improvements made by those skilled in the art to the technical solutions of the invention without departing from the design concept of the invention should fall within the protection scope of the invention.
Claims
1. A method for extracting structured information from multimodal documents in complex scenarios, characterized in that: Includes the following steps: Step S1: Obtain the image of the document to be processed and perform preprocessing to obtain the preprocessed image; Step S2: Calculate the local variation coefficient pixel by pixel for the preprocessed image to generate a binary mask for the text area covered by the stamp; Step S3: Merge the binary mask and the toner layer binary mask into a repair foreground, calculate the distance and orientation weight factors for the background pixels in the repair foreground, perform orientation constraint repair based on the distance and orientation weight factors, and obtain the morphology reconstruction matrix; Step S4: Extract corner points from the preprocessed image and match them with standard template corner points. Simultaneously map the preprocessed image, the local variation coefficient, and the morphological reconstruction matrix to the standard template coordinate system through Delaunay triangulation and affine transformation. Step S5: Determine the fusion weights based on the document type prior, construct three feature maps from the standardized local variation coefficients, standardized morphological reconstruction matrix, and standardized image brightness in the standard template coordinate system, and then fuse them by weight to obtain the comprehensive confidence map. Step S6: Determine the field regions according to the standard template, count the proportion of effective text pixels that meet the confidence and spatial clustering conditions in each region to the total pixels in that region, determine whether the field exists based on the proportion, perform optical character recognition on the existing fields and output the structured results.
2. The method according to claim 1, characterized in that, In step S1, the preprocessing specifically includes the following steps: Step S1.1: Normalize the size of the document image to be processed, scaling the short side of the image to 1024 pixels and scaling the long side proportionally according to the original aspect ratio. Step S1.2: Use a 3×3 window mid-range filter to perform noise reduction on the size-normalized image; Step S1.3: Histogram equalization is used to perform contrast stretching on the noise-reduced image to obtain the preprocessed image.
3. The method according to claim 2, characterized in that, Step S2 specifically includes the following steps: Step S2.1: Take each pixel in the preprocessed image as the center and take a square window with a side length of 11 pixels as the neighborhood; Step S2.2: Traverse each pixel in the neighborhood and divide the red channel brightness value of the pixel by the sum of the blue channel brightness value and the zero constant to obtain the red-blue spectrum ratio of the pixel. Step S2.3: Calculate the mean and standard deviation of all red-blue spectral ratios in the neighborhood, and divide the standard deviation by the sum of the mean and the zero constant to obtain the local variation coefficient of the pixel. Step S2.4: When the local coefficient of variation is greater than 0.15, the pixel is marked as a text area covered by a stamp; otherwise, it is marked as a text area not covered by a stamp. Step S2.5: After traversing all pixels, generate a binary mask for the text area covered by the stamp.
4. The method according to claim 3, characterized in that, Step S3 specifically includes the following steps: Step S3.1: Perform a logical OR operation on the binary mask of the text area covered by the stamp and the binary mask of the toner layer obtained by Otsu's binarization method, and merge them into the repair foreground; Step S3.2: For any background pixel with a value of 0 in the repaired foreground, calculate the Euclidean distance from the background pixel to the nearest foreground pixel using the distance transformation algorithm; Step S3.3: Calculate the gradient vector of the red-blue spectral ratio at the background pixel using the first-order central difference method; Step S3.4: Take a neighborhood window centered on the background pixel, perform principal component analysis on the Harris matrix of each pixel in the neighborhood window, and take the eigenvector corresponding to the largest eigenvalue as the stroke direction vector. Step S3.5: Calculate the direction weight factor based on the angle between the gradient vector and the stroke direction vector. The direction weight factor is calculated as follows: calculate the absolute value of the dot product of the gradient vector and the stroke direction vector, divide it by the product of the Euclidean norm of the gradient vector and the Euclidean norm of the stroke direction vector, and then take the negative value of the exponential function with the natural constant as the base. Step S3.6: When the Euclidean distance is less than 2.5 pixels and the orientation weight factor is greater than 0.5, the background pixel is converted into the text foreground. Step S3.7: After traversing all background pixels, the shape reconstruction matrix is obtained.
5. The method according to claim 4, characterized in that, Step S4 specifically includes the following steps: Step S4.1: Extract visual corner points from the preprocessed image using the FAST corner detection algorithm. After non-maximum suppression, obtain a set of distorted image corner points. Then, match the set of distorted image corner points with the predefined set of corner points in the standard template according to the index. Step S4.2: Using the set of corner points in the standard template as vertices, construct a triangulation network using the Delaunay triangulation algorithm; Step S4.3: For each triangle, use affine transformation to calculate the affine transformation matrix of the standard template triangle to the corresponding triangle in the preprocessed image; Step S4.4: For each pixel in the standard template coordinate system, determine the triangle to which the pixel belongs, and use the affine transformation matrix of the triangle to calculate the corresponding coordinates of the pixel in the preprocessed image. Step S4.5: Using bilinear interpolation, the preprocessed image, the local coefficient of variation, and the morphological reconstruction matrix are synchronously mapped to the standard template coordinate system to obtain the standardized image, the standardized local coefficient of variation, and the standardized morphological reconstruction matrix, respectively.
6. The method according to claim 5, characterized in that, Step S5 specifically includes the following steps: Step S5.1: Determine the fusion weights of the three feature maps based on the type of the current document; Step S5.2: Construct the standardized local variation coefficients into a first feature map; Step S5.3: Directly use the standardized morphological reconstruction matrix as the second feature map; Step S5.4: Calculate the brightness of each pixel in the standardized image, normalize the brightness to the 0 to 1 range, and then take the complement to obtain the third feature map; Step S5.5: Perform a weighted summation of the first feature map, the second feature map, and the third feature map according to the fusion weights to obtain the comprehensive confidence map.
7. The method according to claim 6, characterized in that, Step S6 specifically includes the following steps: Step S6.1: Determine the pixel range of each field area in the standard template coordinate system according to the standard template template of the document; Step S6.2: For each field area, count the pixels with a comprehensive confidence score greater than 0.6 in that area, and count the number of pixels with a comprehensive confidence score greater than 0.6 in its 3×3 neighborhood centered on that pixel. When the number is greater than or equal to 3, the pixel is counted as a valid text pixel. Step S6.3: Calculate the percentage of the effective text pixels to the total pixels in the field area; Step S6.4: When the percentage is greater than 0.12, it is determined that the field exists in the current document; otherwise, it is determined that the field does not exist and an empty value is output. Step S6.5: For fields that are determined to exist, perform optical character recognition on the connected pixel regions within the field area that meet the confidence condition and spatial clustering condition; Step S6.6: Combine the recognition results with the field names into key-value pairs. After all fields have been processed, output the structured results in JSON format.
8. A multimodal document structured information extraction system for complex scenarios, used to implement the multimodal document structured information extraction method for complex scenarios as described in any one of claims 1-7, characterized in that, include: The image acquisition module is used to acquire images of the document to be processed. The preprocessing module is used to perform size normalization, median filtering for noise reduction, histogram equalization, and contrast stretching on the document image to be processed, so as to obtain the preprocessed image. The physical tomography module is used to calculate the local coefficient of variation pixel by pixel in the preprocessed image and generate a binary mask for the text area covered by the stamp. The morphology restoration module is used to merge the binary mask and the toner layer binary mask into a restoration foreground, calculate the distance and orientation weight factors for the background pixels in the restoration foreground, perform orientation constraint restoration based on the distance and orientation weight factors, and obtain the morphology reconstruction matrix. The normalization mapping module is used to extract corner points from the preprocessed image and match them with corner points of a standard template. It synchronously maps the preprocessed image, the local variation coefficients, and the morphological reconstruction matrix to the standard template coordinate system through Delaunay triangulation and affine transformation. The confidence fusion module is used to determine the fusion weights based on the prior document type. It constructs three feature maps by combining the standardized local variation coefficients, the standardized morphological reconstruction matrix, and the standardized image brightness in the standard template coordinate system. The weighted fusion results in a comprehensive confidence map. The structured output module is used to determine the field regions according to the standard template, count the proportion of effective text pixels that meet the confidence condition and spatial clustering condition in each region to the total pixels in that region, determine whether the field exists based on the proportion, perform optical character recognition on the existing fields, and output the structured results.
9. A storage medium, characterized in that, The storage medium stores instructions that, when read by a computer, cause the computer to execute the multimodal document structured information extraction method for complex scenarios as described in any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes a processor and a storage medium as described in claim 9, wherein the processor executes instructions in the storage medium.
