Character recognition method, device, electronic device and computer readable storage medium

By using the feature matrix matching technology of grayscale images in character recognition, the problem of feature loss caused by binarization processing is solved and the accuracy of character recognition is improved.

CN113255674BActive Publication Date: 2024-09-03SHENZHEN YIHUA TIMES SMART AUTOMATION SYST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010960287.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-14
Publication Date
2024-09-03
Estimated Expiration
2040-09-14

AI Technical Summary

Technical Problem

Existing character recognition methods easily lose character features through binarization processing, resulting in reduced recognition accuracy.

Method used

By obtaining the grayscale image of the character to be recognized, the first feature matrix is ​​determined according to the pixel grayscale value in the grayscale image, and matched with the second feature matrix of the preset character, and the similarity is calculated to identify the character.

Benefits of technology

It retains more features of the characters to be recognized and preset characters, improving the accuracy of character recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113255674B
    Figure CN113255674B
Patent Text Reader

Abstract

The present application is applicable to the field of image processing technology, and provides a character recognition method, device, electronic device and computer-readable storage medium. The character recognition method includes: obtaining a grayscale image of a character to be recognized, the grayscale image includes at least one pixel, determining a first feature matrix of the character to be recognized according to the grayscale value of the at least one pixel, determining the similarity between the character to be recognized and a preset character according to the first feature matrix and a second feature matrix of the preset character, wherein the second feature matrix is ​​determined according to the grayscale values ​​of the pixels of the grayscale image of the preset character, and identifying whether the character to be recognized is a preset character according to the similarity. Since the first feature matrix and the second feature matrix retain more character features, the accuracy of character recognition is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing technology, and in particular, relates to a character recognition method, device, electronic device, and computer-readable storage medium. Background Art

[0002] With the development of image processing technology, image processing technology is applied to more and more fields. For example, image processing technology can be used to identify characters contained in images. The existing method of identifying characters using image processing technology generally binarizes the image containing characters, extracts character features based on the character structure in the obtained binary image, and then recognizes the characters based on the extracted character features. However, in some images, since the image texture of the characters contained therein is fine, it is easy to lose some character features when extracting character features from the binarized image obtained after binarization, resulting in the extracted character features failing to express the true features of the characters, thereby reducing the accuracy of character recognition. Summary of the invention

[0003] In view of this, embodiments of the present application provide a character recognition method, device, electronic device, and computer-readable storage medium, which can improve the accuracy of character recognition.

[0004] A first aspect of an embodiment of the present application provides a character recognition method, comprising:

[0005] Acquire a grayscale image of a character to be recognized, wherein the grayscale image includes at least one pixel;

[0006] Determining a first feature matrix of the character to be recognized according to the grayscale value of the at least one pixel;

[0007] Determining the similarity between the character to be recognized and the preset character according to the first feature matrix and a second feature matrix of the preset character, wherein the second feature matrix is ​​determined according to the grayscale values ​​of pixels of the grayscale image of the preset character;

[0008] It is determined whether the character to be identified is the preset character according to the similarity.

[0009] In a possible implementation manner of the first aspect, determining the first feature matrix of the to-be-recognized character according to the grayscale value of the at least one pixel includes:

[0010] Dividing the grayscale image of the character to be recognized into at least one region, each of the regions including at least one pixel;

[0011] Determine a characteristic value of a corresponding area according to the grayscale value of pixels in each of the areas;

[0012] The first characteristic matrix is ​​determined according to the eigenvalues.

[0013] In a possible implementation manner of the first aspect, determining a feature value of a corresponding region according to a grayscale value of a pixel in each of the regions includes:

[0014] The grayscale value of each pixel in each of the regions is calculated, and the minimum grayscale value is used as the feature value of the corresponding region.

[0015] In a possible implementation manner of the first aspect, determining a feature value of a corresponding region according to a grayscale value of a pixel in each of the regions includes:

[0016] The grayscale value of each pixel in each of the regions is calculated, and the minimum grayscale value is inverted to be used as the feature value of the corresponding region.

