A method and device for recognizing easily confused characters based on grayscale images

By binarizing and morphological profile analysis of the grayscale images on the certificate, the problems of high recognition error rate and time-consuming manual proofreading are solved, and the OCR recognition efficiency and accuracy are improved.

CN113837119BActive Publication Date: 2024-11-22FUZHOU SYMBOL INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111142126.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2024-11-22
Estimated Expiration
2041-09-28

AI Technical Summary

Technical Problem

The prior art in the machine-read code on the identification document, especially the name part, is prone to identification errors and lacks effective verification algorithms, which leads to manual proofreading and correction, which is time-consuming and labor-intensive, and the grayscale jump caused by environmental factors makes Character recognition obfuscation.

Method used

By initially identifying the grayscale image, we can determine whether it is easy to confuse characters. If so, we will perform correction processing, including calculating the pixel gradient value, setting the grayscale threshold, performing binarization and morphological profile analysis, and re-judging the character type to reduce the Error rate.

Benefits of technology

It reduces the recognition error rate of confusing characters, reduces the time-consuming of manual proofreading, and improves the efficiency and accuracy of OCR recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113837119B_ABST
    Figure CN113837119B_ABST
Patent Text Reader

Abstract

The present invention relates to a method and device for identifying easily confused characters based on grayscale images. The method comprises the following steps: inputting an original image, identifying the character type in the image through a text recognition engine, and judging whether the character is an easily confused character. If the character is an easily confused character, correcting the character; the correcting comprises the following steps: obtaining a grayscale image of the character, traversing the grayscale values ​​of each pixel in the grayscale image, and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel; selecting a gradient value as a gradient threshold, and calculating the grayscale average value of pixels exceeding the gradient threshold as the grayscale threshold; according to the grayscale threshold, setting the pixel points in the grayscale image whose grayscale values ​​are greater than the grayscale threshold as black points, and setting the pixel points whose grayscale values ​​are less than the grayscale threshold as white points, so as to generate a binary image; and correcting the character type of the character according to the morphological contour of the character in the binary image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method and a device for recognizing easily confused characters based on grayscale images, belonging to the technical field of image processing and text recognition. Background Art

[0002] At present, there are roughly three types of machine-readable codes used internationally, mostly 2 lines * 44 characters for passports, 2 lines * 36 characters for ID cards, and 3 lines * 30 characters. Currently, OCR recognition technology is mainly used to complete the reading of the machine-readable codes of these documents. The machine-readable codes on these documents contain the relevant identity information of the holder, generally including data such as document number, nationality, date of birth, and name. For the document number, nationality, date of birth, and other information of the holder, the machine-readable code area has its corresponding verification algorithm to verify the correctness of the OCR recognition result, but there is usually no relevant verification algorithm for the name of the holder and the optional information of each country, which easily causes the recognition error of this part of the information data that has not been verified, and manual proofreading and manual correction are required. Although manual correction can improve the accuracy of recognition, manual correction is a time-consuming and labor-intensive process, and the recognition speed needs to be improved.

[0003] Generally, in actual application scenarios, electronic devices may experience irregular grayscale jumps in the collected images due to various environmental factors. This can easily cause recognition confusion between some characters that are similar in local morphology, such as the letters P and F in the name of the cardholder. Summary of the invention

[0004] In order to solve the problems existing in the above-mentioned prior art, the present invention proposes a method for identifying easily confused characters based on grayscale images. Based on the grayscale image of the original character, the morphological contour corresponding to the character image is found, and the morphological contour is judged twice to re-judge and correct the easily confused characters, thereby reducing the recognition error rate of easily confused characters in the OCR recognition process, reducing the time-consuming manual proofreading and correction, and thus improving the efficiency of OCR recognition.

[0005] The technical solution of the present invention is as follows:

[0006] Technical solution 1:

[0007] A method for identifying easily confused characters based on grayscale images comprises the following steps:

[0008] Initial recognition: input the original image, identify the character type in the image through the text recognition engine, and determine whether the character is an easily confused character based on the character type. The easily confused character is a character that is similar in shape and easily misidentified; if it is an easily confused character, correct it; if not, skip it, keep the recognition result, and do not correct it;

