High-precision OCR recognition and automatic error correction method in digital processing of archives
Through multi-threshold method and edge information optimization analysis, combined with weighting factors to process sticky characters, the missegment problem of traditional methods in complex image segmentation and sticky character recognition is solved, and the recognition accuracy and processing effect are significantly improved.
Patent Information
- Application Number
- CN202411479144.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-10-23
AI Technical Summary
The traditional single-threshold method is difficult to find a suitable threshold when processing complex images, resulting in poor segmentation effect. The existing character segmentation method is prone to missegment or missegment when processing sticky characters.
Multi-threshold method is used to optimize it with edge information, and hyphen characters are separated through the analysis of the connected area, and weighting factors are introduced during the separation process to protect the edge information, and shape, stroke, geometric and color features are extracted for comparison and correction.
Improve the accuracy and character recognition rate of image segmentation, reduce the situation of missegment, and significantly improve the recognition effect when dealing with complex and sticky characters.
Smart Images

Figure CN119007227B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of digital processing technology, in particular to a high-precision OCR recognition and automatic error correction method in digital processing of archives. Background Art
[0002] In the digitalization of archives, high-precision OCR recognition and automatic error correction methods are the key to ensure that paper archives are converted into electronic form and maintain high accuracy and reliability. The demand in this field stems from the historical value, management efficiency and access convenience of archives. Early OCR technology was mainly used to recognize printed text, with low recognition rate and poor adaptability to fonts and typesetting. However, with the development of computer vision and machine learning technology, modern OCR technology has been able to process documents with multiple fonts, handwriting and complex typesetting, and the recognition rate has been significantly improved. Despite this, high-precision OCR recognition still faces many technical challenges. The traditional single threshold method divides the image into two parts: foreground and background. In some images, the pixel value distribution of the foreground and background may not be a simple bimodal distribution, but a multimodal distribution. In this case, it is difficult for the single threshold method to find a suitable threshold, resulting in poor segmentation effect. In addition, the existing character segmentation method is prone to mis-segmentation or missed segmentation when dealing with characters with severe adhesion. Therefore, a high-precision OCR recognition and automatic error correction method in the digitalization of archives is designed. Summary of the invention
[0003] The purpose of the present invention is to provide a high-precision OCR recognition and automatic error correction method in archive digitization processing, so as to solve the problem that the single threshold method proposed in the above background technology is difficult to find a suitable threshold in this case, resulting in poor segmentation effect, and the existing character segmentation method is prone to mis-segmentation or missed segmentation when processing characters with severe adhesion.
[0004] To achieve the above object, the present invention aims to provide a high-precision OCR recognition and automatic error correction method in archive digitization processing, comprising the following steps:
[0005] S1. Preprocessing the text image of the archive document, introducing multiple thresholds and optimizing it in combination with edge information during the preprocessing process, segmenting the preprocessed image text into separate characters, and then using the connected region analysis method to separate the adhered characters, introducing a weighting factor and optimizing it in combination with edge information during the separation of the adhered characters, and extracting key features from each character; wherein the key features include shape features, stroke features, geometric features and color features;
[0006] S2, compare the extracted key features with the known character template to find the best matching text result;
[0007] S3, using rule-based error correction and context-aware error correction to check and correct text results;
[0008] S4. Save the checked and corrected results in a specified format, add metadata information to the archive document, and establish a user feedback channel for the archive to collect cases of identification errors.
[0009] As a further improvement of the technical solution, the preprocessing in S1 includes converting the color image into a grayscale image, converting the grayscale image into a binary image, and then using median filtering to remove noise in the image.
[0010] As a further improvement of the technical solution, the grayscale image is converted into a binary image as follows:
[0011] ;
[0012] in, is the between-class variance; is the threshold value; is the ratio of foreground pixels; is the ratio of background pixels; is the mean value of foreground pixels; is the mean value of background pixels;
[0013] Traverse all thresholds and select The largest threshold is taken as the optimal threshold ;
[0014] Use the optimal threshold found Binarize the original image and convert all images below Pixels with a value of 0 are set, and all pixels with a value greater than or equal to The pixels are set to 255.
[0015] As a further improvement of the technical solution, in S1, multiple thresholds are introduced in the preprocessing process and optimized in combination with edge information. After optimization, the specific results are as follows:
[0016] ;
[0017] in, for Threshold value; for The inter-class variance of the threshold; For the The pixel ratio of each interval; For the The pixel ratio of each interval; For the The pixel mean of the interval; For the The pixel mean of the interval; For the The edge weight factor of the interval; For the The edge strength within a range.
[0018] As a further improvement of the technical solution, the connected characters are separated by using the connected region analysis method in S1, and the specific steps are as follows:
[0019] S11, reducing the size of the character by an erosion operation to disconnect the adhered part, and then restoring the original size of the character by an expansion operation;
[0020] S12, calculating the distance from each pixel to the nearest background pixel, generating a distance map, and retaining the high value area in the distance map;
[0021] S13, generating marking points based on the distance map, dividing the image into multiple regions, each region corresponding to a connected region, and then marking the connected regions;
[0022] S14, analyzing the shape and size of each connected area, and then separating the connected characters;
[0023] S15, post-processing the separated areas, wherein the post-processing includes filtering small areas, merging similar areas, and verifying and repairing.
[0024] As a further improvement of the technical solution, the S11 is specifically as follows:
[0025] ;
[0026] in, is the input image; is a structural element; Representation Structure Pan to Position ; For corrosion operations; is the position coordinate of the current foreground pixel;
[0027] ;
[0028] in, For expansion operation; for Symmetrical structural elements; An empty collection.
[0029] As a further improvement of the technical solution, in the process of separating the stuck characters in S1, a weighting factor is introduced and optimized in combination with edge information, and the optimization is as follows:
[0030] ;
[0031] ;
[0032] in, For the optimized corrosion operation; This is the optimized expansion operation; is the weight threshold; For the location The weight of For the location The edge strength of is the threshold of edge strength; All are structural elements .
[0033] As a further improvement of the technical solution, the S12 is specifically as follows:
[0034] ;
[0035] in, is the distance from the foreground pixel to the nearest background pixel; is the set of background pixels; is the position coordinate of the background pixel;
[0036] Each foreground pixel Distance to the nearest background pixel Stored in a new image, this new image is the distance map;
[0037] Set a threshold in advance , used to distinguish high-value areas from low-value areas, perform threshold processing on each pixel value in the distance map, and retain pixels greater than or equal to the threshold Set the pixels that contain 1 to 1 and the rest to 0.
[0038] As a further improvement of the technical solution, in S13, the image is divided into multiple regions, and then the connected regions are marked, and a label value is assigned to each pixel. , as follows:
[0039] ;
[0040] in, is the output label value; is the coordinate position of the current pixel; The newly assigned label; is the input image; is the minimum label among the neighbors.
[0041] As a further improvement of the technical solution, the specific steps of S3 are as follows:
[0042] S31. Input text Perform basic cleaning and formatting to obtain preprocessed text ;
[0043] S32. Read predefined spelling error rule set And load the standard dictionary file , use regular expressions to match and replace spelling errors to get preliminary rule-based correction text , and then perform dictionary matching on each word. If the word is not in the dictionary, find the most similar word to replace it, and get the final rule-based error correction text. ;
[0044] S33. Collect training data with context and train the model , Will As the input of the context-aware model, context-aware error correction is performed to obtain the context-aware error correction text ;
[0045] S34, the final error correction result Output to a file or database and use standard evaluation indicators to evaluate the error correction effect.
[0046] Compared with the prior art, the present invention has the following beneficial effects:
[0047] 1. In the high-precision OCR recognition and automatic error correction method used in the digital processing of archives, multiple thresholds are introduced in the preprocessing process and optimized in combination with edge information. The multi-threshold method can divide the image into multiple levels, and each level uses a different threshold, so that the algorithm can better process complex images, especially when there are objects with multiple gray levels in the image; at the same time, the combination of edge information can enhance the algorithm's ability to recognize important features in the image, especially near the edge. Edge information can help the algorithm segment the target object more accurately and reduce the possibility of mis-segmentation.
[0048] 2. In the high-precision OCR recognition and automatic error correction method used in the digital processing of the archive, a weighting factor is introduced in the process of separating the adhered characters and optimized in combination with edge information. By combining edge information, the edges in the image can be better protected to prevent the edges from being destroyed during corrosion and expansion. The weighted operation can dynamically adjust the processing intensity according to local features to reduce the possibility of mis-segmentation, especially when processing adhered characters, so that the characters can be separated more accurately. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1The figure is a flow chart of the overall method of the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] Example
[0052] See also Figure 1 As shown, a high-precision OCR recognition and automatic error correction method in archive digitization processing is provided, including the following steps:
[0053] S1. Preprocessing the text image of the archive document, introducing multiple thresholds and optimizing it in combination with edge information during the preprocessing process, segmenting the preprocessed image text into separate characters, and then using the connected region analysis method to separate the adhered characters, introducing a weighting factor to optimize the process of separating the adhered characters, and extracting key features from each character; wherein the key features include shape features, stroke features, geometric features and color features;
[0054] Shape features specifically include contour, convex hull, Hu moment and bounding box. The outer contour of the character is extracted to describe the overall shape of the character; the convex hull of the character is calculated to describe the outer contour of the character; the Hu moment of the character is a shape descriptor that is invariant to rotation, scaling and translation; the minimum bounding box of the character is calculated to describe the position and size of the character;
[0055] The stroke features specifically include stroke width, stroke direction and stroke density. The stroke width is used to measure the width of the strokes in the character; the stroke direction is used to extract the direction information of the strokes, such as horizontal, vertical, oblique, etc.; the density of the strokes in the character is calculated, that is, the number of strokes per unit area;
[0056] The geometric features specifically include aspect ratio, area, perimeter and roundness. The aspect ratio is used to calculate the ratio of the height to the width of a character; the area is used to calculate the area of a character; the perimeter is used to calculate the perimeter of a character; and the roundness of a character is used to describe the degree of roundness of the character.
[0057] Color features include color histogram and main color tone. The color histogram of a character is calculated to describe the color distribution of the character; the main color tone of the character is extracted to distinguish characters of different colors.
[0058] The preprocessing in S1 includes converting the color image into a grayscale image, converting the grayscale image into a binary image, and then using median filtering to remove noise from the image;
[0059] Convert the grayscale image to a binary image as follows:
[0060] ;
[0061] in, is the between-class variance; is the threshold value; is the ratio of foreground pixels; is the ratio of background pixels; is the mean value of foreground pixels; is the mean value of background pixels;
[0062] Traverse all thresholds and select The largest threshold is taken as the optimal threshold ;
[0063] Use the optimal threshold found Binarize the original image and convert all images below Pixels with a value of 0 (black, usually foreground) are set, and all pixels above or equal to The pixels of are set to 255 (white, representing the background);
[0064] In the process of preprocessing, multi-threshold is introduced and optimized in combination with edge information. The multi-threshold method can divide the image into multiple levels, and each level uses a different threshold, so as to better process complex images. After optimization, it is as follows:
[0065] ;
[0066] in, for Threshold value; for The inter-class variance of the threshold; For the The pixel ratio of each interval; For the The pixel ratio of each interval; For the The pixel mean of the interval; For the The pixel mean of the interval; For the The edge weight factor of the interval; For the The edge strength within the interval;
[0067] The traditional single threshold method divides the image into two parts, foreground and background, while the multi-threshold method can divide the image into multiple levels, using different thresholds for each level. This enables the algorithm to better handle complex images, especially when there are objects with multiple gray levels in the image; combining edge information can enhance the algorithm's ability to identify important features in the image, especially near the edges. Edge information can help the algorithm segment the target object more accurately and reduce the occurrence of mis-segmentation.
[0068] After the text in the archive document is segmented into individual characters, the characters may become stuck together for various reasons, which will seriously affect the subsequent text recognition (OCR) and processing effects. Specifically, stuck characters will cause the optical character recognition (OCR) system to recognize them as an incorrect character or completely fail to recognize them. By separating the stuck characters, the accuracy of character recognition can be significantly improved. After separating the stuck characters, each character can be recognized independently, thereby improving the overall recognition rate.
[0069] Therefore, S1 uses the connected region analysis method to separate the connected characters. The specific steps are as follows:
[0070] S11. Reduce the size of the characters through the erosion operation, disconnect the sticky parts, and make the connecting parts between the sticky characters thinner or even disconnected. The erosion operation can be implemented by defining a structural element (such as a 3x3 square or a cross), and then restore the original size of the characters through the expansion operation; the expansion operation is also implemented by defining a structural element; the operation of first erosion and then expansion is called an opening operation, which can remove small noise points and small connecting parts, and the operation of first expansion and then erosion is called a closing operation, which can fill small holes inside the characters to make the characters more complete.
[0071] S11 is as follows:
[0072] The erosion operation slides a structural element across the image. If the structural element is completely contained within the foreground object, the pixel value at that position remains unchanged, otherwise it becomes the background value. The erosion operation can be used to shrink objects, remove small protrusions, or disconnect adjacent objects.
[0073] ;
[0074] in, is the input image; The structural element is a small binary image, usually a rectangle, circle, or cross. The structural element is used to define the neighborhood range of the erosion and expansion operations; Representation Structure Pan to Position ; For corrosion operations; is the position coordinate of the current foreground pixel;
[0075] The dilation operation slides a structural element across the image. If there is any intersection between the structural element and the foreground object, the pixel value at that position becomes the foreground value. The dilation operation can be used to enlarge objects, fill small holes, or connect adjacent objects.
[0076] ;
[0077] in, For expansion operation; for Symmetrical structural elements; is an empty collection;
[0078] In the process of separating the stuck characters, a weighting factor is introduced and optimized in combination with edge information. The optimization is as follows:
[0079] ;
[0080] ;
[0081] in, For the optimized corrosion operation; This is the optimized expansion operation; is the weight threshold; For the location The weight of For the location The edge strength of is the threshold of edge strength; All are structural elements ;
[0082] The core logic of the traditional corrosion operation is maintained, which requires the structural elements to In Location All points of the image must be located This ensures that the position will be retained only when the structural element completely covers the background area; The core logic of the traditional expansion operation is maintained, which requires the structural elements The complement of is in position At least one point is consistent with the image Intersection,ensures that as long as part of the structure element covers the foreground area,,that location will be extended;
[0083] This condition introduces a weighting factor , which reflects the importance or reliability of different positions by Each pixel value within the coverage area Multiply by the corresponding weight , and then summing them up, we can get a weighted pixel sum. If this sum is greater than or equal to the threshold , then the location is considered to meet the conditions, which helps to highlight important areas and reduce the impact of noise;
[0084] Edge Strength Indicates location The edge significance is determined if the edge strength is greater than or equal to the threshold , then the position is considered to be an important edge point, which helps to preserve the edge of the character and avoid excessive corrosion;
[0085] By combining edge information, the edges in the image can be better protected to prevent them from being destroyed during corrosion and expansion. The weighted operation can dynamically adjust the processing intensity according to local features to reduce the possibility of mis-segmentation. In particular, when processing adhered characters, the characters can be separated more accurately. Combining edge information and weighted operations can improve the processing effect. In particular, when processing complex images, by dynamically adjusting the weights, it can better adapt to the characteristics of different regions and improve the overall processing quality. By adjusting the weight coefficient and threshold, the processing effect can be flexibly controlled to adapt to different application scenarios and needs.
[0086] S12, calculating the distance from each pixel to the nearest background pixel, generating a distance map, and retaining the high value area in the distance map;
[0087] S12 is as follows:
[0088] ;
[0089] in, is the distance from the foreground pixel to the nearest background pixel; is the set of background pixels; is the position coordinate of the background pixel;
[0090] Each foreground pixel Distance to the nearest background pixel Stored in a new image, this new image is the distance map;
[0091] Set a threshold in advance , which is used to distinguish high-value areas from low-value areas. Usually, the choice of threshold can be determined according to the needs of the specific application, and the appropriate threshold can be selected through experiments or statistical methods. Threshold processing is performed on each pixel value in the distance map, and pixels greater than or equal to the threshold are retained. Set the pixels with the same value to 1 (or keep the original value), and set the rest of the pixels to 0;
[0092] Suppose there is a simple binary image where foreground pixels are represented by 1 and background pixels are represented by 0:
[0093] ;
[0094] For foreground pixels (i.e. the pixel at row 2 and column 2), we need to calculate its distance to all background pixels:
[0095] Background pixel collection This includes all pixel locations with a value of 0, e.g. , , , ;
[0096] calculate Distance to each background pixel:
[0097] ;
[0098] ;
[0099] ;
[0100] ;
[0101] Find the minimum distance: min( , , , )= ; Therefore, D(2,2)= In this way, the distance to the nearest background pixel can be calculated for each foreground pixel, and finally the entire distance map is generated.
[0102] S13, generating marker points based on the distance map, dividing the image into multiple regions, each region corresponding to a connected region, and then marking the connected regions, each connected region will be assigned a unique label;
[0103] In S13, the image is divided into multiple regions, and then the connected regions are marked, assigning a label value to each pixel. , as follows:
[0104] ;
[0105] in, is the output label value; is the coordinate position of the current pixel; The newly assigned label; is the input image; is the minimum label among the neighbors;
[0106] when and there are no marked neighbors around: This means the current location The pixel value is 1 (usually indicating the foreground), and all its neighboring pixels (usually in the four directions of up, down, left, right, and sometimes in the diagonal direction) have not been labeled. At this time, a new label is assigned to the pixel , which ensures that each new, isolated object gets a unique identifier;
[0107] when and at least one neighbor is marked: If the current position If a pixel has a value of 1 and at least one of its neighbors is already labeled (i.e. has the same foreground value of 1 and has been assigned a label), then the pixel should belong to the same object as these neighbors. Therefore, the smallest label among these labeled neighbors is selected. Assigned to the current pixel. This operation helps ensure that all pixels of the same object will eventually have the same label, while reducing the number of labels by selecting the smallest label value, improving algorithm efficiency.
[0108] S14, analyzing the shape and size of each connected area, and then separating the connected characters;
[0109] If the area of a connected region is abnormally large or the aspect ratio deviates from the range of normal characters, it may contain multiple characters; if the connected region has many convex hull defects, it may indicate the presence of depressions, which are usually the characteristics of glued characters. Once it is determined that a connected region contains multiple characters, find a suitable vertical or horizontal dividing line inside the connected region and choose to segment at a place with lower pixel density.
[0110] S15, post-processing the separated areas, where the post-processing includes filtering small areas, merging similar areas, and verification and repair; filtering small areas is to remove connected areas with too small areas, which may be the result of noise or mis-segmentation; merging similar areas means that if the segmented character areas are very close and have similar properties, you can consider re-merging them to avoid over-segmentation; verification and repair is to verify the segmentation results to ensure that each character area is reasonable. If obvious errors are found, they can be repaired manually or automatically.
[0111] S2, compare the extracted key features with the known character template to find the best matching text result;
[0112] S3. Check and correct text results using rule-based and context-aware error correction, such as checking whether the date format and numbers are reasonable, and correcting words that are not included or misspelled.
[0113] The specific steps of S3 are as follows:
[0114] S31. Input text Perform basic cleaning and formatting, such as removing spaces, punctuation marks, etc., to obtain preprocessed text ;
[0115] S32. Read predefined spelling error rule set And load the standard dictionary file , use regular expressions to match and replace spelling errors to get preliminary rule-based correction text , and then perform dictionary matching on each word. If the word is not in the dictionary, find the most similar word to replace it, and get the final rule-based error correction text. ; Rule-based error correction can quickly correct common spelling errors, improve efficiency, ensure the correctness of words, and reduce spelling errors;
[0116] S33. Collect training data with context and train the model , Will As the input of the context-aware model, context-aware error correction is performed to obtain the context-aware error correction text ; Consider contextual information to correct errors that cannot be solved based on rules, and improve the accuracy of error correction;
[0117] S34, the final error correction result Output to a file or database and use standard evaluation indicators to evaluate the error correction effect;
[0118] S4. Save the results of the inspection and correction in a specified format, and add metadata information to the archive documents, such as metadata fields, such as document ID, creation date, author, keywords, subject, etc. Metadata provides additional information about the document, which helps to better understand and manage the document and improve the discoverability of the document. At the same time, it can record the version history of the document, making it easier to track and manage different versions of the document. Establish a user feedback channel for the archive to collect cases of identification errors; promote continuous improvement of the system and enhance user experience.
[0119] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above embodiments, and the above embodiments and descriptions are only preferred examples of the present invention, and are not intended to limit the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.
Claims
1. A high-precision OCR recognition and automatic error correction method in digital file processing, characterized in that: The steps include: S1. Preprocessing the text image of the archive document, introducing multiple thresholds and optimizing it in combination with edge information during the preprocessing process, segmenting the preprocessed image text into separate characters, and then using the connected region analysis method to separate the adhered characters, introducing a weighting factor and optimizing it in combination with edge information during the separation of the adhered characters, and extracting key features from each character; wherein the key features include shape features, stroke features, geometric features and color features; S2, compare the extracted key features with the known character template to find the best matching text result; S3, using rule-based error correction and context-aware error correction to check and correct text results; S4, save the results of the inspection and correction in a specified format, add metadata information to the archive document, and establish a user feedback channel for the archive to collect cases of identification errors; In the S1, multiple thresholds are introduced during the preprocessing process and optimized in combination with edge information. After optimization, the specific results are as follows: ; in, for Threshold value; for The inter-class variance of the threshold; For the The pixel ratio of the interval; For the The pixel ratio of the interval; For the The pixel mean of the interval; For the The pixel mean of the interval; For the The edge weight factor of the interval; For the The edge strength within the interval; In S1, the connected region analysis method is used to separate the connected characters, and the specific steps are as follows: S11, reducing the size of the character by an erosion operation to disconnect the adhered part, and then restoring the original size of the character by an expansion operation; S12, calculating the distance from each pixel to the nearest background pixel, generating a distance map, and retaining the high value area in the distance map; S13, generating marking points based on the distance map, dividing the image into multiple regions, each region corresponding to a connected region, and then marking the connected regions; S14, analyzing the shape and size of each connected area, and then separating the connected characters; S15, post-processing the separated areas, wherein the post-processing includes filtering small areas, merging similar areas, and verifying and repairing.
2. The high-precision OCR recognition and automatic error correction method in the digitalization of archives according to claim 1, characterized in that: The preprocessing in S1 includes converting a color image into a grayscale image, converting the grayscale image into a binary image, and then using a median filter to remove noise in the image.
3. The high-precision OCR recognition and automatic error correction method in the digitalization of archives according to claim 2, characterized in that: The grayscale image is converted into a binary image as follows: ; in, is the between-class variance; is the threshold value; is the ratio of foreground pixels; is the ratio of background pixels; is the mean value of foreground pixels; is the mean value of background pixels; Traverse all thresholds and select The largest threshold is taken as the optimal threshold ; Use the optimal threshold found Binarize the original image and convert all images below Pixels with a value of 0 are set, and all pixels with a value greater than or equal to The pixels are set to 255.
4. The high-precision OCR recognition and automatic error correction method in digitalized file processing according to claim 3, characterized in that: The S11 is specifically as follows: ; in, is the input image; is a structural element; Representation Structure Pan to Position ; For corrosion operations; is the position coordinate of the current foreground pixel; ; in, For expansion operation; for Symmetrical structural elements; An empty collection.
5. The high-precision OCR recognition and automatic error correction method in the digitalization of archives according to claim 4, characterized in that: In the S1, a weighting factor is introduced in the process of separating the stuck characters and the optimization is performed in combination with the edge information. The optimization is as follows: ; ; in, For the optimized corrosion operation; This is the optimized expansion operation; is the weight threshold; For the location The weight of For the location The edge strength of is the threshold of edge strength; All are structural elements .
6. The high-precision OCR recognition and automatic error correction method in digitalized file processing according to claim 5, characterized in that: The S12 is specifically as follows: ; in, is the distance from the foreground pixel to the nearest background pixel; is the set of background pixels; is the position coordinate of the background pixel; Each foreground pixel Distance to the nearest background pixel Stored in a new image, this new image is the distance map; Set a threshold in advance , used to distinguish high-value areas from low-value areas, perform threshold processing on each pixel value in the distance map, and retain pixels greater than or equal to the threshold Set the pixels that contain 1 to 1 and the rest to 0.
7. The high-precision OCR recognition and automatic error correction method in the digitalization of archives according to claim 6, characterized in that: In S13, the image is divided into multiple regions, and then the connected regions are marked, and a label value is assigned to each pixel. , as follows: ; in, is the output label value; is the coordinate position of the current pixel; The newly assigned label; is the input image; is the minimum label among the neighbors.
8. The high-precision OCR recognition and automatic error correction method in digitalized file processing according to claim 7, characterized in that: The specific steps of S3 are as follows: S31. Input text Perform basic cleaning and formatting to obtain preprocessed text ; S32. Read predefined spelling error rule set And load the standard dictionary file , use regular expressions to match and replace spelling errors to get preliminary rule-based correction text , and then perform dictionary matching on each word. If the word is not in the dictionary, find the most similar word to replace it, and get the final rule-based error correction text. ; S33. Collect training data with context and train the model , Will As the input of the context-aware model, context-aware error correction is performed to obtain the context-aware error correction text ; S34, the final error correction result Output to a file or database and use standard evaluation indicators to evaluate the error correction effect.