[0017] In a possible implementation manner of the first aspect, obtaining a grayscale image of a character to be recognized includes:

[0018] Obtain the original grayscale image of the character to be recognized;

[0019] The original grayscale image is scaled to a preset size to obtain a grayscale image of the character to be recognized.

[0020] In a possible implementation manner of the first aspect, determining the similarity between the character to be recognized and the preset character according to the first feature matrix and a second feature matrix of the preset character includes:

[0021] Performing preset processing on the first feature matrix to obtain an activation coefficient matrix;

[0022] The similarity between the character to be recognized and the preset character is determined according to the activation coefficient matrix and the second feature matrix of the preset character.

[0023] In a possible implementation manner of the first aspect, determining the similarity between the character to be recognized and the preset character according to the activation coefficient matrix and the second feature matrix of the preset character includes:

[0024] Performing Laplace smoothing processing on the second characteristic matrix to obtain a processed matrix;

[0025] The similarity between the character to be recognized and the preset character is determined according to the activation coefficient matrix and the processed matrix.

[0026] In a possible implementation manner of the first aspect, before determining the similarity between the character to be recognized and the preset character according to the first feature matrix and the second feature matrix of the preset character, the character recognition method further includes:

[0027] Acquire at least one character sample of the preset character;

[0028] Calculate the third feature matrix of each character sample;

[0029] The third characteristic matrix is ​​normalized to obtain a second characteristic matrix of the preset character.

[0030] In a possible implementation manner of the first aspect, determining the similarity between the character to be recognized and the preset character according to the first feature matrix and a second feature matrix of the preset character includes:

[0031] Determining the similarity between the character to be recognized and each of the preset characters according to the first feature matrix and the second feature matrix of each preset character;

[0032] Correspondingly, the identifying whether the character to be identified is the preset character according to the similarity includes:

[0033] Determine the maximum value of the similarities; and take the preset character corresponding to the maximum value of the similarities as the recognition result.

[0034] A second aspect of an embodiment of the present application provides a character recognition device, comprising:

[0035] An acquisition module, used for acquiring a grayscale image of a character to be recognized, wherein the grayscale image includes at least one pixel;

[0036] A first calculation module, used for determining a first characteristic matrix of the character to be recognized according to the gray value of the at least one pixel;

[0037] A second calculation module, used for determining the similarity between the character to be recognized and the preset character according to the first feature matrix and a second feature matrix of the preset character, wherein the second feature matrix is ​​determined according to the grayscale values ​​of pixels of the grayscale image of the preset character;

[0038] The recognition module is used to recognize whether the character to be recognized is the preset character according to the similarity.

[0039] In a possible implementation manner of the second aspect, the first calculation module includes:

[0040] A division unit, used for dividing the grayscale image of the character to be recognized into at least one region, each of which includes at least one pixel;

[0041] A first determining unit, configured to determine a feature value of a corresponding area according to a grayscale value of a pixel in each of the areas;

[0042] The second determining unit is configured to determine the first characteristic matrix according to the characteristic value.

[0043] In a possible implementation manner of the second aspect, the first determining unit is specifically configured to:

[0044] The grayscale value of each pixel in each of the regions is calculated, and the minimum grayscale value is used as the feature value of the corresponding region.

[0045] In a possible implementation manner of the second aspect, the first determining unit is specifically configured to:

[0046] The grayscale value of each pixel in each of the regions is calculated, and the minimum grayscale value is inverted to be used as the feature value of the corresponding region.

[0047] In a possible implementation manner of the second aspect, the acquisition module is specifically configured to:

[0048] Obtain the original grayscale image of the character to be recognized;

[0049] The original grayscale image is scaled to a preset size to obtain a grayscale image of the character to be recognized.

[0050] In a possible implementation manner of the second aspect, the second calculation module is specifically configured to:

[0051] Performing preset processing on the first feature matrix to obtain an activation coefficient matrix;

[0052] The similarity between the character to be recognized and the preset character is determined according to the activation coefficient matrix and the second feature matrix of the preset character.

[0053] In a possible implementation manner of the second aspect, the second calculation module is further configured to:

[0054] Performing Laplace smoothing processing on the second characteristic matrix to obtain a processed matrix;

[0055] The similarity between the character to be recognized and the preset character is determined according to the activation coefficient matrix and the processed matrix.

[0056] In a possible implementation manner of the second aspect, the first calculation module is further configured to:

[0057] Acquire at least one character sample of the preset character;

[0058] Calculate the third feature matrix of each character sample;

[0059] The third characteristic matrix is ​​normalized to obtain a second characteristic matrix of the preset character.

[0060] In a possible implementation manner of the second aspect, the second calculation module is further configured to:

[0061] Determining the similarity between the character to be recognized and each of the preset characters according to the first feature matrix and the second feature matrix of each preset character;

[0062] Correspondingly, the identification module is specifically used for:

[0063] determining a maximum value among the similarities;

[0064] The preset character corresponding to the maximum value of the similarities is taken as the recognition result.

[0065] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the character recognition method as described in the first aspect above is implemented.

[0066] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the character recognition method as described in the first aspect above is implemented.

[0067] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the character recognition method described in the first aspect.

[0068] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by acquiring a grayscale image of a character to be recognized, determining a first feature matrix of the character to be recognized according to the grayscale values ​​of pixels in the grayscale image of the character to be recognized, determining the similarity between the character to be recognized and the preset character according to the first feature matrix and the second feature matrix of the preset character, and then identifying whether the character to be recognized is the preset character according to the similarity. Since the first feature matrix determined according to the grayscale values ​​of pixels in the grayscale image of the character to be recognized retains more character features of the character to be recognized, and since the second feature matrix is ​​determined according to the grayscale values ​​of pixels in the grayscale image of the preset character, more character features of the preset character are retained. Therefore, character recognition based on the similarity determined by the first feature matrix and the second feature matrix is ​​more accurate, thereby improving the accuracy of character recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0070] Figure 1 It is a schematic diagram of the implementation flow of the character recognition method provided in the embodiment of the present application;

[0071] Figure 2 It is a schematic diagram of an image of a banknote serial number provided in an embodiment of the present application;

[0072] Figure 3 is a schematic diagram of an original grayscale image provided by an embodiment of the present application;

[0073] Figure 4 A grayscale image of a preset size provided in an embodiment of the present application;

[0074] Figure 5 A grayscale image after equalization processing provided in an embodiment of the present application;

[0075] Figure 6 A grayscale image after dividing the regions provided in an embodiment of the present application;

[0076] Figure 7 A grayscale image after the grayscale value is reversed provided in an embodiment of the present application;

[0077] Figure 8 A schematic diagram of the calculation results of the similarity provided in the embodiment of the present application;

[0078] Fig. 9 A schematic diagram of a character recognition device provided in an embodiment of the present application;

[0079] Fig.10 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0080] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0081] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.

[0082] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0083] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0084] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0085] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0086] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0087] The existing character recognition method generally binarizes the image containing the characters, extracts the character features based on the character structure in the obtained binarized image, and then recognizes the characters according to the extracted character features. However, the image processed by binarization is prone to lose the character features, resulting in a decrease in the accuracy of character recognition. To this end, the present application provides a character recognition method, which obtains a grayscale image of the character to be recognized, determines a first feature matrix of the character to be recognized according to the grayscale values ​​of the pixels in the grayscale image, determines the similarity between the character to be recognized and the preset character according to the first feature matrix and the second feature matrix of the preset character, and then recognizes whether the character to be recognized is the preset character according to the similarity. Since the first feature matrix determined according to the grayscale values ​​of the pixels in the grayscale image of the character to be recognized retains more character features of the character to be recognized, and since the second feature matrix is ​​determined according to the grayscale values ​​of the pixels in the grayscale image of the preset character, it retains more character features of the preset character. Therefore, the character recognition according to the similarity determined by the first feature matrix and the second feature matrix is ​​more accurate, thereby improving the accuracy of character recognition.

[0088] The character recognition method provided in this application is exemplarily described below in conjunction with specific embodiments.