[0009] The correction process comprises the following steps:

[0010] Obtaining the pixel gradient of the character image; obtaining the grayscale image of the character, traversing the grayscale values ​​of each pixel in the grayscale image, and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel;

[0011] Calculate the grayscale threshold; count the gradient values ​​of all pixels, select a gradient value as the gradient threshold, and calculate the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold;

[0012] Binarize the image; according to the grayscale threshold, set the pixel points whose grayscale values ​​in the grayscale image are greater than the grayscale threshold as black points, and set the pixel points whose grayscale values ​​are less than the grayscale threshold as white points, so as to generate a binary image;

[0013] Character correction: According to the morphological contour of the character in the binary image, the edge change of the target pixel point of its binary contour image is obtained, and the character type is determined according to which character's morphological characteristics are satisfied by the edge change.

[0014] Furthermore, the specific steps of traversing the grayscale values ​​of each pixel in the grayscale image and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel are:

[0015] Select a pixel point in the target character image to be corrected as the coordinate origin to establish a horizontal rectangular coordinate system;

[0016] The gray value corresponding to the pixel is recorded as P(x, y);

[0017] The gradient value G of each pixel is calculated according to the following formula:

[0018]

[0019] Furthermore, the specific steps of counting the gradient values ​​of all pixels, selecting a gradient value as a gradient threshold, and calculating the grayscale average value of pixels exceeding the gradient threshold as the grayscale threshold are:

[0020] Count the gradient values ​​of all pixels and get the number of pixels corresponding to each gradient value;

[0021] The gradient value corresponding to the number of pixels exceeding 25% of the total number of pixels is taken as the gradient threshold;

[0022] The grayscale values ​​of all pixels whose gradient values ​​are greater than the gradient threshold are counted, and the average is taken as the grayscale threshold.

[0023] Furthermore, the specific steps of character correction are:

[0024] Set up an array, and record the x coordinates of the last pixel set as a white point in each row of the grayscale image into the array in sequence;

[0025] Draw a change curve according to the change of x coordinate in the array;

[0026] The character type in the grayscale image is corrected according to the contour of the variation curve.

[0027] Technical solution 2:

[0028] A device for recognizing easily confused characters based on grayscale images, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the program:

[0029] Initial recognition: input the original image, identify the character type in the image through the text recognition engine, and determine whether the character is an easily confused character based on the character type. The easily confused character is a character that is similar in shape and easily misidentified; if it is an easily confused character, correct it; if not, skip it, keep the recognition result, and do not correct it;

[0030] The correction process comprises the following steps:

[0031] Obtaining the pixel gradient of the character image; obtaining the grayscale image of the character, traversing the grayscale values ​​of each pixel in the grayscale image, and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel;

[0032] Calculate the grayscale threshold; count the gradient values ​​of all pixels, select a gradient value as the gradient threshold, and calculate the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold;

[0033] Binarize the image; according to the grayscale threshold, set the pixel points whose grayscale values ​​in the grayscale image are greater than the grayscale threshold as black points, and set the pixel points whose grayscale values ​​are less than the grayscale threshold as white points, so as to generate a binary image;

[0034] Character correction: According to the morphological contour of the character in the binary image, the edge change of the target pixel point of its binary contour image is obtained, and the character type is determined according to which character's morphological characteristics are satisfied by the edge change.

[0035] Furthermore, the specific steps of traversing the grayscale values ​​of each pixel in the grayscale image and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel are:

[0036] Select a pixel point in the target character image to be corrected as the coordinate origin to establish a horizontal rectangular coordinate system;

[0037] The gray value corresponding to the pixel is recorded as P(x, y);

[0038] The gradient value G of each pixel is calculated according to the following formula:

[0039]

[0040] Furthermore, the specific steps of counting the gradient values ​​of all pixels, selecting a gradient value as a gradient threshold, and calculating the grayscale average value of pixels exceeding the gradient threshold as the grayscale threshold are:

[0041] Count the gradient values ​​of all pixels and get the number of pixels corresponding to each gradient value;

[0042] The gradient value corresponding to the number of pixels exceeding 25% of the total number of pixels is taken as the gradient threshold;

