Text line area positioning method, layout analysis method and character recognition method

Through the text line area positioning and splicing technology, the problem of low recognition efficiency of complex images in the existing technology is solved, and all character information can be obtained in one recognition, which improves the recognition efficiency.

CN111814778BActive Publication Date: 2024-10-22SINOSECU TECH CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010640573.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-06
Publication Date
2024-10-22
Estimated Expiration
2040-07-06

AI Technical Summary

Technical Problem

When existing optical character recognition technology processes images with complex layouts to be recognized, it requires two recognitions to obtain all character information, resulting in long recognition time and low efficiency.

Method used

The normal color text line area and the reverse color text line area in the image are obtained through the text line area positioning method, and are spliced ​​into the result image, and a character recognition is performed to obtain all character information.

Benefits of technology

It greatly shortens the character recognition time of complex images on the layout, improves the recognition efficiency, and enables all character information to be obtained with only one recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111814778B_ABST
    Figure CN111814778B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of optical character recognition in digital image recognition, and in particular, relates to a text line area positioning method, a layout analysis method based on text line area positioning, and a character recognition method, device and storage medium based on layout analysis. The text line area positioning method comprises the following steps: obtaining a grayscale image of an image to be recognized; obtaining a positioning image based on the grayscale image; and identifying a normal color text line area and / or a reverse color text line area in the positioning image. The layout analysis method based on text line area positioning and the character recognition method based on layout analysis both comprise applying the text line area positioning method to obtain a normal color text line area and / or a reverse color text line area. The present invention, through text line areas, splices a result image having only a normal color text line area or only a reverse color text line area, so as to realize one-time recognition and obtain all character information, thereby improving the efficiency of character recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of optical character recognition in digital image recognition, and in particular relates to a text line area positioning method, a layout analysis method based on text line area positioning, and a character recognition method, device and storage medium based on layout analysis. Background Art

[0002] OCR (Optical Character Recognition) refers to the process in which an electronic device (such as a scanner or digital camera) examines characters printed on paper, determines their shapes by detecting dark and light patterns, and then uses character recognition methods to translate the shapes into computer text after a large amount of calculation processing; that is, for printed characters, an optical method is used to convert the text in a paper document into a black and white dot matrix image file, and the recognition software is used to convert the text in the image into a text format for further editing and processing by word processing software.

[0003] In the field of digital image recognition, the area with light background and dark characters is generally defined as the positive color area, and conversely, the area with dark background and light characters is defined as the negative color area. Existing OCR technology generally recognizes images with light background and dark characters. Therefore, based on the existing OCR technology, images with only positive color areas can be directly recognized, and images with only negative color areas must be inverted before recognition. For the recognition of images with more complex layouts that have both positive color areas and negative color areas, the processing method is more complicated. First, direct recognition is performed to identify the positive color area in the image, and then recognition is performed after inverting the colors to identify the negative color area in the image. The recognition results of the two recognitions are then combined to obtain the final recognition result. Summary of the invention

[0004] When the existing OCR technology performs character recognition on an image with a complex layout to be recognized, it needs to perform two recognitions to obtain all the character information of the image with a complex layout to be recognized, which has the problems of long recognition time and low recognition efficiency.

[0005] In order to solve the above technical problems, the present application aims to propose a text line area positioning method, a layout analysis method based on text line area positioning, and a character recognition method, device and storage medium based on layout analysis, so as to achieve the acquisition of all character information in an image to be recognized with a complex layout through only one OCR recognition, thereby greatly improving the efficiency of character recognition for images to be recognized with a complex layout.

[0006] One aspect of the present invention provides a method for locating a text line region, the method comprising the following steps:

[0007] Obtain a grayscale image of the image to be recognized;

[0008] Obtaining a positioning image according to the grayscale image;

[0009] Identify positive color text line areas and / or negative color text line areas in the positioning image.

[0010] Another aspect of the present invention provides a layout analysis method based on text line area positioning, the method comprising: applying the text line area positioning method as described above to obtain the positive color text line area and the negative color text line area in the positioning image; determining the positive color area and the negative color area in the grayscale image of the image to be identified.

[0011] Another aspect of the present invention provides a character recognition method based on layout analysis, comprising the following steps:

[0012] Applying the above-mentioned text line area positioning method to obtain the positive color text line area and / or the negative color text line area in the positioning image; obtaining the positive color image and the negative color image according to the grayscale image in the above-mentioned text line area positioning method;

[0013] According to the normal color text line area and / or the reverse color text line area in the positioning image, obtaining at least one of the normal color text line area of ​​the normal color image, the reverse color text line area of ​​the normal color image, the normal color text line area of ​​the reverse color image, and the reverse color text line area of ​​the reverse color image;

[0014] According to at least one of the positive color text line area of ​​the positive color image, the negative color text line area of ​​the positive color image, the positive color text line area of ​​the negative color image, and the negative color text line area of ​​the negative color image, a result image is obtained by splicing the positive color image and the negative color image; the text line areas in the result image are all positive color text line areas or negative color text line areas;

[0015] Perform character recognition on the result image to obtain a recognition result.

[0016] In another aspect of the present invention, a character recognition method based on layout analysis is provided, the method comprising the following steps:

[0017] Obtain a grayscale image of the image to be recognized;

[0018] Obtaining a hollow binary image, an inverse hollow binary image and an inverse grayscale image according to the grayscale image;

[0019] Identifying a sixth text line region in the hollow binary image and a seventh text line region in the inverse hollow binary image;

[0020] splicing the grayscale image and the inverse grayscale image according to the sixth text line region and the seventh text line region to obtain a third result image, wherein the text line regions in the third result image are all positive color text line regions;

[0021] Perform character recognition on the third result image to obtain a recognition result.

[0022] The present invention also provides a character recognition device, which includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method described above.

[0023] The present invention also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method steps described above are implemented.

[0024] Compared with the existing OCR technology, when performing character recognition on an image to be recognized with a complex layout, two recognitions are required to obtain all the character information of the image to be recognized with a complex layout. The text line area positioning method, the layout analysis method based on text line area positioning, and the character recognition method, device and storage medium based on layout analysis of the present invention splice the positive color image and the negative color image according to the positive color text line area and / or negative color text line area in the positioning image to obtain a result image containing only the positive color text line area or only the negative color text line area, so that all the character information of the image to be recognized can be obtained by performing one recognition on the result image, thereby greatly shortening the recognition time and improving the efficiency of character recognition on the image to be recognized with a complex layout. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The drawings described herein are only used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0026] Figure 1 An exemplary flow chart of the text line region locating method of the present invention is shown.

[0027] Figure 2 An exemplary flow chart of an embodiment of the text line region locating method of the present invention is shown.

[0028] Figure 3 An exemplary flow chart of another embodiment of the text line region locating method of the present invention is shown.

[0029] Figure 4 An exemplary flow chart of the character recognition method based on layout analysis of the present invention is shown.

[0030] Figure 5 An exemplary flow chart of a preferred embodiment of the character recognition method based on layout analysis of the present invention is shown.

[0031] Figure 6 An example diagram of the result image in one embodiment of the character recognition method based on layout analysis of the present invention is shown.

[0032] Figure 7 (a) shows an example graph of a grayscale image.

[0033] Figure 7 (b) shows an example of an inverted grayscale image.

[0034] Figure 7 (c) shows an example image of a binary image.

[0035] Figure 7 (d) shows an example image of an inverse binary image.

[0036] Figure 7 (e) shows an example image of a hollow binary image.

