A method for calibrating and extracting text information from reimbursement document images
Through image preprocessing and machine learning technology, the problem of paper reimbursement document noise and printing misalignment is solved, the calibration and extraction of image text information is realized, the efficiency and accuracy of financial management is improved, and electronic documents and paper documents are automatically compared. consistency.
Patent Information
- Application Number
- CN202110910082.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-09
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-08-09
AI Technical Summary
Existing technology In financial management, there are inefficiencies and errors when comparing electronic documents with paper documents. This is mainly due to the noise and printing problems in the paper reimbursement document images that affect the accuracy of optical character recognition, and the printed information and template fields are often inconsistent. dislocation.
The image preprocessing algorithm based on OTSU threshold segmentation and EDT distance transformation is used for noise filtering, combined with SSD network and Tesseract optical character recognition technology, to achieve the calibration and extraction of text information in reimbursement document images. Through image noise filtering, text information calibration and data comparison Yes, automatically align user information and template fields, and generate electronic documents for automatic verification.
It improves the efficiency of financial personnel in checking bills, reduces financial management costs, realizes automatic consistency comparison between electronic documents and paper documents, and enhances the accuracy and efficiency of financial management.
Smart Images

Figure CN113554027B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of image recognition, machine learning, etc., and specifically refers to a method for calibrating and extracting text information of a reimbursement document image. Background Art
[0002] In financial reconciliation and other management activities, it is necessary to compare the consistency of electronic document data and paper document data in the financial information management system to ensure the correctness and authenticity of financial activities. However, in reality, there are often inconsistencies between electronic document data and paper document data, which seriously affects the efficiency of financial management. At present, the comparison of electronic documents and paper documents is mainly carried out through manual review by financial personnel, which is inefficient and still has errors.
[0003] Optical character recognition technology is one of the core technologies for the electronicization of paper documents. It provides a feasible technical path for completing the comparison between paper documents and electronic documents, but there are some technical difficulties: (1) There is a lot of noise in the image of paper expense documents, such as stains produced during the paper production process, unclear ink marks produced during the printing process of expense documents, and seals produced during the review process of expense documents. These noises greatly affect the accuracy of optical character recognition; (2) During the printing process of paper expense documents, due to the influence of the placement of the printed paper, misalignment or even misplacement often occurs, which brings great technical difficulties to the accurate identification and extraction of document user information.
[0004] Therefore, in response to the above-mentioned technical problems, the present invention implements a method for calibrating and extracting text information from paper reimbursement document images based on image recognition and machine learning technology, thereby realizing the extraction and alignment of user information from paper document images, and comparing them with electronic documents in the financial system, automatically reviewing the consistency between paper documents and electronic documents, reducing financial management costs and improving financial management efficiency, and having high practical value. Summary of the invention
[0005] The present invention aims to solve the problems of format and noise caused by seals, as well as the misalignment of user information and template fields caused by printing, in the process of digitizing paper reimbursement documents. It aims to calibrate and extract user information in the reimbursement document image through image processing and recognition technologies, and generate electronic documents for automatic verification, thereby improving the efficiency of financial personnel in checking bills.
[0006] The invention includes:
[0007] (1) Noise filtering method for reimbursement document images
[0008] (2) Reimbursement image text information calibration method
[0009] The details are as follows:
[0010] (1) Noise filtering method for reimbursement document images
[0011] This method is based on the image preprocessing algorithm of OTSU threshold segmentation and EDT distance transform. It filters the noise such as seals, ink dots and wrinkles in the reimbursement document image, and uses the filtered image as the input of the image text information calibration method.
[0012] The pixel matrix of the three color channels of RGB of the original image is extracted, and the OTSU threshold segmentation algorithm is used for binarization processing to generate a binary mask matrix. The original image is filtered to retain the dark part of the image that may be the text of the reimbursement document and remove the noise interference of color information such as seals.
[0013] The EDT distance transform is used on the filtered image to generate a Euclidean distance grayscale image with the text pixels of the reimbursement document retained in the binary image as the target, where the pixel value of the grayscale image is the distance between it and the nearest target point. The OTSU threshold segmentation algorithm is used again, and the threshold is set to half the stroke width of the document print text to obtain the extracted binary image and realize text refinement.
[0014] Perform morphological opening operation on the refined binary image to eliminate isolated, small ink dots and seal noise in the image, separate the adhesion of objects in thin connections such as characters and characters, characters and table borders in the reimbursement document, and eliminate raised parts in larger areas such as the ends of strokes.
[0015] The contour extraction algorithm is used to extract the text in the above binary image, and the maximum connected domain algorithm is used to obtain the minimum circumscribed rectangle of the text connected domain. The aspect ratio threshold of the text rectangle frame is set, and the remaining non-text connected domains are filtered to obtain the key fields and user information of the reimbursement document after filtering the noise.
[0016] (2) Reimbursement document image text information calibration method
[0017] In order to realize the calibration and extraction of reimbursement document information, the present invention proposes an optical character connected domain semantic correlation registration based on SSD network and a reimbursement document image text information recognition method based on Tesseract optical character recognition, performs alignment and calibration processing on user information and template fields, and compares the recognized text with electronic document data to realize the calibration and extraction of reimbursement document image text information. The method takes user information in the document as the detection target, extracts the user information connected domain from the reimbursement document image using the maximum connected domain algorithm, and constructs a correlation matrix based on the corresponding relationship between user information and document fields, marking and representing the reimbursement document user information and template field connected domain correlation; based on the above connected domain correlation matrix, data enhancement is performed through perturbation processing such as random rotation, scaling, Gaussian noise and cropping, and an SSD network is used to train a reimbursement image text information calibration model for aligning and calibrating user information and template fields; Tesseract is used to recognize the optical character information in the document text box, and the recognized text is compared with the electronic document data to realize the calibration and extraction of reimbursement document image text information.
[0018] Among them, the SSD target detection network includes a backbone network and a multi-scale feature extraction network. The SSD target detection backbone network is composed of the convolutional neural network ResNet50 without the fully connected layer used for classification. The multi-scale feature extraction network is a multi-layer downsampling network. By outputting the target frame at each downsampling layer, the target frame extracted from different scales is realized. The correlation extractor consists of VGG16 and a fully connected output layer. Its input is a pair of candidate connected domain images, that is, a feature map with 2 channels. After VGG16, the feature map is flattened into a 1-dimensional feature vector and input into the fully connected layer. The fully connected layer consists of a feature mixing layer with 512 neurons and an output layer with 1 neuron. The final output of the network is the correlation value of the candidate connected domain.
[0019] The SSD network input is two images of user information and template field connected domain image extracted from the reimbursement document image after noise filtering. Both images are scaled to 256x256 size using the bilinear interpolation algorithm and min-max normalized. The SSD network output includes the coordinates of n (n represents the number of connected domains) candidate connected domains to be detected, as well as the n*n correlation matrix between the candidate connected domains.
[0020] The SSD network architecture consists of two branches: one branch is a correlation extractor, which is used to calculate the correlation coefficient between user information and the connected domain of the template field. The input is a pair of n*n connected domain images, and the output is an n*n correlation matrix M, which means the probability of matching each pair of user information and the connected domain of the template field; the other branch is connected to the output layer through a fully connected layer, and outputs the text box position in the form of center point-width and height (x, y, w, h).
[0021] In the output correlation matrix M, select the n values with the largest correlation probability value in these n columns, which are the matching alignment relationship between the n groups of user information and the template field connected domain. Cut out the rectangular frame local image of the n user information connected domain positions (x, y, w, h) from the original image of the reimbursement document, input them into the Tesseract model to recognize the optical character information, and calibrate the recognized text information with the corresponding information in the electronic document. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic diagram of the overall process of the present invention.
[0023] Figure 2 The network architecture diagram of the reimbursement image text information calibration method. DETAILED DESCRIPTION
[0024] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings. Figure 1 As shown, the present invention proposes a method for calibrating and extracting text information of reimbursement document images based on the semantic correlation registration of optical character connected domains based on SSD networks and Tesseract optical character recognition, the method including a reimbursement document image noise filtering method and a reimbursement image text information calibration method. The reimbursement document image noise filtering method performs image denoising on the original reimbursement document image, filters the noise such as seals, ink dots and wrinkles existing in the reimbursement document image, and inputs the filtered image into the reimbursement image text information calibration method. The reimbursement image text information calibration method is used for reimbursement document image format calibration, such as Figure 2 As shown, based on the SSD target detection network and correlation extractor, using template documents and reimbursement document images with labeled information, multi-task training of the user information and template field registration model in the reimbursement document image is carried out, and calibration is performed based on Tesseract optical character recognition technology and data in the financial information management system. The specific steps are as follows:
[0025] Step 1: Binarization of reimbursement document image
[0026] Extract the pixel matrix of the three color channels of the original image RGB, use the OTSU threshold segmentation algorithm to perform binarization processing, generate a binary mask matrix, filter the original image, retain the dark part of the image that may be the text of the reimbursement document, and remove the noise interference of color information such as seals. The threshold segmentation calculation formula is as follows:
[0027]
[0028] Where img(x,y) is the pixel value of the binary image at the x,y coordinates, and thresh is the threshold (set based on experience according to the actual reimbursement document image).
[0029] Step 2: Text image extraction and refinement
[0030] The EDT distance transform is used on the filtered image to generate a Euclidean distance grayscale image with the text pixels of the reimbursement document retained by the binary image as the target, where the pixel value of the grayscale image is the distance between it and the nearest target point, and the formula is as follows:
[0031] gray(p)| p=p(x,y) =min q∈T (ED(p,q))
[0032] Among them, gray(p) is any pixel in the grayscale image, T is all pixels with a value of 1 in the binary image, and ED is the Euclidean distance. After distance transformation, the OTSU threshold segmentation algorithm is used again, and the threshold is set to half the stroke width of the document print text to obtain the extracted binary image and realize text refinement.
[0033] Step 3: Image noise filtering and text adhesion separation
[0034] Perform morphological opening operation on the refined binary image to eliminate isolated, small ink dots and seal noise in the image, separate objects from thin connections such as text and text, text and table border lines, and eliminate raised parts in larger areas such as the ends of strokes.
[0035] Step 4: Extraction of connected character domains of key information
[0036] The contour extraction algorithm is used to extract the text in the above binary image, and the maximum connected domain algorithm is used to obtain the minimum circumscribed rectangle of the text connected domain. The aspect ratio threshold of the text rectangle frame is set, and the remaining non-text connected domains are filtered to obtain the key fields and user information of the reimbursement document after filtering the noise.
[0037] Step 5: Relevance mark between user information in reimbursement document image and template field connectivity domain
[0038] A training dataset for the reimbursement document image calibration model is constructed, which contains commonly used reimbursement document image data. Each document image contains template fields and user information, as well as coordinate annotations, such as document ID, date, address, amount, etc. The maximum connected domain algorithm is used to extract the user information connected domain from the reimbursement document image, and a correlation matrix is constructed based on the correspondence between user information and document fields. The correlation between the connected domain of the reimbursement document user information and the template field is marked and represented, where the correlation between the corresponding connected domain of the user information and the template field is set to 1, and the correlation of the non-corresponding connected domain is set to 0. A large number of corresponding connected domain coordinates and correlation annotations are generated as the training set of the text information calibration model.
[0039] Step 6: Training Data Enhancement
[0040] The images of reimbursement documents in the training set are subjected to data enhancement through perturbations such as random rotation, scaling, Gaussian noise, and cropping to reduce overfitting and improve the accuracy of model calibration.
[0041] Step 7: Training of reimbursement document calibration model based on SSD network
[0042] The SSD network is used to train the reimbursement image text information calibration model. The SSD network input is two images of user information and template field connected domain image extracted from the reimbursement document image after noise filtering. Both images are scaled to 256x256 size using the bilinear interpolation algorithm and min-max normalized. The SSD network output includes the coordinates of n (n represents the number of connected domains) candidate connected domains to be detected, and the n*n correlation matrix between the candidate connected domains.
[0043] The SSD network extracts n feature maps from n connected domains, and aligns and calibrates the user information and the template field by adding a correlation extractor. The SSD network architecture includes two branches: one branch is a correlation extractor, which is used to calculate the correlation coefficient between the user information and the connected domain of the template field. The input is a pair of n*n connected domain images, and an n*n correlation matrix M is output, which means the probability of matching each pair of user information and the connected domain of the template field; the other branch is connected to the output layer through a fully connected layer, and the output text box position is the center point-width and height (x, y, w, h).
[0044] In the output correlation matrix M, select the n values with the largest correlation probability value in these n columns, which is the matching alignment relationship between the n groups of user information and the template field connected domain. The calculation method of probability value matching is as follows:
[0045]
[0046] in For matching user information, the argmax function is the row index of the maximum value in a column
[0047] The candidate connected domain uses the Smooth L1 Loss loss function for regression training, the correlation matrix performs a Softmax function operation on each column, and the cross entropy loss function is used for classification training. The specific training loss function formula is as follows:
[0048]
[0049]
[0050] Where: y represents the sign function (0 or 1), if it is the same text box, it is 1, otherwise it is 0; represents the predicted candidate box; g represents the real candidate box; c represents the predicted correlation; (i, j) represents the row and column indexes of the correlation matrix.
[0051] Step 8: Extract and compare image information of reimbursement documents
[0052] The n user information connected domain positions (x, y, w, h) are cut out of rectangular frame local images from the original reimbursement document image, and the images are input into the Tesseract model to recognize the optical character information therein, and the recognized text information is calibrated with the corresponding data in the electronic document of the financial system.
Claims
1. A method for calibrating and extracting text information from reimbursement document images, characterized in that: include: 1) A noise filtering method for reimbursement document images, which is based on the image preprocessing algorithm of OTSU threshold segmentation and EDT distance transform, filters the seal, ink dots and wrinkle noise in the reimbursement document image, and uses the filtered image as the input of the image text information calibration module; 2) A method for calibrating text information of reimbursement images, including: constructing a target connected domain labeling training set, generating document image data from a variety of commonly used templates, each document image contains multiple fields and their coordinate annotations, the fields correspond to user information, including document ID, date, address, and user information, using a maximum connected domain algorithm to extract the user information connected domain from the reimbursement document image, and constructing a correlation matrix based on the correspondence between user information and document fields, marking and indicating the correlation between the connected domain of the reimbursement document user information and the template field, wherein the correlation between the connected domain corresponding to the user information and the template field is set to 1, and the correlation between the non-corresponding connected domain is set to 0, and a large number of corresponding connected domain coordinates and correlation annotations are generated as text information The training set of the calibration model is used; the images in the training set are processed by random rotation, scaling, Gaussian noise and cropping perturbations to perform data enhancement to reduce overfitting and improve the accuracy of model calibration; the SSD network is used to train the reimbursement image text information calibration model. The SSD network input is two images of user information and template field connected domain images extracted from the reimbursement document image after noise filtering. Both images are scaled to 256x256 using a bilinear interpolation algorithm and min-max normalized; the SSD network output includes the coordinates of n candidate connected domains to be detected, where n represents the number of connected domains, and the n*n correlation matrix between the candidate connected domains. The candidate connected domains are extracted using Smooth L1 Loss function is used for regression training; the SSD network extracts n feature maps from n connected domains, and aligns and calibrates the user information with the template field by adding a correlation extractor. The SSD network architecture includes two branches: one branch is a correlation extractor, which is used to calculate the correlation coefficient between the user information and the connected domain of the template field. The input is n*n connected domain images paired with each other, and an n*n correlation matrix M is output, which means the probability of matching each pair of user information and the connected domain of the template field; the other branch is connected to the output layer through a fully connected layer, and the output text box position is the center point-width and height (x, y, w, h); after the model SSD network training converges, the n values with the largest correlation probability values in the n columns are selected in the output correlation matrix M, which is the matching alignment relationship between the n groups of user information and the connected domain of the template field; the rectangular frame local images of the n user information connected domain positions (x, y, w, h) are cut out from the original image of the reimbursement document, and the optical character information is respectively input into the Tesseract model to recognize the optical character information therein, and the recognized text information is calibrated with the corresponding information in the electronic document.
2. The method for calibrating and extracting text information from an image of a reimbursement document according to claim 1, characterized in that: The reimbursement document image noise filtering method comprises: 1) Extract the pixel matrix of the three color channels of the original image RGB, use the OTSU threshold segmentation algorithm to perform binarization processing, generate a binary mask matrix, filter the original image, retain the dark text part in the image, and remove the noise interference of the seal color information; 2) Apply EDT distance transform to the filtered image, and use OTSU threshold segmentation algorithm again, setting the threshold to half the stroke width of the printed text, to obtain the extracted binary image, realize text refinement, and remove object adhesion; 3) The contour extraction algorithm is used to extract the text in the binary image, and the maximum connected domain algorithm is used to obtain the minimum circumscribed rectangle of the text connected domain, and the key fields and user information of the reimbursement document are obtained after filtering the noise.