[0043] The grayscale values ​​of all pixels whose gradient values ​​are greater than the gradient threshold are counted, and the average is taken as the grayscale threshold.

[0044] Furthermore, the specific steps of character correction are:

[0045] Set up an array, and record the x coordinates of the last pixel set as a white point in each row of the grayscale image into the array in sequence;

[0046] Draw a change curve according to the change of x coordinate in the array;

[0047] The character type in the grayscale image is corrected according to the contour of the variation curve.

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

[0049] 1. The present invention discloses a method and device for recognizing easily confused characters based on grayscale images. By judging whether the character type belongs to easily confused characters and whether there is a possibility of misreading, once there is a greater possibility of misreading, the outline is binarized based on the grayscale image of the character to find the outline corresponding to the character. The character is re-judged based on the morphological characteristics of the outline, which can reduce the recognition error rate between easily confused characters, reduce the time consumption of manual correction, and improve the efficiency of OCR recognition.

[0050] 2. The present invention provides a method and device for identifying easily confused characters based on grayscale images. The method and device identify the pixel points in the grayscale jump area of ​​the grayscale image by calculating the gradient value, and then calculate the grayscale threshold used to identify the contour boundary according to the grayscale value of the pixel points in the grayscale jump area. The grayscale image can be accurately binarized according to the grayscale threshold.

[0051] 3. The present invention provides a method and device for recognizing easily confused characters based on grayscale images. By drawing a change curve based on the position of the last pixel point set as a white point in each row of the grayscale image, the outline of the character can be vividly represented, thereby improving the efficiency and accuracy of character recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 A flowchart of an embodiment of the present invention;

[0053] Figure 2 An example diagram of a grayscale image in an embodiment of the present invention;

[0054] Figure 3 : is an example diagram of a binary image of a character P in an embodiment of the present invention;

[0055] Figure 4 : is an example diagram of a binary image of a character F in an embodiment of the present invention;

[0056] Figure 5 This is an example diagram of a change curve of a character P in an embodiment of the present invention;

[0057] Figure 6 2 is an example diagram of a change curve of a character F in an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0059] Embodiment 1:

[0060] See also Figure 1 , a method for identifying easily confused characters based on grayscale images, comprising the following steps:

[0061] Preliminary recognition: input the original image, use a text recognition engine, such as OCR technology and a neural network model (for example, the currently relatively mature deep learning network model for target detection, such as Faster-RCNN, SSD and Yolo, etc.) to identify the character type in the original image, and determine whether the character is an easily confused character based on the character type. Here, easily confused characters are defined as characters that are similar in shape and easy to be misidentified, and after being recognized by the text recognition engine, the possible probabilities of the two characters are similar, such as P and F, L and I, etc. Once the recognition probabilities of the two characters are similar, they are easily confused characters. The easily confused characters can be entered into the system in advance, and the system determines whether the recognized characters are easily confused characters. If they are easily confused characters, correction processing is performed. If they are not easily confused characters, they are skipped and the recognition result is retained without correction processing, and the recognition result of the character is directly output.

[0062] In this embodiment, based on the grayscale image of the original character, by finding the morphological contour corresponding to the character image, the morphological contour is re-judged and corrected to reduce the recognition error rate of easily confused characters in the OCR recognition process, reduce the time consumption of manual proofreading and correction, and thus improve the efficiency of OCR recognition. The correction process includes the following steps:

[0063] See also Figure 2 In a grayscale image, there is a relatively obvious grayscale jump between the upper and lower adjacent pixels and the left and right adjacent pixels at the edge contour of the image. Therefore, the image can be binarized according to the grayscale gradient difference between adjacent pixels to obtain a contour binary image;

[0064] First, the gradient of a pixel relative to its adjacent pixels is obtained, a grayscale image of the character is obtained, the grayscale values ​​of each pixel in the grayscale image are traversed, and the gradient value of each pixel is calculated based on the grayscale difference between each pixel and its adjacent pixels;