[0037] Figure 7 (f) shows an example image of an anti-hollow binary image. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the implementation mode and the accompanying drawings. Here, the schematic implementation mode of the present invention and its description are used to explain the present invention, but are not used as a limitation of the present invention. Here, it should also be noted that in order to avoid blurring the present invention due to unnecessary details, only structures and / or processing steps closely related to the scheme according to the present invention are shown in the accompanying drawings, and other details that are not closely related to the present invention are omitted. It should be emphasized that the term "include / comprise" refers to the presence of features, elements, steps or components when used herein, but does not exclude the presence or addition of at least one other feature, element, step or component. Here, it should also be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other.

[0039] Figure 1It is an exemplary flow chart of the text line area positioning method of the present application. The basic idea of ​​the text line area positioning method is to propose the concepts of "normal color text line area" and "reverse color text line area", and determine the normal color text line area and / or reverse color text line area from the text line area of ​​the positioning image according to the characteristics of the normal color text line area and the reverse color text line area. The so-called "normal color text line area" refers to the text line area in the normal color area, and the so-called "reverse color text line area" refers to the text line area in the reverse color area. For the image to be identified with a relatively complex layout with both normal color area and reverse color area, the present application realizes the simultaneous acquisition of the positioning of the normal color text line area and the positioning of the reverse color text line area through one recognition. Compared with the prior art, when locating the text line area, only the coordinate position of the text line area in the overall image is obtained. The present application also adds a judgment on whether the text line area is "normal color" or "reverse color", and adds the image information of "normal color" and "reverse color" to the positioning information of the text line area, so that the information processing of the text line area can be more accurate later. For example, in the OCR recognition of text line areas, an appropriate recognition method can be adopted according to the normal color text line areas and the reverse color text line areas. For those skilled in the art, it should be inferred without a doubt that the text line area positioning method of the present application is also applicable to the image to be recognized that contains only normal color areas or only reverse color areas, and the recognition result is all normal color text line areas or all reverse color text line areas.

[0040] The text line area positioning method provided in this application includes the following steps:

[0041] Step S101: obtaining a grayscale image of an image to be identified;

[0042] Step S102: obtaining a positioning image according to the grayscale image;

[0043] Step S103: identifying the normal color text line region and / or the reverse color text line region in the positioning image.

[0044] The image to be identified in step S101 may be an electronic image of a flat printed material such as a paper photo, business card, bank card, ID card, book, leaflet or passport, or an electronic image obtained by photographing a three-dimensional object. The grayscale image in step S101 may be a grayscale image obtained by grayscale processing of a color image to be identified, or may be an image to be identified in a grayscale image style that is directly input. The method of obtaining the grayscale image in this application is only an example and is not limited thereto. Those skilled in the art may choose other methods according to actual needs, which will not be described in detail here.

[0045] In step S103, for an image to be identified that only contains positive color areas, only the positive color text line areas of the positioning image can be identified; for an image to be identified that only contains negative color areas, only the negative color text line areas of the positioning image can be identified; for an image to be identified that has both positive color areas and negative color areas and has a more complex layout, it is necessary to identify both the positive color text line areas in the positioning image and the negative color text line areas in the positioning image.

[0046] In the field of digital image recognition, the area with light background and dark characters is generally defined as the normal color area, and vice versa, the area with dark background and light characters is defined as the reverse color area. In the normal color area, since the color of the characters in the text line area is darker than the color of the background, for the normal color text line area, the inner area is displayed as a dark color, and the outer area is displayed as a light color. At this time, the grayscale value of the inner area of ​​the text line area is less than the grayscale value of the outer area. Conversely, in the reverse color area, the color of the characters in the text line area is lighter than the color of the background. Therefore, for the reverse color text line area, the inner area is displayed as a light color, and the outer area is displayed as a dark color. At this time, the grayscale value of the inner area of ​​the text line area is greater than the grayscale value of the outer area. In view of this, it is possible to judge whether the text line area is a normal color text line area or a reverse color text line area only by comparing the grayscale values ​​of the inner area and the outer area of ​​the text line area. Although this grayscale comparison method is simple, it can quickly and accurately confirm whether the text line area is "normal color" or "reverse color".

[0047] Based on this, in a specific embodiment of the text line area positioning method provided in the present application, as follows Figure 2 As shown, the text line area in the positioning image is the first text line area, the inline area of ​​the first text line area is the first inline area, and the outline area of ​​the first inline area is the first outline area. The method specifically includes the following steps:

[0048] Step S111: obtaining a grayscale image of an image to be identified;

[0049] Step S112: obtaining a positioning image according to the grayscale image;

[0050] Step S1131: identifying a first text line area of ​​the positioning image;

[0051] Step S1132: selecting a first inner-row area and a first outer-row area in the positioning image;

[0052] Step S1133: when the grayscale value of the first in-line area is less than the grayscale value of the first out-line area, determining that the first text line area is a normal color text line area; and / or,

[0053] When the grayscale value of the first in-line area is greater than the grayscale value of the first out-line area, the first text line area is determined to be an inverted text line area.

[0054] The first text line area in the above step S1131 can be obtained by the method of obtaining a connected domain in the prior art. In the above embodiment, through step S1131, the coordinate position of the first text line area in the overall image can be obtained, and in steps S1132 and S1133, only by comparing the grayscale value of the area inside the first line with the grayscale value of the area outside the first line, it can be confirmed whether the first text line area is a normal color text line area or a reverse color text line area, thereby adding "normal color" and "reverse color" information to the positioning information of the first text line area, and when the text line area is processed later, especially in the OCR recognition of the text line area, OCR recognition can be performed more accurately based on this information.

[0055] In particular, in the case where both the normal color text line area in the positioning image and the inverted color text line area in the positioning image need to be identified, the steps of "when the grayscale value of the area within the first line is less than the grayscale value of the area outside the first line, determining that the first text line area is the normal color text line area of ​​the positioning image" and "when the grayscale value of the area within the first line is greater than the grayscale value of the area outside the first line, determining that the first text line area is the inverted color text line area of ​​the positioning image" in step S1133 can be executed sequentially or in parallel.

[0056] In the current technical means, the positioning image can be a positioning grayscale image (see Figure 7 (a)), locate the inverse grayscale image (see Figure 7 (b)), positioning binary image (see Figure 7 (c)) and the localization inverse binary image (see Figure 7 (d)). When using the grayscale comparison method, these images can all be used to determine whether the first text line area is a positive color text line area or a negative color text line area.

[0057] Since the grayscale image and the inverse grayscale image can retain the contour and color depth of each character in the image to be recognized to a large extent, when the positioning image is a positioning grayscale image or a positioning inverse grayscale image, the positive color text line area and / or the inverse color text line area in the positioning grayscale image or the positioning inverse grayscale image can be identified based on more image detail information and character information. The positioning grayscale image can be the grayscale image obtained in step S111; the positioning inverse grayscale image is an image obtained by at least inverting the grayscale image.

[0058] Because the grayscale values ​​of pixels in a binary image are only 0 or 255, and the grayscale value difference between the characters and the corresponding background is relatively large, when the positioning image is a positioning binary image or a positioning inverse binary image, the positive color text line area and the inverse color text line area can be more accurately positioned. The positioning binary image is an image obtained by at least performing a binarization process on the grayscale image, and the positioning inverse binary image is an image obtained by at least performing a color inversion process and a binarization process on the grayscale image. The color inversion process and the binarization process described in this embodiment are both prior art and will not be described in detail here.

