Intelligent character recognition method based on edge color deviation of scanned characters

Through multi-dimensional feature extraction and random forest model training, the color deviation of the scanned text edges is used to identify handwriting and printed text, which solves the problems of insufficient recognition efficiency and accuracy in existing technologies and realizes efficient document digitization processing.

CN120656180AInactive Publication Date: 2025-09-16SICHUAN BISHENG INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510769278.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When separating handwritten and printed text, existing technologies fail to effectively utilize color deviations at the edges of scanned text, resulting in insufficient efficiency and accuracy of the distinction algorithm, making it difficult to meet the needs of document digitization.

Method used

An intelligent text recognition method based on the color deviation of scanned text edges is adopted. Through multi-dimensional feature extraction and random forest model training, RGB, HSV, Lab, YCrCb color spaces and logarithmic polar coordinate ring processing are used to capture the differences in edge color penetration patterns between handwriting and printed text, forming a high-dimensional feature vector for recognition.

Benefits of technology

It breaks through the limitations of traditional error recognition, accurately distinguishes handwriting from printed text, improves recognition efficiency and accuracy, and meets the needs of document digitization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120656180A_ABST
    Figure CN120656180A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent character recognition method based on scanned character edge color deviation, which comprises the following steps of: 1, preparing a data set: collecting a single character picture only containing a handwritten or printed body, cutting a complete text line into single character areas, and labeling category labels; 2, multi-dimensional feature extraction: for each input picture, extracting texture and morphological features and point cloud color features; 3, model training: splicing the texture and morphological features and the point cloud color features to form a high-dimensional feature vector, and training a random forest model by using the high-dimensional feature vector; and 4, model application: inputting a to-be-processed scanning picture into the trained random forest model, and outputting a division result of handwritten and printed character areas by the random forest model to finish segmentation of handwritten and printed characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and image processing, and in particular to a method for intelligent text recognition based on color deviation of scanned text edges. Background Art