[0065] Calculate the grayscale threshold. Since the grayscale value of each pixel in the grayscale image ranges from 0 to 255, the grayscale gradient difference between pixels also ranges from 0 to 255. Prepare an array T of size 256, initialized to 0, to count the number of pixels corresponding to each gradient value. Count the gradient values ​​of all pixels. Generally, the boundaries of the image, where the grayscale jump is obvious, have larger gradient values. Therefore, in order to obtain a rough binary contour map;

[0066] See also Figure 3 and Figure 4, binarize the image, and according to the grayscale threshold, set the pixel points whose grayscale values ​​in the grayscale image are greater than the grayscale threshold as black points (that is, the pixel values ​​are set to 0), and set the pixel points whose grayscale values ​​are less than the grayscale threshold as white points (that is, the pixel values ​​are set to 255), to generate a binary image, Figure 3 is the binary image of character P, Figure 4 is the binary image of the character F.

[0067] Character correction: Determine the character type of the character based on the morphological outline of the character in the binary image; if the character type recognized by the binary image is inconsistent with the character type recognized by the text recognition engine, correction is performed to replace the previously recognized character type with the character type recognized by the binary image; if the recognized character types are consistent, no processing is performed.

[0068] After the character type is determined by the text recognition engine for the image, this embodiment further determines whether the character type is an easily confused character and whether there is a possibility of misreading. Once there is a greater possibility of misreading, the contour is binarized based on the grayscale image of the character to find the contour corresponding to the character. The character is re-judged based on the morphological characteristics of the contour, which can reduce the recognition error rate between easily confused characters, reduce the time spent on manual correction, and improve the efficiency of OCR recognition.

[0069] Embodiment 2:

[0070] Furthermore, the specific steps of traversing the grayscale values ​​of each pixel in the grayscale image and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel are:

[0071] A pixel point in the target character image to be corrected is selected as the coordinate origin to establish a horizontal rectangular coordinate system; Figure 2 As shown, the pixel point in the upper left corner of the image is the coordinate origin, the horizontal right is the positive x direction, the vertical downward is the positive y direction, the image width is w, and the height is h. In order to calculate the grayscale difference between the upper and lower adjacent pixels and the left and right adjacent pixels of each pixel in the original image, the gradient difference corresponding to the pixel points (x, y) in the original image within the range of 1 to w-2 in the x direction and 1 to h-2 in the y direction is counted here;

[0072] The grayscale value corresponding to the pixel is recorded as P(x,y), where x∈[1,w-2],y∈[1,h-2].

[0073] The corresponding gradient G(x,y) calculation formula includes but is not limited to:

[0074]

[0075] The corresponding gradient G is obtained and the number of statistics is calculated, T G =T G +1(G∈[0,255]).

[0076] Furthermore, the specific steps of selecting a gradient value as the gradient threshold and calculating the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold are:

[0077] Calculate the gradient value for each pixel within the range, and count the gradient values ​​of (w-2)*(h-2) pixels in total to get the number of pixels corresponding to each gradient value. Since the grayscale jump at the boundary contour is more obvious, that is, the corresponding gradient value is larger, a higher value is taken as the gradient threshold for the statistically obtained gradient. Here, the number of pixels corresponding to the highest gradient value is counted and summed up, and the gradient value corresponding to more than 25% of the total number of pixels is taken as the gradient threshold G. n (n∈[0,255]); Taking 25% as the threshold, the complete outline of the character can be obtained well, that is, at least the number of outline points is guaranteed to exceed 1 / 4 of the total number of pixels in the character image. And this threshold can better highlight the morphological features of the character.

[0078]

[0079] According to the selected gradient threshold, once the gradient value G(x,y) corresponding to a point in the gradient image is greater than the gradient threshold, it can be considered that the point (x,y) in the original grayscale image may be at the boundary contour position, and the grayscale values ​​P(x,y) of the pixels corresponding to these possible boundary contour positions are calculated and counted, and the average is taken as the grayscale threshold P n : Where P(x,y) must satisfy the condition G(x,y)>G n , m is the number of pixels that meet the conditions.

[0080] Furthermore, the specific steps of correcting the character type of the character according to the morphological contour of the character in the binary image are:

[0081] Prepare an array of size h of the binary image height, and record the x coordinates of the last pixel set as a white point in each row of the grayscale image into the array in sequence;