[0089] The character recognition method provided in the embodiment of the present application is applied to an electronic device, and the electronic device may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server.

[0090] Please refer to the attached Figure 1 , the character recognition method provided in the embodiment of the present application includes:

[0091] S101: Acquire a grayscale image of a character to be recognized, wherein the grayscale image includes at least one pixel.

[0092] The character to be recognized is a character on the text to be recognized, the text to be recognized may be a banknote serial number, or a text on a newspaper or web page, and the character may be a letter, a number, or a Chinese character, etc. The character recognition method provided in the embodiment of the present application is described below by taking the text to be recognized as a banknote serial number and the character to be recognized as a number in the banknote serial number as an example.

[0093] The grayscale image may be obtained by segmenting the image of the banknote serial number, or by first segmenting the image of the banknote serial number and then preprocessing the segmented image.

[0094] In one possible implementation, an electronic device segments the image of the serial number of a banknote to obtain an original grayscale image, and normalizes the original grayscale image to obtain a grayscale image of the character to be recognized, wherein the normalization process is to scale the original grayscale image to a preset size. By setting the grayscale image to the preset size, subsequent comparison with a template is facilitated to calculate the similarity between the character to be recognized and the preset character.

[0095] In another possible implementation, the electronic device scales the original grayscale image to a preset size and then equalizes the grayscale image of the preset size to obtain a grayscale image of the character to be recognized, wherein equalization can improve the distinction between the characters and the background in the image and weaken the impact of background brightness differences to improve the accuracy of image recognition.

[0096] For example, Figure 2 The image of the banknote serial number shown in the figure is segmented to obtain the following Figure 3 The grayscale image of the number "2" shown in the figure, that is, the original grayscale image, sets the preset size to 32*32 pixels, and scales the original grayscale image to the preset size to obtain the following Figure 4 The grayscale image of the preset size is equalized to obtain the grayscale image of the preset size. Figure 5 The grayscale image after equalization processing shown is the grayscale image of the character to be recognized.

[0097] S102: Determine a first feature matrix of the character to be recognized according to the grayscale value of the at least one pixel.

[0098] Specifically, the eigenvalue is calculated according to the gray value of at least one pixel, and the eigenvalue is used as an element in the first feature matrix. Since the eigenvalue is determined according to the gray value of the pixel, the position of the eigenvalue in the first feature matrix reflects the position of the pixel in the gray image, so the first feature matrix can represent more character features in the gray image, thereby improving the accuracy of character recognition.

[0099] In a possible implementation, the grayscale image of the character to be recognized is first divided into several equal-sized regions according to the number of pixels. An region may have only one pixel or more than two pixels. For example, if the size of the grayscale image of the character to be recognized is 32*32 pixels, then the grayscale image is divided into N regions, where N=(32 / S)*(32 / S), and S is an integer. When S=1, the grayscale image is divided into 1024 regions, and when S=2, the grayscale image is divided into 256 regions, and so on. For example, Figure 6 As shown, the pixel of the grayscale image is 32*32, and the grayscale image is divided into 1024 regions.

[0100] After the grayscale image of the character to be recognized is divided into several regions, the feature value of the corresponding region is determined according to the grayscale value of the pixels in each region. If there is only one pixel in one region after the grayscale image is divided into several regions, the grayscale value of the pixel in each region is the feature value of the corresponding region; if there are more than two pixels in one region after the grayscale image is divided into several regions, the grayscale value of each pixel in each region is calculated, and the minimum grayscale value is used as the feature value of the corresponding region. Experiments show that using the minimum grayscale value as the feature value of the corresponding region can improve the accuracy of the calculation.

[0101] In one possible implementation, if the grayscale value of the character to be recognized is low and the grayscale value of the background is high, for example, the grayscale value of each character in the image of the banknote serial number is low and the background grayscale value is high, after obtaining the minimum grayscale value of each area, the minimum grayscale value is inverted as the feature value, that is, 255 minus the minimum grayscale value is used as the feature value, so that a feature value with a larger grayscale value can be obtained, thereby highlighting the grayscale value of the character part and improving the accuracy of character recognition. For example, the grayscale value of the pixel of the grayscale image of the character to be recognized is inverted to obtain the following Figure 7 The grayscale image shown, Figure 7 The grayscale image can highlight the characters in the grayscale image.