[0059] In order to locate the text line area more accurately, the inventor proposed a hollow binary image (see Figure 7 (e)) and the inverse hollow binary image (see Figure 7 (f)). In the hollow binary image and the reverse hollow binary image, the positive color area is displayed as a white background and the characters are black solid characters (see Figure 7 (e) the words "General Manager Zhang Feifei" and Figure 7 (f) in the first 6 lines), and the inverted area is displayed as a white background and characters are displayed as black-bordered hollow characters (see Figure 7 The first 6 rows in (e) and Figure 7 (f) The text "Zhang Feifei, General Manager"); the positive text line area is displayed as a white background and black solid characters, and the negative text line area is displayed as a white background and black-bordered hollow characters.

[0060] According to this, if Figure 3 As shown, in another embodiment of the text line area positioning method provided by the present application, the positioning image includes a positioning hollow binary image and a positioning anti-hollow binary image. The method specifically includes the following steps:

[0061] Step S121: obtaining a grayscale image of an image to be identified;

[0062] Step S122: obtaining a localized hollow binary image and a localized anti-hollow binary image according to the grayscale image;

[0063] Step S123: identifying the positive color text line area and / or the negative color text line area in the located hollow binary image and the located negative hollow binary image.

[0064] Since the hollow binary image and the reverse hollow binary image retain the contour information of each character to the maximum extent, the text line area can be identified more accurately. Moreover, the color of each character contour is the same, and all text line areas in the image can be found by using a threshold to perform connected domain screening. Therefore, in the present application, the positioning hollow binary image and the positioning reverse hollow binary image are used to accurately, simply and quickly identify the text line area, greatly improving the accuracy and efficiency of text line area positioning. In conjunction with the subsequent information processing of the text line area, especially in conjunction with the OCR recognition of characters, the accuracy and efficiency of character recognition can be improved.

[0065] In a feasible implementation manner, the text line region in the located hollow binary image is a second text line region, the inline region of the second text line region is a second inline region, the outline region of the second inline region is a second outline region, and the absolute value of the difference between the grayscale value of the second inline region and the grayscale value of the second outline region is a second grayscale difference;

[0066] The third text line area in the text line area of ​​the positioning anti-hollow binary image, the inline area of ​​the third text line area is the third inline area, the outline area of ​​the third inline area is the third outline area, and the absolute value of the difference between the grayscale value of the third inline area and the grayscale value of the third outline area is the third grayscale difference;

[0067] The above step S123, identifying the positive color text line area and / or the negative color text line area in the located hollow binary image and the located negative hollow binary image, specifically includes:

[0068] Step S1231: identifying a second text line region in the located hollow binary image and a third text line region in the located reverse hollow binary image;

[0069] Step S12321: when the second text line area has an overlapping area with at least one of the third text line areas, obtaining a second in-line area and a second out-line area of ​​the second text line area, and a third in-line area and a third out-line area of ​​a third text line area corresponding to the second text line area; obtaining a second grayscale difference value of the second text line area and a third grayscale difference value of the third text line area corresponding to the second text line area by calculation;

[0070] or,

[0071] When there is an overlapping area between the third text line area and at least one of the second text line areas, a third in-line area and a third out-line area of ​​the third text line area, and a second in-line area and a second out-line area of ​​a second text line area corresponding to the third text line area are obtained; a third grayscale difference value of the third text line area and a second grayscale difference value of the second text line area corresponding to the third text line area are obtained by calculation;

[0072] Step S12322: when the second grayscale difference is greater than the third grayscale difference, determining that the second text line region is a normal color text line region, and / or the third text line region is a reverse color text line region;

[0073] and / or,

[0074] When the second grayscale difference is less than the third grayscale difference, it is determined that the second text line region is a reverse color text line region, and / or the third text line region is a normal color text line region.

[0075] In this field, the text line area refers to a certain area in the image, which is usually stored in the form of the lower left corner coordinates and the upper right corner coordinates of this area. In this embodiment, the overlapping area between two text line areas refers to the intersection between the position coordinates of the two text line areas. For example, "there is an overlapping area between the second text line area and the third text line area" means that there is an intersection between the coordinates of the second text line area and the coordinates of the third text line area. The area of ​​the second text line area and the area of ​​the third text line area may be equal or unequal, but the second text line area and the third text line area with overlapping areas will both cover the text line area corresponding to the overlapping area in the grayscale image. The second text line area in the located hollow binary image and the third text line area in the located anti-hollow binary image can both be obtained by the method of obtaining connected domains in the prior art.

[0076] From the above, it can be known that the positive color text line areas in the said positioning hollow binary image and the said positioning reverse hollow binary image are displayed as white background and black solid characters, and the reverse color text line areas are displayed as white background and black hollow characters. That is to say, the inner area of ​​the positive color text line areas in the said positioning hollow binary image and the said positioning reverse hollow binary image are all black solid characters with a white background and the outer area is white, and the grayscale difference of the positive color text line areas in the said positioning hollow binary image and the said positioning reverse hollow binary image (the absolute value of the difference between the grayscale value of the inner area and the grayscale value of the outer area) is the absolute value of the difference between the grayscale value of the black solid character area with a white background and the grayscale value of the white background area of ​​the same area. Similarly, the in-line areas of the inverted text line areas in the positioning hollow binary image and the positioning reverse hollow binary image are all white background black border hollow characters, and the out-line areas are white, and the grayscale difference of the inverted text line areas in the positioning hollow binary image and the positioning reverse hollow binary image is the absolute value of the difference between the grayscale value of the white background black border hollow character area and the grayscale value of the white background area of ​​equal area. Therefore, when there is an overlapping area between the text line area of ​​the positioning hollow binary image and the text line area at the corresponding position of the positioning reverse hollow binary image, the grayscale difference of the normal text line area is greater than the grayscale difference of the inverted text line area, that is, the text line area corresponding to the larger value of the second grayscale difference and the third grayscale difference is the normal text line area, and the text line area corresponding to the smaller value is the inverted text line area. Therefore, in this embodiment, by judging the size between the second grayscale difference value of the second text line area and the grayscale difference value of the third text line area, it is confirmed whether the second text line area and the third text line area are the normal color text line area of ​​the positioning image or the reverse color text line area of ​​the positioning image. The present invention can accurately and quickly realize the positioning of the normal color text line area of ​​the positioning image and / or the reverse color text line area of ​​the positioning image in a simple and reliable method.

[0077] In this embodiment, there is also a situation where the second text line area cannot find the corresponding third text line area, that is, there is no overlapping area between the second text line area and each of the third text line areas, which means that the content similar to the text line area in the grayscale image can only be located in the located hollow binary image. In view of the fact that the positive color text line area and the negative color text line area of ​​the located hollow binary image cannot be simply located by the grayscale value comparison method to achieve "positive color" and "negative color" positioning, step S123 in this embodiment, identifying the positive color text line area and / or negative color text line area in the located hollow binary image and the located negative hollow binary image, further includes the following steps:

[0078] Step S12331: when there is no overlapping area between the second text line area and each of the third text line areas, obtaining a fourth text line area corresponding to the second text line area in the grayscale image;

[0079] Step S12332: acquiring a fourth inline area and a fourth outline area; the inline area of ​​the fourth text line area is the fourth inline area, and the outline area of ​​the fourth inline area is the fourth outline area;

[0080] Step S12333: when the grayscale value of the fourth inner-line region is less than the grayscale value of the fourth outer-line region, determining that the second text line region is a normal color text line region; and / or,

[0081] When the grayscale value of the fourth inner-row area is greater than the grayscale value of the fourth outer-row area, the second text row area is determined to be an inverted text row area.