[0082] The position of the last white pixel corresponding to each row of a binary image with a width of w and a height of h is recorded in the negative direction of the y-axis from the lower right corner (w-1, h-1) of the image, and the change curve is drawn by obtaining the change of the x-coordinate in the array;

[0083] See also Figure 5 and Figure 6 , Figure 5 is the change curve of character P, Figure 6 is the change curve of the character F. The position of the last pixel white point corresponding to each line obtained by recording, if it is within the range of image height h, the position of the last pixel white point recorded {x0,x1,x2,.....,x h-1 If the value of} shows an obvious trend of increasing first, then decreasing, and then increasing again, that is, there are two peaks, and there is a trough between the two peaks, it can be judged that the character is F. If there is only one peak, and there is no trough between the peaks, it can be considered as the letter P.

[0084] Embodiment three:

[0085] A device for recognizing easily confused characters based on grayscale images, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the program:

[0086] Initial recognition: input the original image, identify the character type in the original image through OCR technology and neural network models (for example, the currently relatively mature deep learning network models for target detection, such as Faster-RCNN, SSD and Yolo, etc.), and determine whether the character is an easily confused character based on the character type. Here, easily confused characters are defined as characters that are similar in shape and easy to be misidentified, and after being recognized by the text recognition engine, the possible probabilities of the two characters are similar, such as P and F, L and I, etc. Once the recognition probabilities of the two characters are similar, they are easily confused characters. The easily confused characters can be entered into the system in advance, and the system determines whether the recognized characters are easily confused characters. If they are easily confused characters, correction processing is performed. If they are not easily confused characters, they are skipped and the recognition result is retained without correction processing, and the recognition result of the character is directly output.

[0087] In this embodiment, based on the grayscale image of the original character, by finding the morphological contour corresponding to the character image, the morphological contour is re-judged and corrected to reduce the recognition error rate of easily confused characters in the OCR recognition process, reduce the time consumption of manual proofreading and correction, and thus improve the efficiency of OCR recognition. The correction process includes the following steps:

[0088] See also Figure 2 In a grayscale image, there is a relatively obvious grayscale jump between the upper and lower adjacent pixels and the left and right adjacent pixels at the edge contour of the image. Therefore, the image can be binarized according to the grayscale gradient difference between adjacent pixels to obtain a contour binary image;

[0089] First, the gradient of a pixel relative to its adjacent pixels is obtained, a grayscale image of the character is obtained, the grayscale values ​​of each pixel in the grayscale image are traversed, and the gradient value of each pixel is calculated based on the grayscale difference between each pixel and its adjacent pixels;

[0090] Calculate the grayscale threshold. Since the grayscale value of each pixel in the grayscale image ranges from 0 to 255, the grayscale gradient difference between pixels also ranges from 0 to 255. Prepare an array T of size 256, initialized to 0, to count the number of pixels corresponding to each gradient value. Count the gradient values ​​of all pixels. Generally, the boundaries of the image, where the grayscale jump is obvious, have larger gradient values. Therefore, in order to obtain a rough binary contour map;

[0091] See also Figure 3 and Figure 4 , binarize the image, and according to the grayscale threshold, set the pixel points whose grayscale values ​​in the grayscale image are greater than the grayscale threshold as black points (that is, the pixel values ​​are set to 0), and set the pixel points whose grayscale values ​​are less than the grayscale threshold as white points (that is, the pixel values ​​are set to 255), to generate a binary image, Figure 3 is the binary image of character P, Figure 4 is the binary image of the character F.

[0092] Character correction: Determine the character type of the character based on the morphological outline of the character in the binary image; if the character type recognized by the binary image is inconsistent with the character type recognized by the text recognition engine, correction is performed to replace the previously recognized character type with the character type recognized by the binary image; if the recognized character types are consistent, no processing is performed.

[0093] After the character type is determined by the text recognition engine for the image, this embodiment further determines whether the character type is an easily confused character and whether there is a possibility of misreading. Once there is a greater possibility of misreading, the contour is binarized based on the grayscale image of the character to find the contour corresponding to the character. The character is re-judged based on the morphological characteristics of the contour, which can reduce the recognition error rate between easily confused characters, reduce the time spent on manual correction, and improve the efficiency of OCR recognition.