[0102] After calculating the eigenvalue of each region, the first feature matrix is ​​generated according to the eigenvalue according to the position of each region, where the eigenvalue is the element at the corresponding position in the first feature matrix. For example, if the grayscale image of the character to be recognized is divided into W*H regions, the width of the generated first feature matrix is ​​W and the height is H, so that the elements in the first feature matrix correspond to each region in the grayscale image one by one, and then the first feature matrix can represent the complete character features of the character to be recognized, thereby improving the accuracy of subsequent character recognition.

[0103] S103: Determine the similarity between the character to be recognized and the preset character according to the first feature matrix and a second feature matrix of the preset character, wherein the second feature matrix is ​​determined according to the grayscale values ​​of pixels of the grayscale image of the preset character.

[0104] The preset character is a character template, and the grayscale image of the preset character is normalized and equalized, and the equalized image is divided into at least one region, and the second feature matrix is ​​determined according to the grayscale value of the pixel in each region. The process of calculating the second feature matrix according to the preset character is the same as the process of calculating the first feature matrix according to the character to be recognized, and will not be repeated here.

[0105] In this embodiment, after the first feature matrix and the second feature matrix are obtained, the similarity between the first feature matrix and the second feature matrix is ​​calculated, and the similarity is the similarity between the character to be recognized and the preset character.

[0106] In one possible implementation, the product of the first feature matrix and the second feature matrix can be used as the calculation result of the similarity. Since the product between matrices can reflect the similarity between the matrices, and the first feature matrix retains more character features of the characters to be recognized, and the second feature matrix retains more character features of the preset characters, the product of the first feature matrix and the second feature matrix can characterize the similarity between the characters to be recognized and the preset characters, and the characters to be recognized are recognized based on the similarity, thereby improving the recognition accuracy.

[0107] In one possible implementation, the second feature matrix is ​​obtained based on multiple character samples of preset characters. Specifically, for each character sample, normalization and equalization are first performed, and then the equalized image is divided into at least one region, and the eigenvalue of the corresponding region is determined according to the grayscale value of the pixel in each region, and a third feature matrix is ​​generated according to the eigenvalue and the position of the eigenvalue, and the elements in the third feature matrix are the eigenvalues ​​of the corresponding position. After obtaining the third feature matrix corresponding to each character sample, the third feature matrix is ​​normalized to obtain the second feature matrix of the preset character. In one possible implementation, the formula for normalizing the third feature matrix is: Template = Sum / n, where Matrix(i) represents the third feature matrix, Template represents the second feature matrix, and n is the number of character samples. In another possible implementation, the elements of the third feature matrix can be converted to the range of 0 to 1, and then the converted third feature matrix is ​​summed and divided by the number of character samples to obtain the second feature matrix. Therefore, the second feature matrix is ​​obtained by averaging the third feature matrices corresponding to each character sample. Due to differences in the grayscale of pixels under different image processing environments, the second feature matrix obtained by averaging the third feature matrix reduces the calculation error caused by the grayscale difference and improves the accuracy of character recognition.

[0108] For each preset character, the above processing is performed to obtain the second feature matrix corresponding to each preset character, and the similarity between the first feature matrix and each second feature matrix is ​​calculated in sequence. For example, the character to be recognized is a number, and the preset characters include numbers 0 to 9. The similarity between the first feature matrix and the second feature matrix corresponding to 0 to 9 is calculated in sequence, thereby obtaining the similarity between the character to be recognized and each preset character.

[0109] In one possible implementation, the first feature matrix may be pre-processed to obtain an activation coefficient matrix, and then the similarity between the character to be identified and the preset character may be determined based on the activation coefficient matrix and the second feature matrix of the preset character. For example, the product of the activation coefficient matrix and the second feature matrix is ​​used as the similarity between the character to be identified and the preset character. In one possible implementation, the activation coefficient matrix Activate[N] = Matrix[N] / 255, Matrix[N] represents the first feature matrix, and " / " represents a division operation. The activation coefficient matrix can represent the first feature matrix in the form of probability. Compared with directly using the first feature matrix to calculate the similarity, using the activation coefficient to calculate the similarity can obtain a more intuitive calculation result. In another possible implementation, the first feature matrix can also be converted into an activation coefficient matrix through a preset linear calculation formula.