[0082] In this embodiment, the gray value comparison method with simple calculation and high accuracy is still adopted. In view of the fact that the "normal color" and "reverse color" of the second text line area in the positioned hollow binary image are consistent with those of the fourth text line area in the gray image, this embodiment determines whether the second text line area is "normal color" or "reverse color" by judging whether the fourth text line area is "normal color" or "reverse color". When the gray value of the area inside the fourth line is less than the gray value of the area outside the fourth line, the fourth text line area is normal color, then the corresponding second text line area is the normal color text line area of ​​the positioned hollow binary image; when the gray value of the area inside the fourth line is greater than the gray value of the area outside the fourth line, the fourth text line area is reverse color, then the corresponding second text line area is the reverse color text line area of ​​the positioned hollow binary image. The present application determines whether the second text line area is a normal color text line area or a reverse color text line area in a simple judgment manner, thereby improving the accuracy of the determination result.

[0083] Similarly, there may be a situation where there is no overlapping area between the second text line area and the third text line area, so the above step S123 may further specifically include the following steps:

[0084] Step S12341: when there is no overlapping area between the third text line area and each of the second text line areas, obtaining a fifth text line area corresponding to the third text line area in the grayscale image;

[0085] Step S12342: acquiring a fifth inline area and a fifth outline area; the inline area of ​​the fifth text line area is the fifth inline area, and the outline area of ​​the fifth inline area is the fifth outline area;

[0086] Step S12343: When the grayscale value of the area within the fifth line is less than the grayscale value of the area outside the fifth line, determine that the third text line area is a normal color text line area; and / or, when the grayscale value of the area within the fifth line is greater than the grayscale value of the area outside the fifth line, determine that the third text line area is a reverse color text line area.

[0087] In this embodiment, the principle of judging the positive and negative colors of the third text line area by the positive and negative colors of the fifth text line area is the same as the principle of judging the positive and negative colors of the second text line area by the positive and negative colors of the fourth text line area, which will not be repeated here.

[0088] The positioned hollow binary image and the positioned anti-hollow binary image, as well as the in-line area and out-line area of ​​each text line area involved in the present application will be briefly described below.

[0089] In another embodiment of the above-mentioned text line area positioning method provided in the present application, the positioning hollow binary image and the positioning anti-hollow binary image are obtained according to the grayscale image in step S122, which can be obtained by performing at least background removal binary processing on the grayscale image to obtain the positioning hollow binary image and the positioning anti-hollow binary image. Specifically, the grayscale image is at least subjected to binary processing and edge detection processing to obtain the positioning hollow binary image; the grayscale image is at least subjected to color inversion processing, binary processing and edge detection processing to obtain the positioning anti-hollow binary image.

[0090] In a specific implementation, step S122, performing at least background removal binarization processing on the grayscale image to obtain the localized hollow binary image and the localized anti-hollow binary image, specifically includes the following steps:

[0091] Step S1221, performing at least binarization processing on the grayscale image, obtaining a connected domain in the processed image, setting the grayscale value of each pixel point at the edge of the connected domain whose grayscale value is 255 to 0, and setting the grayscale value of each pixel point of the background corresponding to the connected domain to 255, to obtain a localized hollow binary image;

[0092] as well as,

[0093] Step S1222, at least perform inversion processing and binarization processing on the grayscale image, obtain a connected domain in the processed image, set the grayscale value of each pixel point on the edge of the connected domain whose grayscale value is 255 to 0, and set the grayscale value of each pixel point of the background corresponding to the connected domain to 255, to obtain a located anti-hollow binary image.

[0094] The binarization process, the edge detection process and the color inversion process in this embodiment are all prior art. The grayscale image may be subjected to binarization process of global grayscale threshold and Canny edge detection process to obtain the localized hollow binary image, and the grayscale image may be subjected to color inversion process, binarization process of global grayscale value threshold and Canny edge detection process to obtain the localized hollow binary image. The grayscale image may also be subjected to local threshold binarization process only to obtain the localized hollow binary image and the localized hollow binary image at the same time.

[0095] In addition, in the above-mentioned many embodiments of the present application, each text line area includes a first text line area, a second text line area, a third text line area, a fourth text line area and a fifth text line area. The inline area of ​​each text line area can be at least one unit character area in the text line area. The unit character area is the area corresponding to any character in the text line area. In order to facilitate the use of the following method to obtain the out-of-line area of ​​each text line area, preferably, the inline area is the first unit character area or the last unit character area of ​​the text line area.

[0096] At the same time, obtaining the out-of-row area of ​​each in-row area may be to select one of the left area, right area, upper area and lower area adjacent to the in-row area in the positioning image or the grayscale image as the out-of-row area. Of course, selecting the out-of-row area of ​​the in-row area of ​​the first text line area, the second text line area and the third text line area is performed in the positioning image corresponding to each text line area, and selecting the out-of-row area of ​​the in-row area of ​​the fourth text line area and the fifth text line area is performed in the grayscale image.

[0097] In order to make the number of pixel points in the area outside the row the same as the number of pixel points in the area inside the row, the area outside the row is selected to be the same as the area inside the row, and the acquisition of the area outside the row specifically includes:

[0098] When the area of ​​the left region is the same as the area of ​​the in-row region, and the area of ​​the right region is different from the area of ​​the in-row region, the left region is selected as the out-of-row region;

[0099] When the right region has the same area as the in-row region, and the left region has different areas from the in-row region, selecting the right region as the out-row region;

[0100] When the areas of the left area and the right area are the same as the area in the row, the left area or the right area is selected as the area outside the row;

[0101] When the areas of the left region and the right region are different from those of the in-row region, the upper region or the lower region is selected as the out-of-row region.

[0102] The upper area or the lower area is selected as the outer area, specifically:

[0103] When the area of ​​the upper region is the same as the area in the row, and the area of ​​the lower region is different from the area in the row, the upper region is selected as the area outside the row;

[0104] When the area of ​​the lower region is the same as the area in the row, and the area of ​​the upper region is different from the area in the row, the lower region is selected as the area outside the row;

[0105] When the upper region and the lower region have the same area as the in-row region, the upper region or the lower region is selected as the out-of-row region.

[0106] Preferably, an outer-row area having the same shape as the inner-row area is selected, that is, the outer-row area and the inner-row area have the same height and width.

[0107] The text line area positioning method provided by the present application can accurately determine the coordinate information and image information of the normal color text line area and / or the reverse color text line area, and use the determined coordinate information and image information to process the image to be identified, so that the processing result can be more accurate. Even if the image to be identified with a complex layout is processed, the normal color text line area and the reverse color text line area can be quickly and accurately identified.

[0108] Based on the text line area positioning method provided by the present application, the present application also provides a layout analysis method based on text line area positioning, which can apply the text line area positioning method as described above to obtain the positive color text line area and the negative color text line area in the positioning image; determine the positive color area and the negative color area in the grayscale image of the image to be identified. Since the difference in the background grayscale value of the positive color area and the negative color area is large, after locating the positive color text line area or the negative color text line area, it can be determined whether the image to be identified contains only positive color areas, only negative color areas, or a complex layout that includes both positive color areas and negative color areas by judging whether the grayscale value of the background of the positive color text line area or the negative color text line area of ​​the grayscale image of the image to be identified has a sudden change. In this process, a threshold value can be set for the sudden change of the grayscale value, and whether the grayscale value of the grayscale image has a sudden change can be determined by whether the grayscale difference between two adjacent pixels is greater than the threshold value. When it is necessary to complete layout analysis of a large number of images to be identified, the layout analysis method based on text line area positioning provided in this application can quickly and accurately complete the layout analysis of the images to be identified, effectively improving work efficiency and reducing the corresponding labor costs and error rates during human participation.