[0002] Separating handwritten and printed text is crucial in modern document processing and digitization. In scenarios like archive management, educational digitization, and medical prescription recognition, printed text represents standardized information carriers (e.g., medical record templates and exam answer sheets), while handwritten text carries personalized content (e.g., doctor's diagnostic notes and student responses to subjective questions). Separating the two is fundamental to automated classification and storage, semantic retrieval, and compliance review. For example, in the financial sector, separating printed invoice information from handwritten signatures simultaneously meets the machine readability requirements of tax audits and the handwriting authentication needs of manual verification. In the digitization of ancient books, separating printed text from handwritten annotations allows for the construction of knowledge graphs and the preservation of scholars' research tracks, ultimately driving document processing systems from "hybrid recognition" to...

[0003] Currently, images captured by scanners exhibit color deviation at the edges of text. This phenomenon occurs when the text appears bluish on the direction of origin and reddish (yellowish) on the direction of arrival. Existing techniques typically treat this phenomenon as an "error to be corrected," employing established algorithms for pixel alignment to restore the image. However, no research has attempted to exploit this "error" in distinguishing handwritten and printed text. This results in insufficient efficiency and accuracy in existing distinction algorithms, making them unable to meet the growing demand for document digitization. Therefore, this paper proposes an intelligent text recognition method based on color deviation at the edges of scanned text. Summary of the Invention

[0004] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a method for intelligent text recognition based on color deviation of scanned text edges.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions:

[0006] A method for intelligent text recognition based on color deviation of scanned text edges includes the following steps:

[0007] Step 1: Dataset Preparation: Collect single-word images containing only handwritten or printed text, and balance the number of handwritten and printed text samples. Normalize the images, split the complete text lines into individual text regions, and annotate them with category labels.

[0008] Step 2: Multi-dimensional feature extraction: For each input image, extract texture and morphological features as well as point cloud color features. The texture and morphological features include local binary pattern histogram, Hu moment features, directional histogram, gray-level co-occurrence matrix features, and gray-feature statistical features.

[0009] Step 3: Model training: Concatenate the texture and morphological features and the point cloud color features to form a high-dimensional feature vector, and use the high-dimensional feature vector to train the random forest model;

[0010] Step 4: Model application: The scanned image to be processed is input into the trained random forest model, which outputs the division results of the handwritten and printed text areas, completing the segmentation of handwritten and printed text.

[0011] The above further includes:

[0012] Furthermore, in step 2, the specific steps of extracting the local binary pattern histogram are:

[0013] Grayscale the image and generate a 3×3 neighborhood window for each pixel;

[0014] Compare the grayscale values ​​of the central pixel with those of the surrounding eight pixels, generate an 8-bit binary number and convert it to decimal as the LBP value of the pixel;

[0015] The LBP value range Divide the image into 8 intervals, count the number of pixels in each interval, generate a histogram with 8 entries, and normalize the height of the histogram as the feature.

[0016] Furthermore, in step 2, the specific steps of extracting Hu moment features are as follows:

[0017] Calculate the common moment of the image, the calculation formula is expressed as ,in, Indicates that the image is at coordinates The gray value at and Indicates the order of the moment and determines the center coordinates , , , Represents the total grayscale value of the image, and Represents the first-order moment of the image in the x and y directions, respectively, reflecting the centroid position of the grayscale distribution;

[0018] Calculate central moment and normalized central moment , central moment The calculation formula is expressed as , normalized central moment The calculation formula is expressed as in, is the normalization factor, is the zero-order central moment;

[0019] The first 7 invariant moments are extracted as 7-dimensional features.

[0020] Furthermore, in step 2, the specific steps of extracting the directional histogram are:

[0021] Use the Sobel operator to calculate the horizontal gradient and vertical gradient , and get the gradient amplitude and direction angle ;

[0022] The direction angle The range [0°, 360°] is divided into 8 intervals, generating eight histograms, initialized to 0, according to the The gradient amplitude of the interval to which it belongs is added to its corresponding histogram, and the histogram is normalized and returned as a feature.

[0023] Furthermore, in step 2, the specific steps of extracting gray-level co-occurrence matrix features are as follows:

[0024] Count the grayscale combination frequencies of upper and lower adjacent pixel pairs, set the pixel grayscale range to 0–255, and generate a 256×256 grayscale co-occurrence matrix , the gray-level co-occurrence matrix Each element of represents the number of times grayscale i and grayscale j appear simultaneously in this relationship;

[0025] Calculate the gray-level co-occurrence matrix The contrast, dissimilarity, homogeneity, energy, correlation and angular second moment are concatenated into a one-dimensional vector of length 6 as features.

[0026] Furthermore, in step 2, by calculating the grayscale mean, standard deviation, Otsu threshold, local maximum ratio, upper and lower quartile ratio, a six-dimensional feature is formed, and then the Gray-feature statistical feature is extracted.

[0027] Furthermore, in step 2, the specific steps of extracting point cloud color features are as follows:

[0028] Color space expansion: Convert the RGB original image obtained by the scanner into HSV, Lab, and YCrCb spaces, a total of 4 color spaces, to obtain 12 color channels ;

[0029] Logarithmic polar coordinate ring: define the coordinates of the image center , define radius as half of the maximum side length of the image, that is , defining the logarithmic scale parameter R), the interval [0, ] Divide into n segments, and get n+1 segmentation points , calculate the corresponding radius sequence ,and = 0, every pixel , calculate the distance d from the center and determine the ring zone to which it belongs ;

[0030] Color statistics calculation: For each ring and color channel C, calculate the mean , Error sum of squares , skewness ;

[0031] Feature concatenation: For each ring , the 12 channels They are connected in series to form a 36-dimensional vector, and the feature vectors of all n rings are spliced ​​in sequence to obtain the final 36n-dimensional feature.

[0032] Furthermore, in step three, the specific steps of using the high-dimensional feature vector to train the random forest model are:

[0033] Data preparation: Divide the labeled samples into training and test sets with a ratio of 8:2;

[0034] Random forest model initialization: define random forest parameters, including the number of trees, maximum depth, and feature subset size;

[0035] Random forest model training: For each decision tree, samples are extracted from the training set with replacement to generate subsets, and the maximum depth features are randomly selected to find the optimal split point. The information entropy H(D) of the data set D is calculated as ,in, Represents the number of classification categories, Representative The probability of a classification, starting from the root node, divides the data set into subsets according to the best splitting feature, and recursively builds a subtree. At each node, the data set is divided into two or more subsets according to the best splitting feature, and this process is recursively performed on each subset until the termination condition is met;

[0036] Random forest model evaluation: Use the test data set to evaluate the performance of the random forest model and calculate the evaluation indicators: the proportion of correctly classified samples to the total number of samples, the accuracy rate ;The ratio of instances predicted as positive samples to those that are actually positive samples, and the accuracy is ;The ratio of true positive examples to all positive examples, and the recall rate is ; The harmonic mean of precision and recall, F1 score is ; Among them, TP (true positive), TN (true negative), FP (false positive), and FN (false negative) represent the number of samples of true positive, true negative, false positive, and false negative, respectively; the random forest model is adjusted according to the evaluation results.

