Method for improving OCR Chinese recognition accuracy based on Hamming distance
By preprocessing and feature extraction of OCR Chinese recognition technology, using Haiming distance calculation and optimization threshold, the problem of low recognition accuracy in the existing technology is solved, and higher recognition accuracy and robustness are achieved. in complex scenarios.
Patent Information
- Application Number
- CN202411094355.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-12-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing OCR Chinese recognition technology is not very accurate in dealing with complex backgrounds, font diversity and special typesetting. Haiming distance, as a character similarity measure, has limited sensitivity to complex glyphs and font changes, and the threshold setting depends on experience. or limited training data, resulting in insufficient robustness.
By preprocessing the input text, extracting features such as local binary modes, calculating Heming distance to evaluate character similarity, and optimizing Heming distance threshold and feature extraction method based on the test data set, correcting recognition errors, and improving recognition accuracy and stability.
It significantly improves the accuracy and robustness of OCR Chinese recognition, and is suitable for complex scenarios. Through effective measurement of Heming distance and cutting-edge image processing technology, the recognition accuracy and adaptability are improved.
Smart Images

Figure CN119068495A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Chinese processing, and in particular to a method for improving the accuracy of OCR Chinese recognition based on Hamming distance. Background Art
[0002] With the development of information technology, OCR technology has been widely used in document digitization, data extraction and other scenarios. Especially in the field of Chinese processing, the application of OCR technology is particularly important. However, the existing OCR Chinese recognition technology often has unsatisfactory recognition accuracy when dealing with complex backgrounds, font diversity, special typesetting and other problems. At present, the existing technical solutions that are most similar to the technical solution of the present invention are mainly based on traditional image processing and pattern recognition methods. For example:
[0003] Chinese patent publication number CN112016543A discloses a text recognition network, a neural network training method and related equipment, but the prior art does not provide an effective solution for separate processing of images.
[0004] Although these methods have improved the accuracy of OCR Chinese recognition to a certain extent, the Hamming distance, as a measure of character similarity, has limited sensitivity to character shape and structure, and is difficult to capture complex glyphs and font changes, especially in handwritten or low-resolution texts. Secondly, setting an appropriate Hamming distance threshold usually relies on experience or is based on limited training data, which may lead to insufficient robustness in different language environments or specific fonts. Finally, although the Hamming distance can be used for simple error correction, its ability to handle more complex semantic errors or context-related issues in OCR output is limited, and it still needs to be combined with more advanced semantic understanding and context models to further improve recognition precision and accuracy. Summary of the invention
[0005] In order to solve the problem that Hamming distance, as a character similarity measurement method, has limited sensitivity to character shape and structure, is difficult to capture complex glyphs and font changes, and is particularly ineffective in handwritten or low-resolution texts; secondly, setting a suitable Hamming distance threshold usually relies on experience or is based on limited training data, which may lead to insufficient robustness in different language environments or specific fonts, the present invention provides a method for improving OCR Chinese recognition accuracy based on Hamming distance.
[0006] The present invention provides a method for improving the accuracy of OCR Chinese recognition based on Hamming distance, which adopts the following technical solution:
[0007] A method for improving OCR Chinese recognition accuracy based on Hamming distance includes the following steps:
[0008] Step 1: Preprocess the input text to improve the accuracy of subsequent character segmentation and recognition;
[0009] Step 2: Extract features from each character and word, including local binary patterns, which help distinguish different characters and glyphs, and convert the extracted features into feature vectors for subsequent similarity calculations;
[0010] Step 3: Use Hamming distance to calculate the similarity between characters on the feature vector. Hamming distance represents the number of different characters at corresponding positions between two strings of equal length. Set an appropriate Hamming distance threshold to determine whether two characters can be considered similar or identical.
[0011] Step 4: Detect possible erroneous characters or misrecognitions in the OCR recognition results, and use alternative characters with a smaller Hamming distance to correct the detected erroneous characters;
[0012] Step 5: Use the test data set to evaluate the accuracy, recall, and F1 score of the modified OCR system. Based on the evaluation results, optimize the threshold setting of the Hamming distance, feature extraction method, text region detection model, etc. to further improve the recognition accuracy and stability.
[0013] Step 6: Deploy the optimized OCR system to actual applications, monitor its performance and effects in different scenarios, and continuously optimize and improve the algorithms and processes of the OCR system based on feedback and data from actual applications to adapt to new text styles and environmental conditions.
[0014] Preferably, the step one further comprises:
[0015] Data cleaning and enhancement: noise removal, contrast enhancement, and character segmentation;
[0016] Text region detection and segmentation: Use text detection algorithms to locate and segment text regions in images and extract image blocks for each character.
[0017] Preferably, the text detection based on deep learning uses a convolutional neural network (CNN) for text detection, and its loss function can be described as:
[0018]
[0019] in, They are the loss functions for score prediction, geometric transformation loss, and balance loss, respectively, and λ is the weight of each loss term.
[0020] Preferably, based on character segmentation, the detected text area is segmented into image blocks of individual characters by connected component analysis;
[0021] A1. First, the input text area image is binarized to obtain a binary image I binary (x, y), where (x, y) represents the coordinates of the pixel;
[0022] A1. Using the connected component analysis algorithm, the pixels in the binary image can be labeled differently according to their connectivity, thus forming different connected components;
[0023] A3. Once the connected components are marked, the boundaries of the characters can be defined based on the positions and shapes of these components. The bounding box of each connected component can be calculated to determine the boundaries of each character. The formula is as follows:
[0024]
[0025] Where C is a connected component, is the minimum x and y coordinate of all pixels in this component, are the maximum x and y coordinates.
[0026] Preferably, the features extracted in step 2 include shape features, stroke features, and features.
[0027] Preferably, in the local binary pattern of step 2, it is assumed that the pixel located at the center of the image (x c ,y c ), then the definition of the LBP operator is as follows:
[0028]
[0029] in:
[0030] P is the number of neighborhood pixels;
[0031] R is the radius, which determines the size of the neighborhood;
[0032] g c is the gray value of the center pixel;
[0033] g p is the gray value of the neighborhood pixel p;
[0034] s(x) is a sign function, if x≥0, then s(t)=1, otherwise s(x)=0.
[0035] Preferably, in step 3, the Hamming distance d H Defined as the number of bits that differ in corresponding positions between two equal-length strings X and Y. Suppose X = (x1, x2, ..., x n ) and Y = (y1, y2, ..., y n) are two strings or feature vectors of equal length, where x i ,y i ∈0, 1 represents the bit value at each position, then the Hamming distance can be calculated using the following formula:
[0036]
[0037] Among them, Hamming (x i ,y i ) means when x i ≠y i The smaller the Hamming distance between X and Y, the more similar the two feature vectors are; the larger the distance, the less similar they are or the greater the difference.
[0038] Preferably, the detecting of possible erroneous characters and misrecognitions in the OCR recognition results includes:
[0039] Error detection: Detect possible erroneous characters in recognition based on the Hamming distance calculation results;
[0040] Error correction: Correct the detected wrong characters;
[0041] Recognition confirmation: Confirm the corrected characters and use them as the final OCR recognition results.
[0042] Preferably, the main steps and indicators of the evaluation include:
[0043] Dataset preparation: Select test datasets containing diverse texts and different styles. These datasets should cover various practical application scenarios in which the system is expected to operate.
[0044] Accuracy: Accuracy refers to the ability of the OCR system to correctly recognize text, that is, the ratio of the number of correctly recognized texts to the total number of recognized texts;
[0045] Recall: Recall refers to the ability of the OCR system to recognize all correct texts, that is, the ratio of the number of correctly recognized texts to the total number of actual texts;
[0046] F1 score: The F1 score is the harmonic mean of precision and recall and is used to comprehensively evaluate the recognition ability of the system, especially when dealing with imbalanced categories (such as recognizing incorrect and correct text).
[0047] Preferably, the threshold optimization of the Hamming distance includes adjusting the threshold setting of the Hamming distance according to the evaluation data to more accurately distinguish between correctly recognized and misrecognized texts.
[0048] In summary, the present invention includes the following beneficial technical effects:
[0049] 1. This application starts with the preprocessing of the input text, and improves the accuracy of character segmentation and recognition through operations such as denoising and contrast enhancement. It uses methods such as local binary patterns to extract features of each character for subsequent similarity calculations to help distinguish different characters and glyphs. It uses the Hamming distance as a similarity metric. When calculating the similarity between characters, it sets a suitable threshold to determine whether the characters are similar or identical, effectively correcting possible erroneous characters or misrecognitions in OCR. It evaluates the corrected OCR system through a test data set, providing a basis for further optimizing the Hamming distance threshold, feature extraction method, and text area detection model to improve recognition accuracy and stability.
[0050] 2. This application introduces the concept of Hamming distance into the field of OCR Chinese recognition for the first time, and judges the accuracy of the recognition result by calculating the Hamming distance between the recognition result and the alternative result. This is the core innovation of the present invention. By introducing the concept of Hamming distance, text can be recognized more accurately, especially when processing different characters and glyphs, the recognition accuracy is significantly improved. By using the Hamming distance to effectively measure the similarity of characters, combined with cutting-edge image processing and machine learning technology, the accuracy and robustness of OCR Chinese recognition can be significantly improved. Through detailed data processing, feature extraction, similarity calculation and subsequent error correction strategies, the OCR system can recognize text more accurately and is suitable for various complex real-life scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 The present invention is a flowchart of a method for improving the accuracy of OCR Chinese recognition based on Hamming distance according to an embodiment of the present invention.
[0052] Figure 2 It is a schematic structural diagram of an embodiment of the invention. DETAILED DESCRIPTION
[0053] The following is combined with Figure 1-2 The present invention is described in further detail.
[0054] The embodiment of the present invention discloses a method for improving the accuracy of OCR Chinese recognition based on Hamming distance. Figure 1-Figure 2 , including the following steps:
[0055] Step 1: Preprocess the input text to improve the accuracy of subsequent character segmentation and recognition. It also includes: data cleaning and enhancement: removing noise, enhancing contrast, and character segmentation; text area detection and segmentation: using text detection algorithms to locate and segment the text area in the image, and extract the image block of each character. These steps help to eliminate noise and enhance the edge features of characters, so as to more accurately locate and extract characters, analyze and process the preprocessed image, accurately locate the text area and segment it, so as to extract the image block of each character, and prepare for subsequent feature extraction.
[0056] Specifically, text detection based on deep learning uses convolutional neural network CNN for text detection, and its loss function can be described as:
[0057]
[0058] in, They are the loss functions for score prediction, geometric transformation loss, and balance loss, respectively, and λ is the weight of each loss term.
[0059] Furthermore, based on character segmentation, the detected text area is segmented into image blocks of individual characters through connected component analysis, for example, character boundaries are defined according to pixel connectivity.
[0060] A1. First, the input text area image is binarized to obtain a binary image I binary (x, y), where (x, y) represents the coordinates of the pixel;
[0061] A1. Using the connected component analysis algorithm, the pixels in the binary image can be labeled differently according to their connectivity, thereby forming different connected components (or connected regions). Commonly used algorithms include labeling algorithms based on four or eight connections.
[0062] A3. Once the connected components are marked, the boundaries of the characters can be defined based on the positions and shapes of these components. The bounding box of each connected component can be calculated to determine the boundaries of each character. The formula is as follows:
[0063]
[0064] Where C is a connected component, is the minimum x and y coordinate of all pixels in this component, are the maximum z and y coordinates.
[0065] Step 2: Extract features for each character and word, including local binary patterns, histogram of oriented gradients (HOG) and other feature extraction methods to capture the local texture features and structural information of the characters, which help distinguish different characters and glyphs, and convert the extracted features into feature vectors for subsequent similarity calculations; convert the features extracted from each character image into a unified feature vector representation for subsequent similarity calculations and recognition steps. This conversion ensures that the features of each character are compared and matched in the same space.
[0066] Furthermore, the features extracted in step 2 include shape features, stroke features, and features.
[0067] In this embodiment, in the step 2 local binary mode, it is assumed that the pixel located at the center of the image (x c ,y c ), then the definition of the LBP operator is as follows:
[0068]
[0069] in:
[0070] P is the number of neighborhood pixels (usually 8, that is, eight-neighborhood);
[0071] R is the radius, which determines the size of the neighborhood;
[0072] g c is the gray value of the center pixel;
[0073] g p is the gray value of the neighborhood pixel p;
[0074] s(x) is a sign function, if x≥0, then s(x)=1, otherwise s(x)=0.
[0075] Step 3: Use the Hamming distance to calculate the similarity between characters on the feature vector. The Hamming distance represents the number of different characters at corresponding positions between two equal-length strings. Set an appropriate Hamming distance threshold to determine whether two characters can be considered similar or identical. For example, it can be dynamically adjusted according to the characteristics of the training data set and the character set. This step can more accurately measure the semantic similarity of the text, thereby making up for the limitations of the Hamming distance; by setting an appropriate Hamming distance threshold, the system can dynamically determine whether two characters are similar enough to be identified as the same character. This threshold setting can be adjusted according to the specific application scenario and the characteristics of the training data set to ensure the robustness and accuracy of the recognition system.
[0076] Furthermore, in step 3, the Hamming distance d HDefined as the number of bits that differ in corresponding positions between two equal-length strings X and Y. Suppose X = (x1, x2, ..., x n ) and Y = (y1, y2, ..., y n ) are two strings or feature vectors of equal length, where x i ,y i ∈0, 1 represents the bit value at each position, then the Hamming distance can be calculated using the following formula:
[0077]
[0078] Among them, Hamming (x i ,y i ) means when x i ≠y i The smaller the Hamming distance between X and Y, the more similar the two feature vectors are; the larger the distance, the less similar they are or the greater the difference.
[0079] Step 4: Detect possible erroneous characters or misrecognitions in the OCR recognition results, and use alternative characters with a smaller Hamming distance to correct the detected erroneous characters. This can be achieved through pre-defined replacement rules or dynamic correction based on statistical data; this method is based on numerical comparison of character similarity and can effectively improve the accuracy and quality of recognition results.
[0080] In this embodiment, detecting possible erroneous characters and misrecognitions in the OCR recognition results includes: error detection: detecting possible erroneous characters or words in the recognition based on the Hamming distance calculation result; error correction: correcting the detected erroneous characters or words; recognition confirmation: confirming the corrected characters or words and taking them as the final OCR recognition results.
[0081] Step 5: Use the test data set to evaluate the accuracy, recall, and F1 score of the modified OCR system. Based on the evaluation results, optimize the threshold setting of the Hamming distance, feature extraction method, text region detection model, etc. to further improve recognition accuracy and stability. This continuous optimization strategy enables the system to perform better when facing different text styles and environmental conditions.
[0082] Specifically, the threshold optimization of the Hamming distance includes adjusting the threshold setting of the Hamming distance according to the evaluation data to more accurately distinguish between correctly recognized and misrecognized texts. For example, different thresholds can be set according to different text types and scenarios.
[0083] Step 6: Deploy the optimized OCR system to actual applications, monitor its performance and effects in different scenarios, and continuously optimize and improve the algorithms and processes of the OCR system based on feedback and data from actual applications to adapt to new text styles and environmental conditions.
[0084] The main steps and indicators of the evaluation include: Dataset preparation: Select test datasets containing diverse texts and different styles. These datasets should cover various practical application scenarios in which the system is expected to operate; Accuracy: Accuracy refers to the ability of the OCR system to correctly recognize texts, that is, the ratio of the number of correctly recognized texts to the total number of recognized texts; Recall: Recall indicates the ability of the OCR system to recognize all correct texts, that is, the ratio of the number of correctly recognized texts to the total number of actual texts; F1 score: The F1 score is the harmonic mean of accuracy and recall, which is used to comprehensively evaluate the recognition ability of the system, especially when dealing with imbalanced categories (such as recognizing incorrect and correct texts).
[0085] In summary, through the text preprocessing in step 1, such as denoising and contrast enhancement, the accuracy of subsequent character segmentation and recognition is improved. Step 2 uses local binary patterns and other technologies to extract features from each character. These features are converted into feature vectors and used for Hamming distance calculation in step 3 to help determine the similarity of characters. Step 4 focuses on correcting the erroneous characters that may appear in OCR, and uses alternative characters with smaller Hamming distance to correct them, thereby improving the overall recognition accuracy. Subsequently, step 5 evaluates the accuracy, recall rate and F1 score of the OCR system through the test data set, providing a basis for optimizing the Hamming distance threshold, feature extraction method and text area detection model, and further enhancing the stability and performance of the system. Finally, step 6 deploys the optimized OCR system into actual applications, and through monitoring and continuous optimization, ensures that it performs well in different scenarios and adapts to various new text styles and environmental conditions, thereby achieving continuous improvement and improved user experience. The entire process comprehensively uses strategies such as preprocessing, feature extraction, similarity calculation, misrecognition correction, evaluation optimization and actual application deployment to improve the recognition effect and stability of the OCR system in complex environments. The above process steps use the Hamming distance to effectively measure character similarity, combined with cutting-edge image processing and machine learning technology, to significantly improve the accuracy and robustness of OCR Chinese recognition. Through detailed data processing, feature extraction, similarity calculation and subsequent error correction strategies, the OCR system can recognize text more accurately and is suitable for various complex real-world scenarios.
[0086] Finally, a few points should be explained: First, in the description of the present invention, it should be noted that, unless otherwise specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, which may refer to mechanical connection or electrical connection, or internal communication between two components, or direct connection. "upper", "lower", "left", "right", etc. are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship may change;
[0087] Secondly: In the drawings of the embodiments disclosed in the present invention, only the structures related to the embodiments disclosed in the present invention are involved, and other structures can refer to the general design. In the absence of conflict, the same embodiment and different embodiments of the present invention can be combined with each other;
[0088] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0089] The above are all preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for improving OCR Chinese recognition accuracy based on Hamming distance, characterized in that: The steps include: Step 1: Preprocess the input text to improve the accuracy of subsequent character segmentation and recognition; Step 2: Extract features from each character and word, including local binary patterns, distinguish different characters and glyphs, and convert the extracted features into feature vectors for subsequent similarity calculations; Step 3: Use Hamming distance to calculate the similarity between characters on the feature vector. Hamming distance represents the number of different characters at corresponding positions between two strings of equal length. Set an appropriate Hamming distance threshold to determine whether two characters can be considered similar or identical. Step 4: Detect the erroneous characters or misrecognitions in the OCR recognition results, and use the alternative characters with a smaller Hamming distance to correct the detected erroneous characters; Step 5: Use the test data set to evaluate the accuracy, recall, and F1 score of the modified OCR system. Based on the evaluation results, optimize the threshold setting of the Hamming distance, feature extraction method, text region detection model, etc. to further improve the recognition accuracy and stability. Step 6: Deploy the optimized OCR system to actual applications, monitor its performance and effects in different scenarios, and continuously optimize and improve the algorithms and processes of the OCR system based on feedback and data from actual applications to adapt to new text styles and environmental conditions.
2. According to the method of claim 1, the method is characterized by: In the step 1, the pretreatment specifically includes: Data cleaning and enhancement: noise removal, contrast enhancement, and character segmentation; Text region detection and segmentation: Use text detection algorithms to locate and segment text regions in images and extract image blocks for each character.
3. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 2 is characterized in that: Text detection based on deep learning uses convolutional neural network CNN for text detection, and its loss function can be described as: in, They are the loss functions for score prediction, geometric transformation loss, and balance loss, respectively, and λ is the weight of each loss term.
4. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 2, characterized in that: Based on character segmentation, the detected text area is segmented into image blocks of individual characters through connected component analysis; A1. First, the input text area image is binarized to obtain a binary image I binary (x, y), where (x, y) represents the coordinates of the pixel; A1. Use the connected component analysis algorithm to label the pixels in the binary image differently according to their connectivity, thus forming different connected components; A3. Once the connected components are marked, the boundaries of the characters are defined based on the positions and shapes of these components. The bounding box of each connected component is calculated to determine the boundaries of each character. The formula is as follows: Where C is a connected component, is the minimum x and y coordinate of all pixels in this component, are the maximum x and y coordinates.
5. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 1, characterized in that: The features extracted in step 2 include shape features, stroke features, and features.
6. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 1, characterized in that: In the local binary pattern of step 2, it is assumed that the pixel located at the center of the image (x c ,y c ), then the definition of the LBP operator is as follows: in: P is the number of neighborhood pixels; R is the radius, which determines the size of the neighborhood; g c is the gray value of the center pixel; g p is the gray value of the neighborhood pixel p; s(x) is a sign function, if x≥0, then s(t)=1, otherwise s(x)=0.
7. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 1, characterized in that: In step 3, the Hamming distance d H Defined as the number of bits that differ in corresponding positions between two equal-length strings X and Y. Suppose X = (x1, x2, ..., x p ) and Y = (y1, y2, ..., y n ) are two strings or feature vectors of equal length, where x i ,y i ∈0, 1 represents the bit value at each position, and the Hamming distance is calculated using the following formula: Among them, Hamming (x i ,y i ) means when x i ≠y i The smaller the Hamming distance between X and Y, the more similar the two feature vectors are; the larger the distance, the less similar they are or the greater the difference.
8. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 1, characterized in that: The detection of possible erroneous characters and misrecognitions in the OCR recognition results includes: Error detection: Detect possible erroneous characters in recognition based on the Hamming distance calculation results; Error correction: Correct the detected wrong characters; Recognition confirmation: Confirm the corrected characters and use them as the final OCR recognition results.
9. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 1, characterized in that: The main steps and indicators of the assessment include: Dataset preparation: Select test datasets containing diverse texts and different styles. These datasets should cover various practical application scenarios in which the system is expected to operate. Accuracy: Accuracy refers to the ability of the OCR system to correctly recognize text, that is, the ratio of the number of correctly recognized texts to the total number of recognized texts; Recall: Recall refers to the ability of the OCR system to recognize all correct texts, that is, the ratio of the number of correctly recognized texts to the total number of actual texts; F1 score: The F1 score is the harmonic mean of precision and recall and is used to comprehensively evaluate the recognition ability of the system, especially when dealing with imbalanced categories (such as recognizing incorrect and correct text).
10. The method for improving OCR Chinese recognition accuracy based on Hamming distance according to claim 1, characterized in that: The threshold optimization of the Hamming distance includes adjusting the threshold setting of the Hamming distance according to the evaluation data to more accurately distinguish between correctly recognized and misrecognized texts.
Citation Information
Patent Citations
Finger vein recognition method based on individualized weight
CN102411711A
Business card OCR data correction method and system based on knowledge base
CN103488983A
Chinese business card OCR (optical character recognition) data correction system utilizing massive associated information of knowledge base
CN103927352A
Print file identification method based on character texture region segmentation
CN107273898A
Character recognition method, device, electronic device and storage medium
CN109086834A