[0109] Figure 4 This is an exemplary flow chart of the character recognition method based on layout analysis of the present application. The basic idea of ​​the method is to obtain a positioning image and a positive text line area and / or a negative text line area in the positioning image according to the grayscale image of the image to be recognized by applying the above-mentioned text line area positioning method, so as to find the positive text line area and / or the negative text line area in the positive image and / or the negative text line area obtained according to the grayscale image, and accordingly, splice to obtain a result image in which all text line areas are positive text line areas or all text line areas are negative text line areas, so as to realize that character recognition is performed only once on the result image, and all character information in the image to be recognized can be obtained. Compared with the existing OCR technology, when performing character recognition on an image with a complex layout to be recognized, two recognitions are required to obtain all the character information of the image with a complex layout to be recognized. The present application, through the result image, realizes that all the character information in the image with a complex layout to be recognized can be obtained through only one OCR recognition. While ensuring the recognition accuracy, it greatly shortens the time for character recognition on the image with a complex layout to be recognized, and effectively improves the efficiency of character recognition on the image with a complex layout to be recognized.

[0110] The character recognition method based on layout analysis of the present application comprises the following steps:

[0111] Step S201: applying the above-mentioned text line region positioning method to obtain the positive color text line region and / or the negative color text line region in the positioning image; obtaining the positive color image and the negative color image according to the grayscale image in the above-mentioned text line region positioning method;

[0112] Step S202: acquiring at least one of the normal color text line area of ​​the normal color image, the reverse color text line area of ​​the normal color image, the normal color text line area of ​​the reverse color image, and the reverse color text line area of ​​the reverse color image according to the normal color text line area and / or the reverse color text line area in the positioning image;

[0113] Step S203: obtaining a result image by splicing the normal color image and the reverse color image according to at least one of the normal color text line area of ​​the normal color image, the reverse color text line area of ​​the normal color image, the normal color text line area of ​​the reverse color image, and the reverse color text line area of ​​the reverse color image; the text line areas in the result image are all normal color text line areas or reverse color text line areas;

[0114] Step S204: performing character recognition on the result image to obtain a recognition result.

[0115] In the above step S201, there is no restriction on the order of "applying the above text line area positioning method to obtain the positive color text line area and / or the negative color text line area in the positioning image" and "obtaining the positive color image and the negative color image according to the grayscale image as described above". The two processes can be carried out in parallel, and of course can also be carried out in any order. Technical personnel in this field can choose according to their needs.

[0116] In the present application, the text row area positioning method described in any of the above embodiments can be used to obtain the positive text row area and the negative text row area in the positioning image. Therefore, according to the various embodiments of the above text row area positioning method, it can be known that the positive text row area of ​​the positioning image can be one of the positive text row area of ​​the positioning grayscale image, the positive text row area of ​​the positioning negative grayscale image, the positive text row area of ​​the positioning binary image, the positive text row area of ​​the positioning negative binary image, the positive text row area of ​​the positioning hollow binary image, and the positive text row area of ​​the positioning negative hollow binary image; the negative text row area of ​​the positioning image can be one of the negative text row area of ​​the positioning grayscale image, the negative text row area of ​​the positioning negative grayscale image, the negative text row area of ​​the positioning binary image, the negative text row area of ​​the positioning negative binary image, the negative text row area of ​​the positioning hollow binary image, and the negative text row area of ​​the positioning negative hollow binary image. For step S202, when the positioning image is one of the positioning grayscale image, the positioning binary image and the positioning hollow binary image, the positive text line area of ​​the positive color image and the negative text line area in the negative color image are areas corresponding to the positive text line area of ​​the positioning image, and similarly, the negative text line area of ​​the positive color image and the positive text line area in the negative color image are areas corresponding to the negative text line area of ​​the positioning image; when the positioning image is one of the positioning negative grayscale image, the positioning negative binary image and the positioning negative hollow binary image, the positive text line area of ​​the positive color image and the negative text line area in the negative color image are areas corresponding to the negative text line area of ​​the positioning image, and similarly, the negative text line area of ​​the positive color image and the positive text line area in the negative color image are areas corresponding to the positive text line area of ​​the positioning image.

[0117] According to the result obtained in step S202, in a specific implementation, the above step S203 for stitching the result image is specifically:

[0118] According to the positive color text line area of ​​the positive color image and / or the positive color text line area of ​​the negative color image, the positive color text line area of ​​the positive color image and the positive color text line area of ​​the negative color image are intercepted and spliced ​​together, or the positive color text line area of ​​the positive color image is intercepted and correspondingly spliced ​​to the negative color image, or the positive color text line area of ​​the negative color image is intercepted and correspondingly spliced ​​to the positive color image, to obtain a first result image; the text line areas in the first result image are all positive color text line areas;

[0119] or,

[0120] According to the inverse text line area of ​​the normal color image and / or the inverse text line area of ​​the inverse color image, the inverse text line area of ​​the normal color image and the inverse text line area of ​​the inverse color image are intercepted and spliced ​​together, or the inverse text line area of ​​the normal color image is intercepted and spliced ​​to the inverse color image, or the inverse text line area of ​​the inverse color image is intercepted and spliced ​​to the normal color image, to obtain the second result image; the text line areas in the second result image are all inverse text line areas.

[0121] It can be seen that in order to obtain the first result image that is entirely positive color text line areas, the positive color text line areas of the positive color image and the positive color text line areas of the negative color image can be cut out and spliced ​​to the corresponding area of ​​the first blank image with a white background, or the positive color text line areas of the positive color image can be cut out and spliced ​​to the corresponding area of ​​the negative color image, or the positive color text line areas of the negative color image can be cut out and spliced ​​to the corresponding area of ​​the positive color image. Similarly, in order to obtain the second result image that is entirely negative color text line areas, the negative color text line areas of the positive color image and the negative color text line areas of the negative color image can be cut out and spliced ​​to the corresponding area of ​​the second blank image with a black background, or the negative color text line areas of the positive color image can be cut out and spliced ​​to the corresponding area of ​​the negative color image, or the negative color text line areas of the negative color image can be cut out and spliced ​​to the corresponding area of ​​the positive color image. It should be understood by those skilled in the art that the first blank image and the second blank image here are the same size as the image to be recognized.

[0122] In the character recognition method based on layout analysis proposed in this application, the positive color image is a grayscale image (see Figure 7 (a)), binary image (see Figure 7 (c)) and the hollow binary image (see Figure 7 (e)), wherein the inverted image is an inverted grayscale image (see Figure 7 (b)), inverse binary image (see Figure 7 (d)) and the inverse hollow binary image (see Figure 7(f) as shown). The binary image, the hollow binary image, the inverse grayscale image, the inverse binary image and the inverse hollow binary image are all obtained through the grayscale image. In the process of splicing, the positive color image and the inverse color image can be selected according to the actual usage scenario. For example, two or more positive color images can be spliced ​​with the inverse color image, or two or more inverse color images can be selected to be spliced ​​with the positive color image. When selecting one of the positive color images and one of the inverse color images for interception and splicing, in order to obtain more detailed information of the image to be identified, the positive color image can be selected as a grayscale image and the inverse color image can be selected as an inverse grayscale image; if the difference between the characters and the background in the text line area in the obtained result image is larger, the positive color image can be selected as a binary image and the inverse color image can be selected as an inverse binary image, or the positive color image can be selected as a hollow binary image and the inverse color image can be selected as an inverse hollow binary image.

[0123] The character recognition method based on layout analysis provided by the present application converts the image to be recognized into the result image having only positive text line areas or only negative text line areas, and then recognizes the result image. Therefore, the present application supports the recognition of all types of images to be recognized with dark backgrounds, light backgrounds, and a combination of the two. At the same time, since all character information of the image to be recognized can be recognized only by recognizing the result image once, the present application has the characteristics of accurate recognition results and high recognition rate. The character recognition method based on layout analysis provided by the present application achieves the purpose of quickly and accurately recognizing all characters in a complex layout, and effectively solves the problem of low accuracy and low efficiency of existing character recognition methods when recognizing complex layouts.