[0037] The present invention has the following beneficial effects:

[0038] In this invention, while existing techniques treat blue / red offsets at the edges of scanned text as noise requiring elimination, this method transforms these into effective criteria using point cloud color features. This method uses the original RGB channels, three newly added color spaces derived from RGB conversion: HSV / Lab / YCrCb, and log-polar coordinate banding. This method accurately captures the essential differences in edge color penetration between handwritten and printed text: Handwritten text exhibits nonlinear gradient color transitions (e.g., a more pronounced blue offset) due to uneven pen pressure, while printed text exhibits periodic, repetitive color deviations due to the mechanical platemaking process. This feature reconstruction transforms traditional "errors" into key distinguishing features, transcending the limitations of existing techniques in understanding color deviations. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 This is a step diagram of a method for intelligent text recognition based on color deviation of scanned text edges proposed by the present invention. DETAILED DESCRIPTION

[0040] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.

[0041] See also Figure 1 As shown, the present invention is a method for intelligent text recognition based on color deviation of scanned text edges, comprising the following steps:

[0042] Step 1: Dataset Preparation: Collect single-word images containing only handwritten or printed text, and balance the number of handwritten and printed text samples. Standardize the images (such as unifying the size, denoising, and binarization preprocessing). Cut the complete text lines into individual word regions and annotate them with category labels (0 = printed text, 1 = handwritten text).

[0043] Step 2: Multi-dimensional feature extraction: For each input image, extract texture and morphological features as well as point cloud color features. The texture and morphological features include local binary pattern (LBP) histogram, Hu moment features, directional histogram, gray-level co-occurrence matrix (GLCM) features, and gray-feature statistical features.

[0044] Step 3: Model training: Concatenate the texture and morphological features and the point cloud color features (texture features (8+7+8+6+6=35 dimensions), morphological features and color features (288 dimensions)) to form a high-dimensional feature vector, and use the high-dimensional feature vector to train the random forest model;

[0045] Step 4: Model application: The scanned image to be processed is input into the trained random forest model, which outputs the division results of the handwritten and printed text areas, completing the segmentation of handwritten and printed text.

[0046] In one embodiment, in step 2, the specific steps of extracting the local binary pattern (LBP) histogram are:

[0047] Grayscale the image and generate a 3×3 neighborhood window for each pixel;

[0048] Compare the grayscale values ​​of the central pixel with those of the surrounding eight pixels, generate an 8-bit binary number and convert it to decimal as the LBP value of the pixel;

[0049] The LBP value range Divide the image into 8 intervals, count the number of pixels in each interval, generate a histogram with 8 entries, and normalize the height of the histogram as the feature.

[0050] In one embodiment, in step 2, the specific steps of extracting Hu moment features are:

[0051] Calculate the common moment of the image, the calculation formula is expressed as ,in, Indicates that the image is at coordinates The gray value at and Indicates the order of the moment and determines the center coordinates , , , represents the total grayscale value of the image (i.e. the image "quality"), and Represents the first-order moment of the image in the x and y directions, respectively, reflecting the centroid position of the grayscale distribution;

[0052] Calculate central moment and normalized central moment , central moment The calculation formula is expressed as , normalized central moment The calculation formula is expressed as in, is the normalization factor, is the zero-order central moment (equivalent to the ordinary moment , i.e., the total image quality);

[0053] The first 7 invariant moments are extracted as 7-dimensional features.

[0054] In one embodiment, in step 2, the specific steps of extracting the directional histogram are:

[0055] Use the Sobel operator to calculate the horizontal gradient and vertical gradient , and get the gradient amplitude and direction angle ;

[0056] The direction angle The range [0°, 360°] is divided into 8 intervals, generating eight histograms, initialized to 0, according to the The gradient amplitude of the interval to which it belongs is added to its corresponding histogram, and the histogram is normalized and returned as a feature.

[0057] In one embodiment, in step 2, the specific steps of extracting gray level co-occurrence matrix (GLCM) features are as follows:

[0058] Count the grayscale combination frequencies of upper and lower adjacent pixel pairs, set the pixel grayscale range to 0–255, and generate a 256×256 grayscale co-occurrence matrix , the gray-level co-occurrence matrix Each element of represents the number of times grayscale i and grayscale j appear simultaneously in this relationship;

[0059] Calculate the gray-level co-occurrence matrix The contrast, dissimilarity, homogeneity, energy, correlation and angular second moment are concatenated into a one-dimensional vector of length 6 as features.