[0110] If the product of the activation coefficient matrix and the second feature matrix is ​​used as the similarity between the character to be recognized and the preset character. When the element in the second feature matrix is ​​0, the result of multiplication with the activation coefficient matrix is ​​0. Therefore, no matter how much the value of the element in the activation coefficient matrix is, the result of multiplication is 0. The calculation result cannot reflect the characteristics of the activation coefficient matrix, that is, it cannot reflect the characteristics of the character to be recognized, affecting the accuracy of the calculation. Therefore, in order to improve the accuracy of the calculation, when calculating the similarity, the second feature matrix is ​​first subjected to Laplace smoothing to obtain the processed matrix, and the similarity between the character to be recognized and the preset character is determined according to the product of the activation coefficient matrix and the processed matrix, thereby avoiding obtaining a calculation result of 0, so that the obtained calculation result can reflect the characteristics of the character to be recognized, thereby improving the accuracy of the calculation. In a possible implementation, the formula for Laplace smoothing is (Matrix[i]+1) / N, N=W*H. In another possible implementation, the second feature matrix can also be added to any integer greater than 0 to achieve Laplace smoothing.

[0111] S104: Identify whether the character to be identified is the preset character according to the similarity.

[0112] Specifically, the similarity between the first feature matrix and each second feature matrix is ​​calculated in turn, and the preset character corresponding to the second feature matrix with the greatest similarity is used as the character to be recognized. Compared with directly setting a similarity threshold to determine the recognition result of the character to be recognized, calculating the similarity between the first feature matrix and each second feature matrix in turn can determine the preset character closest to the character to be recognized, avoids mistakenly taking the preset character that is relatively close to the character to be recognized as the recognition result, and improves the accuracy of character recognition.

[0113] For example, if the character to be recognized is a number, the electronic device calculates the similarity with each preset character and outputs the following: Figure 8 The calculation results of the similarity are shown, among which the similarity with the number 2 is the largest, so the character to be recognized is the number 2.

[0114] In the above embodiment, by obtaining a grayscale image of the character to be recognized, the first feature matrix of the character to be recognized is determined according to the grayscale values ​​of the pixels in the grayscale image, the similarity between the character to be recognized and the preset character is determined according to the first feature matrix and the second feature matrix of the preset character, and then whether the character to be recognized is the preset character is identified according to the similarity. Since the first feature matrix determined according to the grayscale values ​​of the pixels in the grayscale image of the character to be recognized retains more character features of the character to be recognized, and since the second feature matrix is ​​determined according to the grayscale values ​​of the pixels in the grayscale image of the preset character, more character features of the preset character are retained. Therefore, the character recognition based on the similarity determined by the first feature matrix and the second feature matrix is ​​more accurate, thereby improving the accuracy of character recognition.

[0115] In a possible implementation, before calculating the similarity between the character to be recognized and the preset character, it also includes determining the fineness of the texture of the character to be recognized, wherein the fineness of the texture of the character to be recognized can be determined by a frequency spectrum of the grayscale image of the character to be recognized or a method of extracting texture features from the grayscale image of the character to be recognized. If it is determined that the fineness of the texture of the character to be recognized is less than a preset value, the similarity between the character to be recognized and the preset character is determined based on the first feature matrix and the second feature matrix of the preset character; if it is determined that the fineness of the texture of the character to be recognized is greater than or equal to the preset value, the image of the character to be recognized is binarized, and then the character features in the binarized image are extracted, and finally the character is recognized based on the extracted character features, thereby improving the calculation efficiency.

[0116] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0117] Corresponding to the character recognition method described in the above embodiment, Fig. 9 A structural block diagram of a character recognition device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0118] like Fig. 9 As shown, the character recognition device includes:

[0119] An acquisition module 10 is used to acquire a grayscale image of a character to be recognized, wherein the grayscale image includes at least one pixel;

[0120] A first calculation module 20, used for determining a first characteristic matrix of the character to be recognized according to the gray value of the at least one pixel;

[0121] A second calculation module 30, configured to determine the similarity between the character to be recognized and the preset character according to the first feature matrix and a second feature matrix of the preset character, wherein the second feature matrix is ​​determined according to the grayscale values ​​of pixels of the grayscale image of the preset character;

[0122] The recognition module 40 is used to recognize whether the character to be recognized is the preset character according to the similarity.

[0123] In a possible implementation, the first calculation module 20 includes:

[0124] A division unit, used for dividing the grayscale image of the character to be recognized into at least one region, each of which includes at least one pixel;

[0125] A first determining unit, configured to determine a feature value of a corresponding area according to a grayscale value of a pixel in each of the areas;

[0126] The second determining unit is configured to determine the first characteristic matrix according to the characteristic value.

[0127] In a possible implementation manner, the first determining unit is specifically configured to:

[0128] The grayscale value of each pixel in each of the regions is calculated, and the minimum grayscale value is used as the feature value of the corresponding region.

[0129] In a possible implementation manner, the first determining unit is specifically configured to:

[0130] The grayscale value of each pixel in each of the regions is calculated, and the minimum grayscale value is inverted to be used as the feature value of the corresponding region.

[0131] In a possible implementation, the acquisition module 10 is specifically used to:

[0132] Obtain the original grayscale image of the character to be recognized;

[0133] The original grayscale image is scaled to a preset size to obtain a grayscale image of the character to be recognized.

[0134] In a possible implementation, the second calculation module 30 is specifically configured to:

[0135] Performing preset processing on the first feature matrix to obtain an activation coefficient matrix;

[0136] The similarity between the character to be recognized and the preset character is determined according to the activation coefficient matrix and the second feature matrix of the preset character.

[0137] In a possible implementation, the second calculation module 30 is further configured to:

[0138] Performing Laplace smoothing processing on the second characteristic matrix to obtain a processed matrix;

[0139] The similarity between the character to be recognized and the preset character is determined according to the activation coefficient matrix and the processed matrix.

[0140] In a possible implementation, the first calculation module 20 is further configured to:

[0141] Acquire at least one character sample of the preset character;

[0142] Calculate the third feature matrix of each character sample;

[0143] The third characteristic matrix is ​​normalized to obtain a second characteristic matrix of the preset character.

[0144] In a possible implementation manner, the second calculation module is further configured to:

[0145] Determining the similarity between the character to be recognized and each of the preset characters according to the first feature matrix and the second feature matrix of each preset character;

[0146] Correspondingly, the identification module is specifically used for:

[0147] determining a maximum value among the similarities;

[0148] The preset character corresponding to the maximum value of the similarities is taken as the recognition result.

[0149] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0150] Fig.10 Schematic diagram of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device of this embodiment includes: a processor 11, a memory 12, and a computer program 13 stored in the memory 12 and executable on the processor 11. When the processor 11 executes the computer program 13, the steps in the above-mentioned character recognition method embodiment are implemented, for example Figure 1 Alternatively, when the processor 11 executes the computer program 13, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Fig. 9 The functions of the acquisition module 10 , the first calculation module 20 , the second calculation module 30 and the identification module 40 are shown.

[0151] Exemplarily, the computer program 13 may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 11 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 13 in the electronic device.

[0152] Those skilled in the art will understand that Fig.10 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0153] The processor 11 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0154] The memory 12 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 12 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 12 may also include both an internal storage unit of the electronic device and an external storage device. The memory 12 is used to store the computer program and other programs and data required by the electronic device. The memory 12 may also be used to temporarily store data that has been output or is to be output.