[0124] like Figure 5 FIG. 1 is a preferred embodiment of a character recognition method based on layout analysis. The basic idea of ​​the character recognition method based on layout analysis is to splice the grayscale image and the inverse grayscale image according to each text line area in the image to be recognized, and obtain a third result image in which all the text line areas are positive color text line areas (see Figure 6As shown), the third result image is then subjected to character recognition. Compared with the aforementioned character recognition method based on layout analysis, the present method no longer needs to mark each text line area of ​​the image to be recognized as "normal color" or "reverse color" first, but directly looks for text line areas that meet the "normal color" condition, saving the time of marking and re-searching. For images to be recognized with more complex layouts that have both normal color areas and reverse color areas, or images to be recognized with irregular reverse color areas and / or irregular normal color areas, the present application gets rid of the restrictions on normal color areas and reverse color areas, and also gets rid of the restrictions on the shapes of normal color areas and reverse color areas, and realizes the acquisition of all character information of the image to be recognized through one character recognition, which not only ensures the accuracy of the character recognition results, but also greatly shortens the image processing time before character recognition, thereby improving the efficiency of character recognition.

[0125] The character recognition method based on layout analysis of the present application comprises the following steps:

[0126] Step S301: obtaining a grayscale image of an image to be identified;

[0127] Step S302: obtaining a hollow binary image, an inverse hollow binary image and an inverse grayscale image according to the grayscale image;

[0128] Step S303: identifying a sixth text line region in the hollow binary image and a seventh text line region in the inverse hollow binary image;

[0129] Step S304: splicing the grayscale image and the inverse grayscale image according to the sixth text line region and the seventh text line region to obtain a third result image; the text line regions in the third result image are all positive color text line regions;

[0130] Step S305: performing character recognition on the third result image to obtain a recognition result.

[0131] In this embodiment, the method for obtaining the hollow binary image, the inverse hollow binary image and the inverse grayscale image according to the grayscale image can refer to the method for obtaining the located hollow binary image, the located inverse hollow binary image and the located inverse grayscale image through the grayscale image in the above-mentioned text line area positioning method.

[0132] In this embodiment, the inline area of ​​the sixth text line area is the sixth inline area, the outline area of ​​the sixth inline area is the sixth outline area, and the absolute value of the difference between the grayscale value of the sixth inline area and the grayscale value of the sixth outline area is the sixth grayscale difference;

[0133] The inline area of ​​the seventh text line area is the seventh inline area, the outline area of ​​the seventh inline area is the seventh outline area, and the absolute value of the difference between the grayscale value of the seventh inline area and the grayscale value of the seventh outline area is the seventh grayscale difference;

[0134] In the above step S304, the grayscale image and the inverse grayscale image are spliced ​​according to the sixth text line region and the seventh text line region to obtain a third result image, which specifically includes:

[0135] When the sixth text line region overlaps with at least one of the seventh text line regions,

[0136] Step S30411: obtaining a sixth in-line area and a sixth out-line area of ​​the sixth text line area, and a seventh in-line area and a seventh out-line area of ​​a seventh text line area corresponding to the sixth text line area; obtaining a sixth grayscale difference value of the sixth text line area and a seventh grayscale difference value of the seventh text line area corresponding to the sixth text line area by calculation;

[0137] Step S30412: when the sixth grayscale difference is less than the seventh grayscale difference, intercepting the area corresponding to the seventh text line area in the inverse grayscale image and splicing it to the grayscale image to obtain the third result image;

[0138] When the sixth text line region and each of the seventh text line regions do not have an overlapping area, or the seventh text line region and each of the sixth text line regions do not have an overlapping area,

[0139] Step S30421, acquiring an eighth text line region corresponding to the sixth text line region or the seventh text line region in the grayscale image;

[0140] Step S30422, obtaining an eighth inline area and an eighth outline area; the inline area of ​​the eighth text line area is the eighth inline area, and the outline area of ​​the eighth inline area is the eighth outline area;

[0141] Step S30423, when the grayscale value of the area within the eighth line is greater than the grayscale value of the area outside the eighth line, the area corresponding to the eighth text line area is intercepted in the inverse grayscale image and spliced ​​to the grayscale image to obtain the third result image.

[0142] In this embodiment, the color of each character and its background in the hollow binary image has the same characteristics as the color of each character and its background in the positioned hollow binary image in the aforementioned text line area positioning method. Similarly, the reverse hollow binary image has the same characteristics as the positioned reverse hollow binary image. The larger grayscale difference (the absolute value of the difference between the grayscale value of the area within the line and the grayscale value of the area outside the line) between the hollow binary image and the reverse hollow binary image is the absolute value of the difference between the grayscale value of the black solid character area and the grayscale value of the white background area of ​​the same area. The smaller grayscale difference between the hollow binary image and the reverse hollow binary image is the absolute value of the difference between the grayscale value of the black-bordered hollow character area and the grayscale value of the white background area of ​​the same area. Therefore, when there is an overlapping area between the sixth text line area and the seventh text line area, if the sixth grayscale difference is greater than the seventh grayscale difference, the area in the grayscale image corresponding to the sixth text line area is "normal color", so there is no need to process the area in the grayscale image, and the text line area in the area in the third result image is still the normal color text line area; if the sixth grayscale difference is less than the seventh grayscale difference, the area in the grayscale image corresponding to the sixth text line area is "reverse color", and the area in the inverse grayscale image corresponding to the seventh text line area is "normal color", so it is necessary to splice the area in the inverse grayscale image corresponding to the seventh text line area to the grayscale image, and the text line area in the area in the third result image is the normal color text line area.

[0143] When there is no overlapping area between the sixth text line area and each of the seventh text line areas, or there is no overlapping area between the seventh text line area and each of the sixth text line areas, directly judge that the eighth text line area corresponding to the sixth text line area or the seventh text line area in the grayscale image is "normal color" or "reverse color". When the grayscale value of the area inside the eighth line is greater than the grayscale value of the area outside the eighth line, the eighth text line area in the grayscale image is reversed, and the area corresponding to the eighth text line area in the reversed grayscale image is normal color. Therefore, the area corresponding to the eighth text line area in the reversed grayscale image is intercepted and spliced ​​to the grayscale image, and the text line area of ​​this area in the third result image is the normal color text line area.

[0144] In summary, according to the overlap between the sixth text line area and the seventh text line area, the present application adopts different comparison methods for the cases where there is an overlapping area and the cases where there is no overlapping area, and then intercepts the corresponding areas in the grayscale image and the inverse grayscale image for splicing according to the comparison results. By comparison and splicing, while ensuring that each text line area of ​​the image to be recognized has a corresponding area in the third result image, the third result image with only positive color text line areas is directly obtained. The third result image is then subjected to character recognition, and all character information of the image to be recognized can be recognized in only one time, which has the advantages of accurate character recognition results and short recognition time.

[0145] In this embodiment, each text line area includes a sixth text line area, a seventh text line area, and an eighth text line area. The inline area of ​​each text line area is the first unit character area or the last unit character area of ​​the text line area. The out-of-line area is one of the left area, the right area, the upper area, and the lower area adjacent to the inline area.

[0146] Preferably, the out-of-row area is one of a left area, a right area, an upper area and a lower area adjacent to the in-row area, specifically:

[0147] When the area of ​​the left region is the same as the area of ​​the in-row region, and the area of ​​the right region is different from the area of ​​the in-row region, the left region is selected as the out-of-row region;