[0094] Embodiment 4:

[0095] Furthermore, the specific steps of traversing the grayscale values ​​of each pixel in the grayscale image and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel are:

[0096] A pixel point in the target character image to be corrected is selected as the coordinate origin to establish a horizontal rectangular coordinate system; Figure 2As shown, the pixel point in the upper left corner of the image is the coordinate origin, the horizontal right is the positive x direction, the vertical downward is the positive y direction, the image width is w, and the height is h. In order to calculate the grayscale difference between the upper and lower adjacent pixels and the left and right adjacent pixels of each pixel in the original image, the gradient difference corresponding to the pixel points (x, y) in the original image within the range of 1 to w-2 in the x direction and 1 to h-2 in the y direction is counted here;

[0097] The grayscale value corresponding to the pixel is recorded as P(x,y), where x∈[1,w-2],y∈[1,h-2].

[0098] The corresponding gradient G(x,y) calculation formula includes but is not limited to:

[0099]

[0100] The corresponding gradient G is obtained and the number of statistics is calculated, T G =T G +1(G∈[0,255]).

[0101] Furthermore, the specific steps of selecting a gradient value as the gradient threshold and calculating the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold are:

[0102] Calculate the gradient value for each pixel within the range, and count the gradient values ​​of (w-2)*(h-2) pixels in total to get the number of pixels corresponding to each gradient value. Since the grayscale jump at the boundary contour is more obvious, that is, the corresponding gradient value is larger, a higher value is taken as the gradient threshold for the statistically obtained gradient. Here, the number of pixels corresponding to the highest gradient value is counted and summed up, and the gradient value corresponding to more than 25% of the total number of pixels is taken as the gradient threshold G. n (n∈[0,255]).

[0103]

[0104] According to the selected gradient threshold, once the gradient value G(x,y) corresponding to a point in the gradient image is greater than the gradient threshold, it can be considered that the point (x,y) in the original grayscale image may be at the boundary contour position, and the grayscale values ​​P(x,y) of the pixels corresponding to these possible boundary contour positions are calculated and counted, and the average is taken as the grayscale threshold P n : Where P(x,y) must satisfy the condition G(x,y)>G n , m is the number of pixels that meet the conditions.

[0105] Furthermore, the specific steps of correcting the character type of the character according to the morphological contour of the character in the binary image are:

[0106] Prepare an array of size h of the binary image height, and record the x coordinates of the last pixel set as a white point in each row of the grayscale image into the array in sequence;

[0107] The position of the last white pixel corresponding to each row of a binary image with a width of w and a height of h is recorded in the negative direction of the y-axis from the lower right corner (w-1, h-1) of the image, and the change curve is drawn by obtaining the change of the x-coordinate in the array;

[0108] See also Figure 5 and Figure 6 , Figure 5 is the change curve of character P, Figure 6 is the change curve of the character F. The position of the last pixel white point corresponding to each line obtained by recording, if it is within the range of image height h, the position of the last pixel white point recorded {x0,x1,x2,.....,x h-1 If the value of} shows an obvious trend of increasing first, then decreasing, and then increasing again, that is, there are two peaks, and there is a trough between the two peaks, it can be judged that the character is F. If there is only one peak, and there is no trough between the peaks, it can be considered as the letter P.

[0109] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for correcting easily confused characters based on grayscale images, characterized in that: The following steps are involved: Initial recognition: inputting the original image, identifying the character type in the image through the text recognition engine, and judging whether the character is an easily confused character according to the character type. The easily confused character is a character that is similar in shape and easily misidentified; If it is a confusing character, correct it; If it does not belong to the category, it will be skipped and the recognition result will be retained without correction. The correction process comprises the following steps: Obtaining the pixel gradient of the character image; obtaining the grayscale image of the character, traversing the grayscale values ​​of each pixel in the grayscale image, and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel; Calculate the grayscale threshold; count the gradient values ​​of all pixels, select a gradient value as the gradient threshold, and calculate the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold; Binarize the image; according to the grayscale threshold, set the pixel points whose grayscale values ​​in the grayscale image are greater than the grayscale threshold as black points, and set the pixel points whose grayscale values ​​are less than the grayscale threshold as white points, so as to generate a binary image; Character correction: According to the morphological contour of the character in the binary image, the edge change of the target pixel point of its binary contour image is obtained, and the character type is determined based on which character's morphological characteristics the edge change satisfies.

