A contract archiving method and system
Through similarity comparison and image processing technology, automated contract archiving solves the problem of low efficiency and low accuracy of corporate document archiving, and achieves an efficient and accurate contract archiving process.
Patent Information
- Application Number
- CN202210813570.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-07-08
AI Technical Summary
Enterprises have a lot of manual processing in the document archiving process, resulting in low work efficiency, low accuracy and low automation, which can easily lead to contract disputes.
By obtaining the standard contract picture set and the contract picture set to be compared, perform similarity comparison, match and sort according to the similarity and the set threshold, and combine image cutting and rotation processing to achieve automated contract archiving.
It improves the automation and accuracy of contract archiving, reduces manual intervention, improves work efficiency, and ensures accuracy through dual determination and threshold screening.
Smart Images

Figure CN115082707B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of document management, and in particular relates to a contract archiving method and system. Background Art
[0002] Relevant departments in enterprises need to compare a large number of documents online or offline every year, and after the comparison, they need to organize, scan and archive the documents. The organized documents include but are not limited to paper documents such as contracts and other attachments to the contracts. For example, when organizing contract documents, specifically, first of all, a large amount of manpower is needed to manually scan the stamped paper documents page by page to obtain scanned copies; then the scanned copies are compared page by page with the original documents stored online to see if the scanned copies are consistent with the original documents to prevent tampering by others; finally, the corresponding PDF files are generated by screening and sorting, and the PDF documents are uploaded to the corresponding system for storage. In addition, in the process of checking whether the scanned copies are consistent with the original documents, employees are prone to visual fatigue due to staring at the screen for a long time, and it is not easy to find tampering, which leads to subsequent contract disputes.
[0003] In short, the file archiving task involves a lot of manual work, which wastes manpower, takes a long time, and file comparison is prone to errors. The work has a low degree of automation, low efficiency and low accuracy. Summary of the invention
[0004] The object of the present invention is to provide a contract archiving method and system to solve the problems of low efficiency and low accuracy of document archiving tasks in the prior art.
[0005] In order to solve the above technical problems, the technical solutions provided by the present invention and the corresponding beneficial effects of the technical solutions are as follows:
[0006] A contract archiving method of the present invention comprises the following steps:
[0007] 1) Obtain a standard contract image set and a to-be-compared contract image set, record a single contract image in the to-be-compared contract image set as a to-be-compared page image, and record a single contract image in the standard contract image set as a standard page image, and the images of each page in the standard image set have been correctly sorted according to the set page numbers;
[0008] 2) Compare each standard page image with each to-be-compared page image for similarity, and obtain the similarity between each standard page image and each to-be-compared page image;
[0009] 3) Based on the similarity obtained in step 2), each standard page image is matched with each to-be-compared page image according to the following criteria, and the page number of the to-be-compared page image is set to the page number of the standard page image that successfully matches it, and then a to-be-compared contract image set with the correct page number sorting is obtained based on the page number of each standard page image:
[0010] Criterion 1: If there is only one to-be-compared page image with the highest similarity to a certain standard page image, and the highest similarity is greater than the set threshold, it indicates that the to-be-compared page image successfully matches the standard page image;
[0011] Criterion 2: If the page image to be compared with the most similarity to multiple standard page images is the same, and all the highest similarities are greater than the set threshold, then compare the sizes of the multiple highest similarities: if there is only one maximum value among the multiple highest similarities, then it means that the page image to be compared is successfully matched with the standard page image corresponding to the maximum value; if there are multiple maximum values among the multiple similarities, then randomly select one from the standard page images corresponding to the multiple maximum values as the standard page image that successfully matches the page image to be compared;
[0012] Criterion 3: Exclude the successfully matched standard page images and the to-be-compared page images, and re-match the other standard page images and the to-be-compared page images according to the set criteria;
[0013] 4) Archive the contract image sets to be compared with the correct page number sorting.
[0014] The beneficial effects of the above technical solution are as follows: the present invention uses a correctly sorted standard contract picture set to perform a similarity comparison with a to-be-sorted contract picture set to be compared, and then determines the page number of the to-be-compared page picture in the to-be-compared contract picture set by double determination based on the maximum similarity value between all to-be-compared contract pages and the standard contract page and a set threshold, thereby realizing the page number sorting of the to-be-compared contract picture set. The double determination has a high accuracy rate, and since there is no need for manual comparison, the workload is small, the archiving work efficiency is high, and it is an automated similarity comparison, which further ensures the accuracy rate. On the other hand, the present invention only retains data with highly similar similarities by setting a set threshold value for similarity, avoids storing some unnecessary dirty data, and reduces the burden of subsequent data processing.
[0015] Furthermore, before archiving the to-be-compared contract image set with the correct page number sorting in step 4), it is necessary to regularize the direction of the to-be-compared page images; each standard page image in the standard contract image set has been regularized to the positive direction; the following method is used to regularize the to-be-compared page images:
[0016] 401) for a pair of standard page images and a page image to be compared having the same page number, cutting the standard page image according to set requirements to cut out a standard cutting image containing identification features under a positive viewing angle of the standard page image;
[0017] 402) the image of the page to be compared at four different rotation angles of 0°, 90°, 180° and 270° is also cut according to the set requirements to obtain four cut images to be compared;
[0018] 403) performing similarity comparison between the standard cutting image and the four cutting images to be compared, calculating each similarity value and obtaining the maximum similarity value;
[0019] 404) using the cutting angle corresponding to the maximum similarity value as the rotation angle of the page image to be compared;
[0020] 405) Rotate the image of the page to be compared according to the rotation angle;
[0021] 406) For the remaining standard page images and to-be-compared page images with the same page number, they are all processed according to the method of steps 401) to 405) to rotate the remaining to-be-compared page images to obtain a rotated and regularized to-be-compared page image set.
[0022] The beneficial effects of the above technical solution are as follows: the present invention cuts out the image part containing the identification feature in the standard contract page in advance according to the set requirements, and then cuts the contract page to be compared with the same page number as the standard contract page according to four cutting angles of 0°, 90°, 180° and 270° with the positive direction, and obtains four cut contract images to be compared, and finally compares the image part containing the identification feature with the four cut contract images to obtain the cutting angle corresponding to the maximum similarity value, and the cutting angle is the angle at which the image needs to be rotated, and the contract page to be compared is rotated according to the cutting angle, so that the contract page to be compared is regularized in the positive direction for easy reading. Therefore, the present invention further improves the degree of automation and further improves work efficiency.
[0023] Furthermore, in step 3), if the highest similarity is not greater than a set threshold, a no-pairing prompt message of the corresponding standard page image is given; the no-pairing prompt message includes the page number of the corresponding standard page image.
[0024] The beneficial effect of the above technical solution is: under the condition that the highest similarity obtained is not greater than the set threshold, it indicates that the standard page image has no matching page image to be compared, and a no-match prompt message is given at this time to find out whether the contract page to be compared corresponding to the standard page image has been tampered with or omitted from being added to the contract to be compared. Thus, the present invention realizes the problem of automatically judging the consistency between the standard contract image set and the contract image set to be compared, and at the same time, due to the use of automated comparison, the work efficiency is high and the double screening accuracy after the set threshold and the maximum threshold is high.
[0025] Furthermore, the set threshold value ranges from 60% to 80%.
[0026] Furthermore, in order to further improve the accuracy, before step 1), it is necessary to judge the clarity of the to-be-compared page images in the to-be-compared page image set; if the clarity does not meet the requirement, a clarity prompt message needs to be issued to prompt the to-be-compared page image to be replaced with one with higher clarity.
[0027] Furthermore, in order to further improve the accuracy, the evaluation method of the clarity judgment includes at least one of the Brenner gradient method, the Tenegrad gradient method, the laplacian gradient method, the variance method and the energy gradient method.
[0028] Furthermore, before step 1), the to-be-compared page images in the to-be-compared page image set need to be subjected to image enhancement processing, wherein the image enhancement processing includes adjusting at least one parameter of the image's contrast, brightness, color saturation, hue and sharpness.
[0029] Furthermore, the setting requirement is to cut the image in a ratio of one quarter.
[0030] A contract archiving system of the present invention includes a processor, a memory and an internal bus. The processor and the memory communicate and exchange data with each other through the internal bus. The processor executes a computer program stored in the memory to implement a contract archiving method of the present invention and achieve the same beneficial effects as the contract archiving method.
[0031] Furthermore, in order to facilitate observation of the system execution content, a UI display module is also included, and the UI display module is used to visually display various prompt information and support interactive operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a flow chart of clarity discrimination and image enhancement operation in an embodiment of a contract archiving method of the present invention;
[0033] Figure 2 It is a flow chart of the operation of sorting contracts to be compared in an embodiment of a contract archiving method of the present invention;
[0034] Figure 3 It is a flowchart of a rotation operation of a contract to be compared in an embodiment of a contract archiving method of the present invention;
[0035] Figure 4 It is a schematic diagram of a contract page to be compared of a contract to be compared in an embodiment of a contract archiving method of the present invention, which is cut upside down by 180°;
[0036] Figure 5 It is a schematic diagram of a contract page to be compared of a contract to be compared in an embodiment of a contract archiving method of the present invention, which is cut upside down by 270°;
[0037] Figure 6 It is a schematic diagram of a contract page to be compared of a contract to be compared in an embodiment of a contract archiving method of the present invention, which is cut upside down by 90 degrees;
[0038] Figure 7 It is a structural schematic diagram of a contract filing system in an embodiment of a contract filing system of the present invention;
[0039] Figure 8 It is a schematic diagram of the main interface of the UI display module in an embodiment of a contract archiving system of the present invention;
[0040] Fig. 9 It is a schematic diagram of comparison results of a display example of a UI display module in an embodiment of a contract archiving system of the present invention;
[0041] Fig.10 It is a schematic diagram of an archived picture viewing interface in a UI display module in an embodiment of a contract archiving system of the present invention;
[0042] Fig.11 It is a schematic diagram of a picture comparison preview interface in a UI display module in an embodiment of a contract archiving system of the present invention;
[0043] Fig.12 It is a schematic diagram of a picture archiving failure viewing interface in a UI display module in an embodiment of a contract archiving system of the present invention;
[0044] Fig.13 It is a flowchart of the processing steps of the picture clarity evaluation function in an embodiment of a contract archiving method of the present invention;
[0045] Fig.14 It is a processing flow chart of a picture definition processing algorithm in an embodiment of a contract archiving method of the present invention;
[0046] Fig.15 It is a schematic diagram of a coordinate system in an image enhancement calculation principle in an embodiment of a contract filing method of the present invention;
[0047] Fig.16 It is a flow chart of image enhancement calculation in an embodiment of a contract archiving method of the present invention;
[0048] Fig.17 It is an OCR recognition flow chart in an embodiment of a contract archiving method of the present invention;
[0049] Fig.18 It is a schematic diagram of coordinates of two vectors in a cosine similarity calculation method used in an embodiment of a contract archiving method of the present invention. DETAILED DESCRIPTION
[0050] The object of the present invention is to provide a contract archiving method and system which has high automation, high accuracy and helps to improve work efficiency.
[0051] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0052] A contract archiving method embodiment:
[0053] The present invention is described in detail below in conjunction with the method steps, and a contract document is used as an example in this embodiment:
[0054] Step 1: Get the standard contract picture set and the contract picture set to be compared, record the single contract picture in the contract picture set to be compared as the page picture to be compared, and record the single contract picture in the standard contract picture set as the standard page picture. The pictures on each page in the standard picture set have been correctly sorted according to the set page numbers.
[0055] All contracts to be compared are collected and organized by taking photos with a mobile phone, using a scanner or other instruments; the server receives all the uploaded images of the contracts to be compared. Specifically, taking a scanner as an example, first place the paper contract document on the scanner, scan the paper contract document, and generate an unordered scanner image. Place the documents to be scanned on the scanner for scanning. The placement of the documents on the scanner is manually operated, so it is inevitable that the documents are misplaced and reversed. While scanning the images, the scanner synchronizes the scan results to the corresponding server (hereinafter referred to as the unordered image server) in real time, and performs a preview screen operation to find out whether the total number of successfully scanned sheets is consistent with the paper file. Rescanning or incremental scanning can be performed according to the actual situation. The unordered images on the unordered image server are called the contract image set to be compared.
[0056] The electronic attachment files (such as the following word, pdf and png files) are cropped into images according to the actual situation of the document and the page number is added to the name of the cropped image. The electronic files are converted into ordered images and then uploaded to the corresponding server (hereinafter collectively referred to as the ordered image server). The images on the ordered image server corresponding to the electronic files are called the standard contract image set.
[0057] Step 2: Determine the clarity of the images in the image set of the page to be compared; if the clarity does not meet the requirement, issue a clarity prompt message, and perform image enhancement on the image of the page to be compared, thereby improving the comparison accuracy.
[0058] Combine the following Figure 1 Explanation of clarity judgment and image enhancement:
[0059] Step ①: Perform clarity judgment on all images in the contract image set to be compared, and filter out clear and unclear images.
[0060] Image clarity is an important indicator for measuring image quality. For cameras, they generally work in a mode without a reference image, so focus control is required when taking pictures. If the focus is not accurate, the image will become blurry and unclear. When the camera focuses, it controls the distance between the lens and the CCD through some clarity evaluation indicators to make the image clear. Generally, there is an adjustment process when focusing, and the image goes from blurry to clear, then to blurry again, determine the clarity peak, and finally reach the clearest position.
[0061] Common image clarity evaluation is generally based on gradient methods. The present invention will use the following five simple evaluation indicators to evaluate clarity, namely Brenner gradient method, Tenegrad gradient method, laplacian gradient method, variance method, and energy gradient method.
[0062] In actual applications, the most effective algorithms among the above methods are selected and used according to the results of historical batch image runs of the corresponding business (all or some of them can be used), and there is no order in their use.
[0063] ① An algorithm for clarity evaluation:
[0064] The output result of each algorithm is a numerical value. The first way to judge whether it is clear is to sum up all the algorithm result values in actual application. The larger the sum result S is, the stronger the clarity is. Then, the clarity threshold is marked according to the historical batch running results. The image that exceeds the threshold is clear, and the image that does not exceed the threshold is unclear.
[0065]
[0066] Among them, n represents the total number of algorithms, i represents the i-th algorithm, and V represents the clarity value.
[0067] if If the value is clear, it is not clear otherwise, where v limit Indicates the threshold for summing all algorithms.
[0068] ②The second clarity evaluation algorithm:
[0069] The second way to judge whether it is clear is to divide the threshold of each algorithm separately, and then judge the clarity according to the number of algorithms that exceed the threshold. At the same time, weight values can also be assigned to the algorithms used respectively (the setting of weights is limited according to the effect of the algorithm in the picture application).
[0070] v i(i: the i-th algorithm, v: clarity value), v limit (clarity threshold), if r i =v i >v limit , then it is clear r i =1, otherwise it is not clear i =0, (w: weight value, i: the i-th algorithm, r: the result of clarity 1 or 0), if (More than half means that it can also be flexibly adjusted according to actual business needs), then it is clear, otherwise it is unclear.
[0071] The specific steps to implement the image clarity evaluation function are as follows: Fig.13 As shown, it includes the picture taken by the front end, which can be jpg, bmp and png. The back end obtains the picture taken by the photo and makes a judgment and evaluation based on the clarity evaluation algorithm. If the clarity reaches the threshold, it can enter the subsequent OCR recognition. If the clarity is lower than the threshold, it is necessary to take a new photo. The implementation process of the clarity evaluation algorithm is as follows Fig.14 As shown, it includes detecting the image area, setting the image size, setting the image grayscale, and using the Tenegrad gradient function, the Brenner gradient function, the laplacian gradient function, and the variance function for blur detection without images.
[0072] The purpose of setting the image to grayscale is to avoid banding distortion. Grayscale images only need one byte to store the grayscale value (also known as intensity value, brightness value) for each pixel, and the grayscale range is 0-255. Grayscale images are usually obtained by measuring the brightness of each pixel in a single electromagnetic spectrum (such as visible light). Grayscale images used for display are usually saved with a nonlinear scale of 8 bits per sampled pixel, so that there can be 256 levels of grayscale. This accuracy is just enough to avoid visible banding distortion and is very easy to program. If color is included, the feature quantity and calculation amount increase exponentially. For example, a point, in grayscale, has only 256 dimensions, but if RGB color is included, it is more than 16 million dimensions. Then combine them with each other, or find the gradient. It can be imagined that the amount of data is very large, so the amount of calculation is huge, so the dimension reduction (grayscale) is used for calculation first.
[0073] The following is an introduction to the Brenner gradient function: The Brenner gradient function is the simplest gradient evaluation function. It simply calculates the square of the grayscale difference between two adjacent pixels. The function is defined as follows:
[0074] D(f)=∑ y ∑ x |f(x+2,y)-f(x,y)| 2
[0075] Where: f(x, y) represents the grayscale value of the pixel (x, y) corresponding to image f, and D(f) is the result of image clarity calculation.
[0076] The following is an introduction to the Tenengrad gradient function:
[0077] The Tenengrad gradient function uses the Sobel operator to extract the gradient values in the horizontal and vertical directions respectively. In image processing, it is generally believed that a well-focused image has sharper edges and therefore has a larger gradient function value. The image clarity based on the Tenengrad gradient function is defined as follows:
[0078] D(f)=∑ y ∑ x |G(x,y)| (G(x,y)>T)
[0079] Among them, G(x, y) is in the following form:
[0080]
[0081] Where: T is the given edge detection threshold, Gx and Gy are the convolution of the Sobel horizontal and vertical edge detection operators at the pixel point (x, y), respectively. It is recommended to use the Sobel operator templates shown in Table 1-1 and Table 1-2 to detect edges:
[0082]
[0083] The calculation formulas for Gx and Gy are as follows:
[0084]
[0085] The approximate horizontal and vertical gradients of each pixel of the image can be combined using the following formula to calculate the magnitude of the gradient.
[0086]
[0087] The gradient direction can then be calculated using the following formula.
[0088]
[0089] In the above example, if the angle θ is equal to zero, it means that the image has a vertical edge at that location, and the left side is darker than the right side.
[0090] The following is an explanation of the Laplacian gradient function:
[0091] The Laplacian gradient function is basically the same as the Tenengrad gradient function. The Sobel operator can be replaced by the Laplacian operator. The operator is defined as follows:
[0092]
[0093] Therefore, the definition of image clarity based on the Laplacian gradient function is as follows:
[0094] D(f)=∑ y ∑ x |G(x,y)| (G(x,y)>T)
[0095] Where G(x, y) is the convolution of the Laplacian operator at the pixel point (x, y).
[0096] The following is an introduction to the SMD2 (grayscale variance product) function:
[0097] The grayscale difference evaluation function has good calculation performance, but its disadvantage is also obvious, that is, the sensitivity is not high near the focus, that is, the function is too flat near the extreme point, which makes it difficult to improve the focusing accuracy. In the article "A fast and high-sensitivity focusing evaluation function", a new evaluation function is proposed, called the grayscale variance product method, that is, the two grayscale differences in each pixel area are multiplied and then accumulated pixel by pixel. The function is defined as follows:
[0098] D(f)=∑ y ∑ x |f(x,y)-f(x+1,y)|*|f(x,y)-f(x,y+1)|
[0099] Step ②: For unclear images, relevant information of the unclear images will be sent out in time to facilitate uploading new images. That is, according to the clarity prompt information, the contract page to be compared is replaced with the corresponding page image to be compared with higher clarity.
[0100] Step 3: Perform image enhancement on images that pass the definition test, laying a foundation for improving the recognition accuracy of subsequent OCR recognition.
[0101] Specifically, image enhancement mainly involves fine-tuning contrast, color saturation, hue, and sharpness to achieve an enhanced image clarity effect.
[0102] 1. Contrast: The brightness of a white screen (brightest) divided by the brightness of a black screen (darkest);
[0103] Contrast refers to the measurement of the different brightness levels between the brightest white and the darkest black in the light and dark areas of an image. The larger the difference range, the greater the contrast, and the smaller the difference range, the smaller the contrast. A good contrast ratio of 120:1 can easily display vivid and rich colors. When the contrast ratio is as high as 300:1, it can support all levels of color. However, the contrast ratio suffers from the same dilemma as brightness. There is no effective and fair standard to measure the contrast ratio today, so the best way to identify it is to rely on the user's eyes.
[0104] 2. Saturation: Chroma divided by brightness, refers to the vividness of the color, also known as the purity of the color;
[0105] Saturation refers to the vividness of a color, also known as the purity of a color. Saturation depends on the ratio of the color component to the achromatic component (gray) in the color. The larger the color component, the greater the saturation; the larger the achromatic component, the lower the saturation. Pure colors are highly saturated, such as bright red and bright green. Colors mixed with white, gray or other tones are unsaturated colors, such as crimson purple, pink, yellow-brown, etc. Completely unsaturated colors have no hue at all, such as various grays between black and white.
[0106] 3. Hue: Adjusting in the negative direction will make red appear, while adjusting in the positive direction will increase yellow. Suitable for fine-tuning skin-colored objects;
[0107] Tone does not refer to the nature of color, but a general evaluation of the overall color of a painting. Tone refers to the basic tendency of the color appearance of a work. Among the three elements of lightness, purity (saturation), and hue, a certain factor plays a leading role, which we call a certain tone. Although a painting uses a variety of colors, there is an overall tendency to be blue or red, warm or cold, etc. This color tendency is the tone of a painting. The tone of a work can usually be defined from four aspects: hue, lightness, coldness and warmth, and purity.
[0108] 4. Sharpness: It is an indicator that reflects the clarity of the image plane and the sharpness of the image edge;
[0109] The adjustment of sharpness is two-way. On the one hand, increasing the sharpness can indeed make the picture clearer and more vivid. On the other hand, it will also lead to a decrease in image quality and easily cause photo distortion. It is necessary to be moderate when adjusting.
[0110] The following is an introduction to the principles of image enhancement:
[0111] For an image, such as Fig.15As shown, we can put it into the coordinate system, where the upper left fixed point of the image is taken as the origin of the coordinate system, the x-axis is rightward, the same as the x-axis of the Cartesian coordinate system; the y-axis is downward, opposite to the y-axis of the Cartesian coordinate system. In this way, we can define an image as a two-dimensional function f(x, y), and each pixel in the image can be represented by (x, y) coordinates, and the amplitude f at any pair of spatial coordinates (x, y) is called the intensity or grayscale of the image at that point.
[0112] The image can be represented by a function f(x, y). The object meaning actually comes from the illumination of the object by the illumination source. The function f(x, y) can be represented by two components:
[0113] ① The total amount of light incident on the observed scene
[0114] ②The total amount of light reflected by objects in the scene
[0115] The above two components are called incident component and reflected component, respectively, expressed as i(x, y) and r(x, y), and we have:
[0116] f(x, y) = i(x, y) * r(x, y)
[0117] Where 0 <i(x,y)<∞,0<r(x,y)<1。
[0118] Therefore, the grayscale value or intensity value of the image is determined by the incident component and the reflected component. The property of i(x, y) depends on the illumination source, while the property of r(x, y) depends on the characteristics of the imaging object. The formula only gives the general value range of i(x, y) and r(x, y). Naturally, for different illumination sources and imaging objects, i(x, y) and r(x, y) will have different values. Therefore, the grayscale value range of the digital image is:
[0119] L min <f<L max
[0120] L min =i min r min
[0121] L max =i max r max
[0122] Therefore, the interval [L min , L max ] is called the grayscale of the image. In practice, the interval is often set to [0, L-1], where f=0 is black and f=L-1 is white in the grayscale. All intermediate values are grayscale tones ranging from black to white, and the grayscale difference between the highest and lowest grayscale levels of the image is the contrast.
[0123] Brightness calculation: Image brightness is generally understood as the brightness of the image. For a digital image, f(x, y) = i(x, y) * r(x, y). If the grayscale value is between [0, 255], the closer the f value is to 0, the lower the brightness; the closer the f value is to 255, the higher the brightness. It should be noted that when the brightness is increased, the saturation, contrast and clarity of the image will be affected while changing the intensity of the image. That is, the saturation, contrast and clarity of the image will be reduced at this time. The reason is that excessive increase in brightness causes the shadow to catch up with the highlight. Because the maximum grayscale value is fixed, the minimum grayscale value almost catches up with the maximum grayscale value, thus affecting the saturation, contrast and clarity of the image.
[0124] The following is an explanation of contrast and saturation:
[0125] (1) Saturation refers to the number of color types in an image. The grayscale level of the image mentioned above is [L min , L max ], then in L min , L max The more intermediate values there are, the more types of colors the image has, the higher the saturation is, and the image will look brighter. Adjusting the saturation can correct overexposed or underexposed images and make the image look more natural.
[0126] (2) Contrast As mentioned above, it refers to the difference between the dark and bright levels of an image, that is, the difference between the maximum grayscale level and the minimum grayscale level of the image.
[0127] At the same time, the contrast is increased on the right side of the white and red spoke images. As a result, it can be seen that as the contrast increases, the white or red spokes on the right side become brighter, the background becomes darker, and the image looks clearer.
[0128] Sharpening: Image sharpening is to compensate for the contour of the image, enhance the edge of the image and the grayscale jump part, and make the image clear. Image sharpening is often used in actual image processing, because the edge information of the image will be lost during image smoothing and image filtering. Image sharpening can enhance the edges and contours of the image.
[0129] By adjusting the white and red spokes of the image, it is found that the brightness, contrast and saturation of the thin spokes close to the center have been significantly improved, but there is no obvious change on the outside. This is because image sharpening will enhance the edge data more, so the impact is more obvious.
[0130] Specific as Fig.16As shown, the original image is adjusted in brightness, hue, saturation and sharpness to obtain an image after image enhancement. The specific adjustment method can be adjusted by setting the parameters for adjusting brightness, hue, saturation and sharpness in the visualization window.
[0131] Step 3: Sort the contracts to be compared. There are many ways to sort the contracts to be compared. Figure 2 The flowchart of the contract is used to explain the order of contracts in detail:
[0132] The first way to sort the contracts to be compared is:
[0133] 301) performing a similarity comparison between a standard page image and each to-be-compared page image, specifically performing a text similarity comparison between a standard page image and each to-be-compared page image using OCR text recognition technology to obtain a similarity set containing multiple corresponding similarity values.
[0134] 302) Determine whether the similarity value in the similarity set is greater than the set threshold. If the similarity value is greater than the set threshold, the similarity threshold is retained. If the similarity value is not greater than the set threshold, it is removed from the similarity set. The setting of the threshold is mainly based on the types of commonly used contracts in actual business. In the early stage, the value range can be set to 60%-80%, and then flexibly adjusted through multiple runs of actual business. The purpose of setting the threshold here is to reduce the burden of the reserved set with similarity exceeding the threshold in the later stage to avoid storing some unnecessary dirty data.
[0135] 303) Obtain the maximum similarity value in the similarity set obtained in step 302), and assign the page number of the standard page image to the to-be-compared page image corresponding to the maximum similarity value as the page number, that is, the standard page image matches the to-be-compared page image corresponding to the maximum similarity value. After setting a threshold for screening, if the similarity set is empty, a no-match prompt message of the corresponding standard page image is given; the no-match prompt message includes the page number of the corresponding standard page image. This situation may be that the to-be-compared page image has been tampered with or lost.
[0136] 304) Perform the operations from step 301) to step 303) on each remaining standard page image in the standard contract image set, so that each comparison contract page image is assigned a page number, thereby obtaining a correctly sorted comparison contract image set.
[0137] The second way to sort the contracts to be compared is:
[0138] 311) Performing a similarity comparison between a standard page image and each to-be-compared page image, specifically, performing a text similarity comparison between the standard page image and each to-be-compared page image using OCR text recognition technology to obtain corresponding similarity values, and obtaining the maximum value among the similarity values greater than a set threshold.
[0139] After screening by the set threshold, if there is no similarity value greater than the set threshold, a no-match prompt message of the corresponding standard page image is given; the no-match prompt message includes the page number of the corresponding standard page image. This situation may be that the page image to be compared has been tampered with or lost.
[0140] 312) The page number of the standard page image is assigned to the to-be-compared page image corresponding to the maximum similarity value as the page number, that is, the standard page image matches the to-be-compared page image corresponding to the maximum similarity value.
[0141] 313) Perform the operations from step 311) to step 312) on each remaining standard page image in the standard contract image set, so that each comparison contract page image is set with a page number, thereby obtaining a correctly sorted set of contract images to be compared.
[0142] In the first and second sorting methods when sorting the contracts to be compared, if multiple standard page images match the same page image to be compared, the same page image to be compared is recorded as the conflict page image, and the page number of the standard page image with the highest similarity to the conflict page image is selected from the multiple standard page images as the page number of the conflict page image, and the remaining standard page images in the multiple standard page images are re-operated with each page of the page image to be compared except the conflict page image in the set of contract images to be compared according to the method of steps 301) to 304) or steps 311) to 313). For example, after comparison, standard page image a 1 After comparing with each page in the contract image set to be compared, the standard page image a is obtained 1 With the page image b to be compared 3 The similarity value is the highest, which is 98.5%; standard page image a 2 After comparing with each page in the contract image set to be compared, the standard page image a is obtained. 2 With the page image b to be compared 3 The similarity value is also the highest, which is 98.7%. Since 98.5% < 98.7%, the standard page image a with a high similarity value is 2 The page number n is used as the page image b to be compared 3 The page number.
[0143] If multiple pages of standard page images match the same page of the page image to be compared and the corresponding multiple similarity values are all equal, the same page image to be compared is recorded as the conflict page image, and the page number of a page of the standard page image is randomly selected from the multiple pages of standard page images and assigned as the page number of the conflict page image; the remaining pictures in the multiple pages of standard page images are re-operated with each page of the page image to be compared except the conflict page image in the contract image set to be compared according to the method of steps 301) to 304) or steps 311) to 313) to obtain the contract image set to be compared with the correct page number sorting. For example, after comparison, standard page image a 3 After comparing with each page in the contract image set to be compared, the standard page image a is obtained 3 With the page image b to be compared 5 The similarity value is the highest, which is 98.5%; standard page image a 4 After comparing with each page in the contract image set to be compared, the standard page image a is obtained. 4 With the page image b to be compared 5 The similarity value is also the highest, and the similarity value is also 98.5%. 98.5% = 98.5%. Then in the standard page picture a 3 and standard page image a 4 Randomly select one of the pictures, for example, select the standard page picture a 4 , set the standard page image a 4 The page number n is used as the page image b to be compared 5 Page number, remaining standard page picture a 3 Re-compare the contract pictures to be compared, except for the pictures b on the page to be compared 5 For each page to be compared, the method of steps 301) to 304) or steps 311) to 313) is performed.
[0144] The third sorting method for sorting the contracts to be compared: 321) performing a similarity comparison between a standard page image in the standard contract image set and each page image to be compared in the contract image set to be compared, so as to obtain a similarity value group corresponding to the standard page image, and obtain a similarity value group corresponding to each standard page image in the standard contract image set;
[0145] 322) obtaining a similarity value greater than a set threshold value in a similarity value group corresponding to a standard page image, obtaining multiple similarity values, which are recorded as qualified similarity value groups; obtaining a qualified similarity value group corresponding to each standard page image;
[0146] 323) For a standard page image, a maximum similarity value is obtained in the corresponding qualified similarity value group, recorded as the best similarity value, and the to-be-compared page image corresponding to the best similarity value is obtained, and the to-be-compared page image corresponding to the best similarity value of each standard page image is obtained;
[0147] 324) For a page image to be compared:
[0148] If there is only one standard page image with a best similarity value corresponding to the page image to be compared, the page number of the standard page image is used as the page number of the page image to be compared;
[0149] If there are multiple standard page images with the best similarity values corresponding to the page image to be compared and the best similarity values of the multiple standard page images are not equal, then the page number of the standard page image with the highest similarity to the page image to be compared is selected from the multiple standard page images as the page number of the page image to be compared;
[0150] If the best similarity values of multiple standard page images correspond to the page image to be compared, and there are at least two with the highest similarity values among the best similarity values of the multiple standard page images, then the page number of a standard page image is randomly selected from the at least two standard page images with the highest similarity values and assigned as the page number of the page image to be compared;
[0151] The remaining standard page images among the multiple standard page images obtain a similarity value that is less than the best similarity value in the corresponding qualified similarity value group as the best similarity value, and the method of step 324) is used to operate until the page number is successfully set for the page image to be compared or there is no usable similarity value in the qualified similarity value group.
[0152] 325) to obtain a set of contract images to be compared with the correct page number sorting.
[0153] If no matching page image is found after comparing all the above situations, a no-match prompt message will be given to the standard page image.
[0154] Step 4: Adjust the direction of the images on the pages to be compared. Figure 3 To explain the rotation function: the positive direction is Figure 4 The direction from a to b is the forward direction of reading and viewing.
[0155] Step ①: The third step has completed the one-to-one correspondence between the contract image set to be compared and the page number of the standard contract image set, so the page images to be compared and the standard page images can be cut according to a certain ratio of a single page (it can be temporarily set to 1 / 4, or it can be adjusted according to later use, there is no specific requirement). The direction of the standard page image itself is positive, so single-page cutting only needs to be cut at 0 degrees to obtain the image part containing the distinguishing features. There are four cutting directions (0 degrees, 90 degrees, 180 degrees, 270 degrees) for the contract page images to be compared. In this embodiment, the page images to be compared can be rotated according to different cutting angles for cutting, such as Figure 4 As shown, the cutting line remains unchanged, and only the image of the page to be compared needs to be rotated; the cutting direction (cutting line) can also be rotated according to different cutting angles, such as Figure 5 As shown, the angle of the picture remains unchanged, and only the direction of the cutting line needs to be rotated to perform the cutting.
[0156] Steps ② and ③: Perform text recognition on the 1 / 4 portion of the cut standard page image and the 1 / 4 portion of the page image to be compared through OCR, calculate the similarity of the recognized texts, and select the angle of the cutting direction of the 1 / 4 contract to be compared with the highest similarity;
[0157] Steps ④ and ⑤: According to the cutting direction angle obtained in step ③, the image of the page to be compared can be rotated counterclockwise by the cutting direction angle to complete the rotation correction, and finally the image of the page to be compared in the correct direction can be obtained.
[0158] The specific image rotation is described below with reference to the accompanying drawings:
[0159] Image A is the correct image in the process, and image B is the image to be rotated. Image A is the electronic file in the process (the standard page image in the standard contract image set). The electronic file in the process is manually uploaded by the business personnel and manually rotated to the positive direction. Figure 4 The direction from a to b needs to be reviewed by layers of personnel, so the final version of image A must be the original without any problems. Image B is the page to be compared in the contract image set to be compared, and needs to be compared and verified with the original image A. After confirming that A and B are completely consistent and there are no problems with the content, image B is converted to be consistent with image A and archived, and stored in the specified path as an archive.
[0160] like Figure 4 As shown in the figure, image B is completely inverted 180 degrees and needs to be rotated 180 degrees to be consistent with image A. Image A and image B are cropped according to the "cutting line" respectively. After the images A and B are cut, OCR recognition is performed. 1 The content of image recognition is "xxx project", B 1The image recognition content is empty. Similarly, A and B are compared for image cutting and recognition. Finally, B N and A 1 The content of image recognition is consistent, N∈(1,4). Finally, it can be confirmed that image B is 180 degrees upside down, so it is the correct image after being rotated 180 degrees.
[0161] like Figure 5 As shown in the figure, image B is completely inverted by 270 degrees and needs to be rotated 270 degrees to be consistent with image A. Image A and image B are cropped according to the "cutting line" respectively. After the images A and B are cut, OCR recognition is performed. 1 The content of image recognition is "xxx project", B 1 The image recognition content is empty. Similarly, A and B are compared for image cutting and recognition. Finally, B N and A 1 The contents of image recognition are consistent, and it can be confirmed that image B is inverted by 270 degrees, so it is the correct image after being rotated 270 degrees.
[0162] like Figure 6 As shown in the figure, image B is completely inverted 90 degrees and needs to be rotated 90 degrees to be consistent with image A. Image A and image B are cropped according to the "cutting line" respectively. After the images A and B are cut, OCR recognition is performed on the images. 1 The content of image recognition is "xxx project", B 1 The image recognition content is empty. Similarly, A and B are compared for image cutting and recognition. Finally, B N and A 1 The contents of image recognition are consistent, and it can be confirmed that image B is inverted by 90 degrees, so it is the correct image after being rotated 90 degrees.
[0163] In other embodiments, the image may not be cut according to the 1 / 4 ratio, but may be cut according to the specific length and width data, for example, the length is 4 cm and the width is 14 cm. Figure 4-6 The cut is shown at one end, but it can also be cut in the middle or other parts of the picture.
[0164] The following is an explanation of OCR text recognition:
[0165] Compare the content similarity based on the OCR recognition results and reorder the disordered scanner images;
[0166] like Fig.17As shown, the OCR recognition results are stored in scanner_list and contact_list, and the text similarity method is used to calculate the highest similarity value between each other, and then the unordered pictures are renamed in the correct order of the ordered pictures. Finally, all the unordered pictures in scanner_list are renamed in the correct order.
[0167] The text similarity mainly uses two algorithms: cosine similarity and edit distance.
[0168] Cosine similarity uses the cosine value of the angle between two vectors in the vector space to measure the similarity between two texts. Compared with the distance metric, cosine similarity pays more attention to the difference in direction between the two vectors. In general, after using Embedding to obtain the vector representation of the two texts, cosine similarity can be used to calculate the similarity between the two texts.
[0169] The calculation formula is as follows:
[0170]
[0171] Among them, X represents the horizontal coordinate, Y represents the vertical coordinate, i represents the i-th vector, n represents the total number of vectors, and θ represents the angle between vectors.
[0172] The specific derivation process of the above calculation formula is combined with Fig.18 For detailed explanation:
[0173] Cosine similarity formula:
[0174]
[0175] The results derived from the coordinate axes are:
[0176]
[0177] The above calculation results are the results of 2-dimensional vector calculation. If it is an n-dimensional vector, the calculation result is:
[0178]
[0179] Edit distance is mainly used to calculate the similarity between two strings, and its definition is as follows:
[0180] Suppose there are strings A and B, B is a pattern string, and now given the following operations: delete a character from a string; insert a character from a string; replace a character from a string. Through the above three operations, the minimum number of operations required to edit string A into pattern string B is called the shortest edit distance between A and B, denoted as ED(A,B).
[0181] The algorithm for solving the shortest edit distance is described as follows:
[0182] Use a two-dimensional array ED[i][j] to represent the minimum number of operations required to edit the first i characters of string A into the first j characters of string B. Then the recursive formula of ED[i][j] is:
[0183] ⑴ED[i][0]=i, ED[0][j]=j, where 0≤i≤A.len, 0≤j≤B.len;
[0184] ⑵If A[i]=B[j], then ED[i][j]=ED[i-1][j-1];
[0185] ⑶If A[i]≠B[j], then ED[i][j]=min(ED[i-1][j-1],ED[i][j-1],ED[i-1][j])+1.
[0186] The smaller the edit distance, the more similar the two strings are. Conversely, the less similar they are.
[0187] Step 5: Archive the contract set to be compared after page sorting and rotation, generate a PDF electronic document for the contract image set to be compared, and store it in the specified path as an archive.
[0188] In summary, the present invention can quickly and accurately sort the contract image set to be compared by performing similarity comparison through OCR, and then use the cut image containing distinguishing features to judge the rotation angle of the page image to be compared, and then rotate the page image to be compared to make it in the positive direction. Since there is no need to rotate the image manually, the degree of automation is further improved, and the work efficiency is correspondingly improved. The accuracy of the archived document sorting is improved by setting multiple screenings of thresholds and maximum thresholds. Finally, the contract image set to be compared that is correctly sorted and in the positive direction is converted into a PDF document for archiving.
[0189] A contract archiving system embodiment:
[0190] A contract archiving system embodiment of the present invention is as follows: Figure 7 As shown, it includes a memory, a processor and an internal bus, and the processor and the memory communicate and exchange data with each other through the internal bus. The memory includes at least one software function module stored in the memory, and the processor executes various functional applications and data processing by running the software program and module stored in the memory, thereby realizing a contract archiving method introduced in the method embodiment of the present invention.
[0191] The processor may be a microprocessor MCU, a programmable logic device FPGA or other processing device.
[0192] The memory may be various memories that use electrical energy to store information, such as RAM, ROM, etc.; it may also be various memories that use magnetic energy to store information, such as hard disks, floppy disks, magnetic tapes, magnetic core memories, bubble memories, USB flash drives, etc.; it may also be various memories that use optical methods to store information, such as CDs, DVDs, etc.; of course, it may also be other types of memories, such as quantum memories, graphene memories, etc.
[0193] In order to facilitate the observation of the system execution content, a UI display module is also included, which is used to visually display various prompt information and support interactive operations. Fig.10 As shown, the UI display module also includes an archived image viewing interface; Fig.11 As shown, the UI display module also includes a picture comparison preview interface; Fig.12 As shown, the UI display module also includes an archiving failure picture viewing interface, and the UI display module also includes a part for adjusting the brightness, hue, saturation and sharpness of the picture.
[0194] Finally, the system is explained based on specific examples. Figure 8 The following is a schematic diagram of the main interface of the UI display module. There are 5 images of contracts to be compared uploaded by the scanner, and 2 standardized contracts. The results after the intelligent comparison of this system are as follows: Fig. 9 The final result of the test is that the first archive is successful and the 180-degree rotated image is corrected, while the second archive fails because the standardized contract is not matched in the image to be compared.
Claims
1. A contract archiving method, Features: The following steps are involved: 1) Obtain a standard contract image set and a to-be-compared contract image set, record a single contract image in the to-be-compared contract image set as a to-be-compared page image, and record a single contract image in the standard contract image set as a standard page image, and the images of each page in the standard image set have been correctly sorted according to the set page numbers; 2) Compare each standard page image with each to-be-compared page image for similarity, and obtain the similarity between each standard page image and each to-be-compared page image; 3) Based on the similarity obtained in step 2), each standard page image is matched with each to-be-compared page image according to the following criteria, and the page number of the to-be-compared page image is set to the page number of the standard page image that successfully matches it, and then a to-be-compared contract image set with the correct page number sorting is obtained based on the page number of each standard page image: Criterion 1: If there is only one to-be-compared page image with the highest similarity to a certain standard page image, and the highest similarity is greater than the set threshold, it indicates that the to-be-compared page image successfully matches the standard page image; Criterion 2: If the page image to be compared with the most similarity to multiple standard page images is the same, and all the highest similarities are greater than the set threshold, then compare the sizes of the multiple highest similarities: if there is only one maximum value among the multiple highest similarities, then it means that the page image to be compared successfully matches the standard page image corresponding to the maximum value; if there are multiple maximum values among the multiple similarities, then randomly select one from the standard page images corresponding to the multiple maximum values as the standard page image that successfully matches the page image to be compared; Criterion 3: Exclude the successfully matched standard page images and the to-be-compared page images, and re-match the other standard page images and the to-be-compared page images according to the set criteria; 4) Archive the contract image sets to be compared with the correct page number sorting.
2. The contract archiving method according to claim 1, Features: Before archiving the to-be-compared contract image set with the correct page number sorting in step 4), the direction of the to-be-compared page images needs to be regularized; each standard page image in the standard contract image set has been regularized to the positive direction; the following method is used to regularize the to-be-compared page images: 401) for a pair of standard page images and a page image to be compared having the same page number, cutting the standard page image according to set requirements to cut out a standard cutting image containing identification features under a positive viewing angle of the standard page image; 402) the image of the page to be compared at four different rotation angles of 0°, 90°, 180° and 270° is also cut according to the set requirements to obtain four cut images to be compared; 403) performing similarity comparison between the standard cutting image and the four cutting images to be compared, calculating each similarity value and obtaining the maximum similarity value; 404) using the cutting angle corresponding to the maximum similarity value as the rotation angle of the page image to be compared; 405) Rotate the image of the page to be compared according to the rotation angle; 406) For the remaining standard page images and to-be-compared page images with the same page number, they are all processed according to the method of steps 401) to 405) to rotate the remaining to-be-compared page images to obtain a rotated and regularized to-be-compared page image set.
3. The contract archiving method according to claim 1, Features: In step 3), if the highest similarity is not greater than the set threshold, a prompt message indicating that there is no pairing for the corresponding standard page image is given; The no-pairing prompt information includes the page number of the corresponding standard page image.
4. The contract archiving method according to claim 1, Features: The value range of the set threshold is 60%-80%.
5. The contract archiving method according to claim 1, Features: Before step 1), it is also necessary to determine the clarity of the to-be-compared page images in the to-be-compared page image set; if the clarity does not meet the requirement, a clarity prompt message is issued to prompt the to-be-compared page image to be replaced with one with higher clarity.
6. The contract archiving method according to claim 5, Features: The evaluation method for clarity judgment includes at least one of a Brenner gradient method, a Tenegrad gradient method, a laplacian gradient method, a variance method and an energy gradient method.
7. The contract archiving method according to claim 1, Features: Before step 1), the to-be-compared page images need to be subjected to image enhancement processing in the to-be-compared page images set, wherein the image enhancement processing includes adjusting at least one parameter of the image's contrast, brightness, color saturation, hue and sharpness.
8. The contract archiving method according to claim 2, Features: The setting requirement is to cut the image in a ratio of one quarter.
9. A contract filing system, Features: The system includes a processor, a memory and an internal bus. The processor and the memory communicate and exchange data with each other through the internal bus. The processor executes a computer program stored in the memory to implement the contract archiving method as described in any one of claims 1 to 8.
10. The contract archiving system according to claim 9, Features: It also includes a UI display module, which is used to visually display various prompt information and support interactive operations.
Citation Information
Patent Citations
Image-text content comparison method and device
CN110688889A
Paper contract management method
CN112540965A