[0148] When the right region has the same area as the in-row region, and the left region has different areas from the in-row region, selecting the right region as the out-row region;

[0149] When the areas of the left area and the right area are the same as the area in the row, the left area or the right area is selected as the area outside the row;

[0150] When the areas of the left region and the right region are different from those of the in-row region, the upper region or the lower region is selected as the out-of-row region.

[0151] The upper area or the lower area is selected as the outer area, specifically:

[0152] When the area of ​​the upper region is the same as the area in the row, and the area of ​​the lower region is different from the area in the row, the upper region is selected as the area outside the row;

[0153] When the area of ​​the lower region is the same as the area in the row, and the area of ​​the upper region is different from the area in the row, the lower region is selected as the area outside the row;

[0154] When the upper region and the lower region have the same area as the in-row region, the upper region or the lower region is selected as the out-of-row region.

[0155] Furthermore, the height and width of the outer row area are the same as those of the inner row area.

[0156] The character recognition method based on layout analysis provided in the present application integrates the positive color text line areas in the grayscale image and the inverted grayscale image into one image to obtain the third result image, and then performs character recognition on the third result image, so that all character information of the image to be recognized can be obtained by performing one recognition on the result image, thereby greatly shortening the recognition time and improving the efficiency of character recognition for images with complex layouts.

[0157] Correspondingly, the present invention also discloses a character recognition device, which may include a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method described above.

[0158] The present invention also relates to a storage medium on which computer program code is stored. When the computer program is executed by a processor, the method steps as described in any one of the above items are implemented. The storage medium can be a tangible storage medium, such as a CD, a USB flash drive, a floppy disk, a hard disk, etc.

[0159] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is 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 the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memory, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, and the like. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0160] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.

[0161] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.

[0162] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A text line area positioning method, It is characterized in that The method comprises the following steps: Obtain a grayscale image of the image to be recognized; Obtaining a positioning image according to the grayscale image; Identifying a positive color text line region and / or a negative color text line region in the positioning image; The text line area in the positioning image is a first text line area, the inline area of ​​the first text line area is a first inline area, and the outline area of ​​the first inline area is a first outline area; identifying the positive color text line area and / or the negative color text line area in the positioning image includes: Identifying a first text line region of the positioning image; Selecting a first row inner region and a first row outer region in the positioning image; In the case where the grayscale value of the first in-line area is less than the grayscale value of the first out-line area, the first text line area is determined to be a normal color text line area; and / or in the case where the grayscale value of the first in-line area is greater than the grayscale value of the first out-line area, the first text line area is determined to be a reverse color text line area; Alternatively, the positioning image includes a positioning hollow binary image and a positioning reverse hollow binary image; the text line area in the positioning hollow binary image is a second text line area, the inline area of ​​the second text line area is a second inline area, the outline area of ​​the second inline area is a second outline area, and the absolute value of the difference between the grayscale value of the second inline area and the grayscale value of the second outline area is a second grayscale difference; the text line area in the positioning reverse hollow binary image is a third text line area, the inline area of ​​the third text line area is a third inline area, the outline area of ​​the third inline area is a third outline area, and the absolute value of the difference between the grayscale value of the third inline area and the grayscale value of the third outline area is a third grayscale difference; identifying the positive color text line area and / or the reverse color text line area in the positioning image includes: Identifying a second text line region in the located hollow binary image and a third text line region in the located anti-hollow binary image; When the second text line area has an overlapping area with at least one of the third text line areas, obtaining a second grayscale difference value of the second text line area and a third grayscale difference value of a third text line area corresponding to the second text line area; or, when the third text line area has an overlapping area with at least one of the second text line areas, obtaining a third grayscale difference value of the third text line area and a second grayscale difference value of a second text line area corresponding to the third text line area; When the second grayscale difference is greater than the third grayscale difference, determining that the second text line region is a normal color text line region, and / or the third text line region is a reverse color text line region; and / or, When the second grayscale difference is less than the third grayscale difference, it is determined that the second text line region is a reverse color text line region, and / or the third text line region is a normal color text line region.

2. The method according to claim 1, It is characterized in that The positioning image is one of a positioning grayscale image, a positioning inverse grayscale image, a positioning binary image and a positioning inverse binary image; the positioning grayscale image is the grayscale image, the grayscale image is at least subjected to inversion processing to obtain the positioning inverse grayscale image, the grayscale image is at least subjected to binarization processing to obtain the positioning binary image, and the grayscale image is at least subjected to inversion processing and binarization processing to obtain the positioning inverse binary image.

3. The method according to claim 1, It is characterized in that Identifying the positive color text line area and / or the negative color text line area in the positioning image further includes the following steps: When there is no overlapping area between the second text line area and each of the third text line areas, acquiring a fourth text line area corresponding to the second text line area in the grayscale image; Acquire a fourth inline area and a fourth outline area; the inline area of ​​the fourth text line area is the fourth inline area, and the outline area of ​​the fourth inline area is the fourth outline area; When the grayscale value of the fourth inner-row area is less than the grayscale value of the fourth outer-row area, determining that the second text row area is a normal color text row area; and / or, When the grayscale value of the fourth inner-row area is greater than the grayscale value of the fourth outer-row area, determining that the second text row area is an inverted text row area; and / or, When there is no overlapping area between the third text line area and each of the second text line areas, acquiring a fifth text line area corresponding to the third text line area in the grayscale image; Acquire a fifth inline area and a fifth outline area; the inline area of ​​the fifth text line area is the fifth inline area, and the outline area of ​​the fifth inline area is the fifth outline area; In the case where the grayscale value of the fifth inner-line area is less than the grayscale value of the fifth outer-line area, determining that the third text line area is a normal color text line area; and / or, When the grayscale value of the fifth inner-row area is greater than the grayscale value of the fifth outer-row area, the third text row area is determined to be an inverted text row area.

4. The method according to any one of claims 1 to 3, It is characterized in that Obtaining a localized hollow binary image and a localized anti-hollow binary image according to the grayscale image specifically comprises the following steps: The grayscale image is at least subjected to background removal and binary processing to obtain the localized hollow binary image and the localized anti-hollow binary image.

5. The method according to claim 4, It is characterized in that The grayscale image is at least subjected to binarization processing and edge detection processing to obtain the localized hollow binary image; the grayscale image is at least subjected to color inversion processing, binarization processing and edge detection processing to obtain the localized inverse hollow binary image.

6. The method according to claim 4, It is characterized in that The grayscale image is subjected to at least background removal and binary processing to obtain the localized hollow binary image and the localized anti-hollow binary image, which specifically comprises the following steps: At least binarize the grayscale image to obtain a connected domain in the processed image, set the grayscale value of each pixel at the edge of the connected domain whose grayscale value is 255 to 0, and set the grayscale value of each pixel of the background corresponding to the connected domain to 255, to obtain a localized hollow binary image; as well as, The grayscale image is at least subjected to inversion processing and binarization processing, and a connected domain in the processed image is obtained, and the grayscale value of each pixel point at the edge of the connected domain whose grayscale value is 255 is set to 0, and the grayscale value of each pixel point of the background corresponding to the connected domain is set to 255, so as to obtain a located anti-hollow binary image.

7. The method according to any one of claims 1, 2, 3, 5 and 6, It is characterized in that The inline area of ​​each text line area is at least one unit character area in the text line area.

8. The method according to claim 7, It is characterized in that Get the outer area of ​​each inline area, including: In the positioning image or the grayscale image, one of a left area, a right area, an upper area and a lower area adjacent to the in-row area is selected as the out-of-row area.