2. A method for correcting easily confused characters based on grayscale images according to claim 1, characterized in that: The specific steps of traversing the grayscale values ​​of each pixel in the grayscale image and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixels are: Select a pixel point in the target character image to be corrected as the coordinate origin to establish a horizontal rectangular coordinate system; The gray value corresponding to the pixel is recorded as P(x, y); The gradient value G of each pixel is calculated according to the following formula:

3. The method for correcting easily confused characters based on grayscale images according to claim 2, characterized in that: The specific steps of counting the gradient values ​​of all pixels, selecting a gradient value as the gradient threshold, and calculating the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold are as follows: Count the gradient values ​​of all pixels and get the number of pixels corresponding to each gradient value; The gradient value corresponding to the number of pixels exceeding 25% of the total number of pixels is taken as the gradient threshold; The grayscale values ​​of all pixels whose gradient values ​​are greater than the gradient threshold are counted, and the average is taken as the grayscale threshold.

4. The method for correcting easily confused characters based on grayscale images according to claim 2, characterized in that: The specific steps of character correction are: Set up an array, and record the x coordinates of the last pixel set as a white point in each row of the grayscale image into the array in sequence; Draw a change curve according to the change of x coordinate in the array; The character type in the grayscale image is corrected according to the contour of the variation curve.

5. A device for identifying easily confused characters based on grayscale images, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the following steps are implemented: Initial recognition: inputting the original image, identifying the character type in the image through the text recognition engine, and judging whether the character is an easily confused character according to the character type. The easily confused character is a character that is similar in shape and easily misidentified; If it is a confusing character, correct it; If it does not belong to the category, it will be skipped and the recognition result will be retained without correction. The correction process comprises the following steps: Obtaining the pixel gradient of the character image; obtaining the grayscale image of the character, traversing the grayscale values ​​of each pixel in the grayscale image, and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixel; Calculate the grayscale threshold; count the gradient values ​​of all pixels, select a gradient value as the gradient threshold, and calculate the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold; Binarize the image; according to the grayscale threshold, set the pixel points whose grayscale values ​​in the grayscale image are greater than the grayscale threshold as black points, and set the pixel points whose grayscale values ​​are less than the grayscale threshold as white points, so as to generate a binary image; Character correction: According to the morphological contour of the character in the binary image, the edge change of the target pixel point of its binary contour image is obtained, and the character type is determined according to which character's morphological characteristics are satisfied by the edge change.

6. The device for recognizing easily confused characters based on grayscale images according to claim 5, characterized in that: The specific steps of traversing the grayscale values ​​of each pixel in the grayscale image and calculating the gradient value of each pixel based on the grayscale difference between each pixel and its adjacent pixels are: Select a pixel point in the target character image to be corrected as the coordinate origin to establish a horizontal rectangular coordinate system; The gray value corresponding to the pixel is recorded as P(x, y); The gradient value G of each pixel is calculated according to the following formula:

7. The device for recognizing easily confused characters based on grayscale images according to claim 6, characterized in that: The specific steps of counting the gradient values ​​of all pixels, selecting a gradient value as the gradient threshold, and calculating the grayscale average value of the pixels exceeding the gradient threshold as the grayscale threshold are as follows: Count the gradient values ​​of all pixels and get the number of pixels corresponding to each gradient value; The gradient value corresponding to the number of pixels exceeding 25% of the total number of pixels is taken as the gradient threshold; The grayscale values ​​of all pixels whose gradient values ​​are greater than the gradient threshold are counted, and the average is taken as the grayscale threshold.

8. The device for recognizing easily confused characters based on grayscale images according to claim 6, characterized in that: The specific steps of character correction are: Set up an array, and record the x coordinates of the last pixel set as a white point in each row of the grayscale image into the array in sequence; Draw a change curve according to the change of x coordinate in the array; The character type in the grayscale image is corrected according to the contour of the variation curve.