[0060] In one embodiment, in step 2, by calculating the grayscale mean, standard deviation, Otsu threshold, local maximum ratio, upper and lower quartile ratio, a 6-dimensional feature is formed, and then the Gray-feature statistical feature is extracted, and the mean feature is calculated for the pixels in the grayscale image, that is, the average grayscale value of the pixel; standard deviation, the standard deviation of the pixel grayscale; Otsu threshold, the threshold in the adaptive binary image algorithm; local maximum ratio, a 3*3 window is generated with a pixel as the center, when the grayscale of the central pixel is greater than that of the other eight pixels, the grayscale of the point is the local maximum, and the number of times such a pixel appears is counted as the ratio of the total number of pixels; grayscale upper quartile ratio, let the maximum grayscale appearing in the image be t, the minimum grayscale be b, and the grayscale upper quartile , calculate the ratio of the number of pixels with grayscale values ​​greater than Q3 to the total number of pixels; the grayscale lower quartile ratio, the grayscale lower quartile , calculate the ratio of the number of pixels whose gray value is less than Q1 to the total number of pixels.

[0061] In one embodiment, in step 2, the specific steps of extracting point cloud color features are:

[0062] Color space expansion: Convert the RGB original image obtained by the scanner into HSV, Lab, and YCrCb spaces, a total of 4 color spaces, to obtain 12 color channels ;

[0063] Logarithmic polar coordinate ring: define the coordinates of the image center , define radius as half of the maximum side length of the image, that is , defining the logarithmic scale parameter R), the interval [0, ] Divide into n segments, and get n+1 segmentation points , calculate the corresponding radius sequence ,and = 0, every pixel , calculate the distance d from the center and determine the ring zone to which it belongs ;

[0064] Color statistics calculation: For each ring and color channel C, calculate the mean , Error sum of squares , skewness ;

[0065] Feature concatenation: For each ring , the 12 channels They are connected in series to form a 36-dimensional vector, and the feature vectors of all n rings are spliced ​​in sequence to obtain the final 36n-dimensional feature.

[0066] In one embodiment, in step three, the specific steps of training the random forest model using the high-dimensional feature vector are:

[0067] Data preparation: The labeled samples (handwritten = 1, printed = 0) were divided into training and test sets with a ratio of 8:2 to ensure that the two types of samples were evenly distributed in the training and test sets (handwritten samples accounted for 50%).

[0068] Random forest model initialization: define random forest parameters, including the number of trees, maximum depth, and feature subset size;

[0069] Random forest model training: For each decision tree, samples are extracted from the training set with replacement (bootstrap sampling), a subset is generated, and the maximum depth feature is randomly selected to find the optimal split point. The information entropy H(D) of the data set D is calculated as ,in, Represents the number of classification categories, Representative The probability of a classification, starting from the root node, divides the data set into subsets according to the best splitting feature, and recursively builds a subtree. At each node, the data set is divided into two or more subsets according to the best splitting feature, and this process is recursively performed on each subset until the termination condition is met;

[0070] Random forest model evaluation: Use the test data set to evaluate the performance of the random forest model and calculate the evaluation indicators: the proportion of correctly classified samples to the total number of samples, the accuracy rate ;The ratio of instances predicted as positive samples to those that are actually positive samples, and the accuracy is ;The ratio of true positive examples to all positive examples, and the recall rate is ; The harmonic mean of precision and recall, F1 score is ; Among them, TP (true positive), TN (true negative), FP (false positive), and FN (false negative) represent the number of samples of true positive, true negative, false positive, and false negative, respectively; the random forest model is adjusted according to the evaluation results.

[0071] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A method for intelligent text recognition based on color deviation of scanned text edges, characterized in that: The following steps are involved: Step 1: Dataset Preparation: Collect single-word images containing only handwritten or printed text, and balance the number of handwritten and printed text samples. Normalize the images, split the complete text lines into individual text regions, and annotate them with category labels. Step 2: Multi-dimensional feature extraction: For each input image, extract texture and morphological features as well as point cloud color features. The texture and morphological features include local binary pattern histogram, Hu moment features, directional histogram, gray-level co-occurrence matrix features, and gray-feature statistical features. Step 3: Model training: Concatenate the texture and morphological features and the point cloud color features to form a high-dimensional feature vector, and use the high-dimensional feature vector to train the random forest model; Step 4: Model application: The scanned image to be processed is input into the trained random forest model, which outputs the division results of the handwritten and printed text areas, completing the segmentation of handwritten and printed text.

2. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step 2, the specific steps of extracting the local binary pattern histogram are: Grayscale the image and generate a 3×3 neighborhood window for each pixel; Compare the grayscale values ​​of the central pixel with those of the surrounding eight pixels, generate an 8-bit binary number and convert it to decimal as the LBP value of the pixel; The LBP value range Divide the image into 8 intervals, count the number of pixels in each interval, generate a histogram with 8 entries, and normalize the height of the histogram as the feature.

3. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step 2, the specific steps for extracting Hu moment features are: Calculate the common moment of the image, the calculation formula is expressed as ,in, Indicates that the image is at coordinates The gray value at and Indicates the order of the moment and determines the center coordinates , , , Represents the total grayscale value of the image, and Represents the first-order moment of the image in the x and y directions, respectively, reflecting the centroid position of the grayscale distribution; Calculate central moment and normalized central moment , central moment The calculation formula is expressed as , normalized central moment The calculation formula is expressed as in, is the normalization factor, is the zero-order central moment; The first 7 invariant moments are extracted as 7-dimensional features.

4. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step 2, the specific steps for extracting the directional histogram are: Use the Sobel operator to calculate the horizontal gradient and vertical gradient , and get the gradient amplitude and direction angle ; The direction angle The range [0°, 360°] is divided into 8 intervals, generating eight histograms, initialized to 0, according to the The gradient amplitude of the interval to which it belongs is added to its corresponding histogram, and the histogram is normalized and returned as a feature.

5. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step 2, the specific steps for extracting gray-level co-occurrence matrix features are: Count the grayscale combination frequencies of upper and lower adjacent pixel pairs, set the pixel grayscale range to 0–255, and generate a 256×256 grayscale co-occurrence matrix , the gray-level co-occurrence matrix Each element of represents the number of times grayscale i and grayscale j appear simultaneously in this relationship; Calculate the gray-level co-occurrence matrix The contrast, dissimilarity, homogeneity, energy, correlation and angular second moment are concatenated into a one-dimensional vector of length 6 as features.

6. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step 2, by calculating the grayscale mean, standard deviation, Otsu threshold, local maximum ratio, upper and lower quartile ratio, a six-dimensional feature is formed, and then the gray-feature statistical feature is extracted.

7. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step 2, the specific steps for extracting point cloud color features are: Color space expansion: Convert the RGB original image obtained by the scanner into HSV, Lab, and YCrCb spaces, a total of 4 color spaces, to obtain 12 color channels ; Logarithmic polar coordinate ring: define the coordinates of the image center , define radius as half of the maximum side length of the image, that is , defining the logarithmic scale parameter , the interval [0, ] is divided into n segments, and n+1 segmentation points are obtained. , calculate the corresponding radius sequence ,and = 0, every pixel , calculate the distance d from the center and determine the ring zone to which it belongs ; Color statistics calculation: For each ring and color channel C, calculate the mean , Error sum of squares , skewness ; Feature concatenation: For each ring , the 12 channels They are connected in series to form a 36-dimensional vector, and the feature vectors of all n rings are spliced ​​in sequence to obtain the final 36n-dimensional feature.

8. The method for intelligent text recognition based on color deviation of scanned text edges according to claim 1, characterized in that: In step three, the specific steps of using high-dimensional feature vectors to train the random forest model are: Data preparation: Divide the labeled samples into training and test sets with a ratio of 8:2; Random forest model initialization: define random forest parameters, including the number of trees, maximum depth, and feature subset size; Random forest model training: For each decision tree, samples are extracted from the training set with replacement to generate subsets, and the maximum depth features are randomly selected to find the optimal split point. The information entropy H(D) of the data set D is calculated as ,in, Represents the number of classification categories, Representative The probability of a classification, starting from the root node, divides the data set into subsets according to the best splitting feature, and recursively builds a subtree. At each node, the data set is divided into two or more subsets according to the best splitting feature, and this process is recursively performed on each subset until the termination condition is met; Random forest model evaluation: Use the test data set to evaluate the performance of the random forest model and calculate the evaluation indicators: the proportion of correctly classified samples to the total number of samples, the accuracy rate ;The ratio of instances predicted as positive samples to those that are actually positive samples, and the accuracy is ;The ratio of true positive examples to all positive examples, and the recall rate is ; The harmonic mean of precision and recall, F1 score is ; Among them, TP (true positive), TN (true negative), FP (false positive), and FN (false negative) represent the number of samples of true positive, true negative, false positive, and false negative, respectively; the random forest model is adjusted according to the evaluation results.