9. The method according to claim 8, It is characterized in that The area of ​​the out-of-row area is the same as that of the in-row area; in the positioning image or the grayscale image, selecting one of the left area, the right area, the upper area and the lower area adjacent to the in-row area as the out-of-row area specifically includes: When the area of ​​the left region is the same as the area of ​​the in-row region, and the area of ​​the right region is different from the area of ​​the in-row region, the left region is selected as the out-of-row region; When the right region has the same area as the in-row region, and the left region has different areas from the in-row region, selecting the right region as the out-row region; When the areas of the left area and the right area are the same as the area in the row, the left area or the right area is selected as the area outside the row; When the areas of the left region and the right region are different from those of the in-row region, the upper region or the lower region is selected as the out-of-row region.

10. The method according to claim 9, It is characterized in that The height and width of the outer row area are the same as those of the inner row area.

11. The method according to any one of claims 8 to 10, It is characterized in that The in-line area is the first unit character area or the last unit character area of ​​the text line area.

12. A layout analysis method based on text line area positioning, It is characterized in that Apply the text line area positioning method described in any one of claims 1 to 11 to obtain the positive color text line area and the negative color text line area in the positioning image; determine the positive color area and the negative color area in the grayscale image of the image to be identified.

13. A character recognition method based on layout analysis, It is characterized in that The specific steps include: Applying the text line area positioning method described in any one of claims 1 to 11, obtaining the positive color text line area and / or the negative color text line area in the positioning image; obtaining the positive color image and the negative color image according to the grayscale image in the text line area positioning method described in any one of claims 1 to 11; According to the normal color text line area and / or the reverse color text line area in the positioning image, obtaining at least one of the normal color text line area of ​​the normal color image, the reverse color text line area of ​​the normal color image, the normal color text line area of ​​the reverse color image, and the reverse color text line area of ​​the reverse color image; According to at least one of the positive color text line area of ​​the positive color image, the negative color text line area of ​​the positive color image, the positive color text line area of ​​the negative color image, and the negative color text line area of ​​the negative color image, a result image is obtained by splicing the positive color image and the negative color image; the text line areas in the result image are all positive color text line areas or negative color text line areas; Perform character recognition on the result image to obtain a recognition result.

14. The character recognition method based on layout analysis according to claim 13, It is characterized in that According to at least one of the positive text line region of the positive image, the negative text line region of the positive image, the positive text line region of the negative image, and the negative text line region of the negative image, a result image is obtained by splicing the positive image and the negative image, wherein the text line regions in the result image are all positive text line regions or negative text line regions, specifically: According to the positive color text line area of ​​the positive color image and / or the positive color text line area of ​​the negative color image, the positive color text line area of ​​the positive color image and the positive color text line area of ​​the negative color image are intercepted and spliced ​​together, or the positive color text line area of ​​the positive color image is intercepted and correspondingly spliced ​​to the negative color image, or the positive color text line area of ​​the negative color image is intercepted and correspondingly spliced ​​to the positive color image, to obtain a first result image, wherein the text line areas in the first result image are all positive color text line areas; or, According to the inverted text line area of ​​the normal color image and / or the inverted text line area of ​​the inverted color image, the inverted text line area of ​​the normal color image and the inverted text line area of ​​the inverted color image are cut out and spliced ​​together, or the inverted text line area of ​​the normal color image is cut out and spliced ​​to the inverted color image, or the inverted text line area of ​​the inverted color image is cut out and spliced ​​to the normal color image, to obtain a second result image, in which all the text line areas in the second result image are inverted text line areas.

15. The character recognition method based on layout analysis according to claim 13 or 14, It is characterized in that The positive color image is at least one of a grayscale image, a binary image and a hollow binary image, and the negative color image is at least one of an inverse grayscale image, an inverse binary image and an inverse hollow binary image; the binary image, the hollow binary image, the inverse grayscale image, the inverse binary image and the inverse hollow binary image are all obtained through the grayscale image.

16. The character recognition method based on layout analysis according to claim 15, It is characterized in that When the positive color image is a grayscale image, the inverse color image is an inverse grayscale image; when the positive color image is a binary image, the inverse color image is an inverse binary image; when the positive color image is a hollow binary image, the inverse color image is an inverse hollow binary image.

17. A character recognition method based on layout analysis, It is characterized in that The method comprises the following steps: Obtain a grayscale image of the image to be recognized; Obtaining a hollow binary image, an inverse hollow binary image and an inverse grayscale image according to the grayscale image; Identifying a sixth text line region in the hollow binary image and a seventh text line region in the inverse hollow binary image; splicing the grayscale image and the inverse grayscale image according to the sixth text line region and the seventh text line region to obtain a third result image, wherein the text line regions in the third result image are all positive color text line regions; Performing character recognition on the third result image to obtain a recognition result; The inline area of ​​the sixth text line area is the sixth inline area, the outline area of ​​the sixth inline area is the sixth outline area, and the absolute value of the difference between the grayscale value of the sixth inline area and the grayscale value of the sixth outline area is the sixth grayscale difference; The inline area of ​​the seventh text line area is the seventh inline area, the outline area of ​​the seventh inline area is the seventh outline area, and the absolute value of the difference between the grayscale value of the seventh inline area and the grayscale value of the seventh outline area is the seventh grayscale difference; According to the sixth text line region and the seventh text line region, the grayscale image and the inverse grayscale image are spliced ​​to obtain a third result image, specifically comprising: When the sixth text line region overlaps with at least one of the seventh text line regions, Acquire a sixth grayscale difference value of the sixth text line region and a seventh grayscale difference value of a seventh text line region corresponding to the sixth text line region; When the sixth grayscale difference is less than the seventh grayscale difference, a region corresponding to the seventh text line region in the inverse grayscale image is intercepted and spliced ​​to the grayscale image to obtain the third result image; When the sixth text line region and each of the seventh text line regions do not have an overlapping area, and the seventh text line region and each of the sixth text line regions do not have an overlapping area, Acquire an eighth text line region corresponding to the sixth text line region or the seventh text line region in the grayscale image; Obtain the eighth in-line area and the eighth out-line area; the in-line area of ​​the eighth text line area is the eighth in-line area, and the out-line area of ​​the eighth in-line area is the eighth out-line area; when the grayscale value of the eighth in-line area is greater than the grayscale value of the eighth out-line area, intercept the area corresponding to the eighth text line area in the inverse grayscale image, and splice it to the grayscale image accordingly to obtain the third result image.

18. The character recognition method based on layout analysis according to claim 17, It is characterized in that The in-line area of ​​each text line area is the first unit character area or the last unit character area of ​​the text line area; the out-of-line area has the same height and width as the in-line area; the out-of-line area is one of the left area, right area, top area and bottom area adjacent to the in-line area.

19. The character recognition method based on layout analysis according to claim 18, It is characterized in that The out-of-row area is one of the left area, the right area, the upper area and the lower area adjacent to the in-row area, specifically: When the area of ​​the left region is the same as the area of ​​the in-row region, and the area of ​​the right region is different from the area of ​​the in-row region, the left region is selected as the out-of-row region; When the right region has the same area as the in-row region, and the left region has different areas from the in-row region, selecting the right region as the out-row region; When the areas of the left area and the right area are the same as the area in the row, the left area or the right area is selected as the area outside the row; When the areas of the left region and the right region are different from those of the in-row region, the upper region or the lower region is selected as the out-of-row region.

20. The method according to claim 19, It is characterized in that The height and width of the outer row area are the same as those of the inner row area.

21. A character recognition device, It is characterized in that The device includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method as described in any one of claims 1 to 20.

22. A computer storage medium, It is characterized in that A computer program is stored thereon, which implements the method steps according to any one of claims 1 to 20 when the computer program is executed by a processor.