[0155] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0156] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0157] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0158] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0159] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0160] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0161] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0162] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A character recognition method, characterized in that: include: Acquire a grayscale image of a character to be recognized, wherein the grayscale image includes at least one pixel; If it is determined according to the texture features of the grayscale image of the character to be recognized that the fineness of the texture of the character to be recognized is less than a preset value, determining a first feature matrix of the character to be recognized according to the grayscale value of the at least one pixel; Determining the first characteristic matrix of the character to be recognized according to the gray value of the at least one pixel comprises: dividing the gray image of the character to be recognized into at least one region, each of the regions comprising at least one pixel; calculating the gray value of each pixel in each of the regions, and taking the inverse of the minimum gray value as the characteristic value of the corresponding region; determining the first characteristic matrix according to the characteristic value, wherein the position of the characteristic value in the first characteristic matrix reflects the position of the pixel in the gray image; Performing preset processing on the first feature matrix to obtain an activation coefficient matrix, where the activation coefficient matrix is ​​used to express the first feature matrix in a probability form; Performing Laplace smoothing processing on the second feature matrix of the preset character to obtain a processed matrix; Determine the similarity between the character to be recognized and the preset character according to the product of the activation coefficient matrix and the processed matrix, wherein the second feature matrix is ​​determined according to the grayscale values ​​of the pixels of the grayscale image of the preset character; perform normalization and equalization processing on each character sample of the preset character, divide the equalized image into at least one region, determine the eigenvalue of the corresponding region according to the grayscale values ​​of the pixels in each region, generate a third feature matrix according to the eigenvalue and the position of the eigenvalue, convert the elements of the third feature matrix to the range of 0 to 1, sum the converted third feature matrix, and divide it by the number of character samples to obtain the second feature matrix; It is determined whether the character to be identified is the preset character according to the similarity.

2. The character recognition method according to claim 1, characterized in that: The step of obtaining a grayscale image of a character to be recognized includes: Obtain the original grayscale image of the character to be recognized; The original grayscale image is scaled to a preset size to obtain a grayscale image of the character to be recognized.

3. The character recognition method according to claim 1, characterized in that: The step of identifying whether the character to be identified is the preset character according to the similarity comprises: determining a maximum value among the similarities; The preset character corresponding to the maximum value of the similarities is taken as the recognition result.

4. A character recognition device, characterized in that: include: An acquisition module, used for acquiring a grayscale image of a character to be recognized, wherein the grayscale image includes at least one pixel; A first calculation module, configured to determine a first feature matrix of the character to be recognized according to the grayscale value of the at least one pixel if it is determined according to the texture feature of the grayscale image of the character to be recognized that the fineness of the texture of the character to be recognized is less than a preset value; Determining the first characteristic matrix of the character to be recognized according to the gray value of the at least one pixel comprises: dividing the gray image of the character to be recognized into at least one region, each of the regions comprising at least one pixel; calculating the gray value of each pixel in each of the regions, and taking the inverse of the minimum gray value as the characteristic value of the corresponding region; determining the first characteristic matrix according to the characteristic value, wherein the position of the characteristic value in the first characteristic matrix reflects the position of the pixel in the gray image; A second calculation module is used to perform preset processing on the first feature matrix to obtain an activation coefficient matrix, where the activation coefficient matrix is ​​used to express the first feature matrix in the form of probability; Performing Laplace smoothing processing on the second feature matrix of the preset character to obtain a processed matrix; Determine the similarity between the character to be recognized and the preset character according to the product of the activation coefficient matrix and the processed matrix, wherein the second feature matrix is ​​determined according to the grayscale values ​​of the pixels of the grayscale image of the preset character; perform normalization and equalization processing on each character sample of the preset character, divide the equalized image into at least one region, determine the eigenvalue of the corresponding region according to the grayscale values ​​of the pixels in each region, generate a third feature matrix according to the eigenvalue and the position of the eigenvalue, convert the elements of the third feature matrix to the range of 0 to 1, sum the converted third feature matrix, and divide it by the number of character samples to obtain the second feature matrix; The recognition module is used to recognize whether the character to be recognized is the preset character according to the similarity.

5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the character recognition method according to any one of claims 1 to 3 is implemented.

6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the character recognition method according to any one of claims 1 to 3 is implemented.