Information processing method, device and equipment
By identifying and supplementing the missing strokes in the text image, the problem of stroke breakage or loss caused by device jitter or malicious destruction during the acquisition process is solved, which improves the visual quality and efficiency of text processing and enhances the ability of text traceability and traceability.
Patent Information
- Application Number
- CN202410554743.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-07
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-05-07
AI Technical Summary
During the acquisition process, the strokes of text images are broken or lost due to device jitter or malicious destruction, resulting in inefficient visual quality and efficiency of text processing, especially in the traceability of text leaks.
By obtaining the text image to be processed, determining the standard character image and its target area corresponding to its characters, identifying the missing strokes and performing supplementary processing, generating the target character block image, and finally obtaining the repaired text image.
It has realized the repair of missing strokes of characters in text, improved the visual quality and efficiency of text processing, simplified the applications of text watermarking and archive digitization, and enhanced the ability of text traceability and traceability.
Smart Images

Figure CN118411314B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text information processing, and in particular to an information processing method, device and equipment. Background Art
[0002] In the process of text acquisition, many factors will affect the quality of the final text. For example, the imaging quality of printers and scanners will affect the quality of the final scanned image. When taking photos of documents with mobile phones, slight shaking will cause the handwriting in the image to become blurred. After these document photos are converted into binary images through threshold algorithms, a large number of strokes will be broken, resulting in incomplete font structure. Especially in special occasions, such as confidential documents containing secret information being illegally stolen through screenshots or photos, in order to avoid being traced, the photographed text is maliciously destroyed, and the image quality becomes worse. After processing, the binary image will have a large number of strokes broken or completely lost, which brings great difficulties to the text leakage traceability work. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide an information processing method, device and equipment to repair missing strokes of characters in text and improve the visual quality and efficiency of text processing.
[0004] In order to solve the above technical problems, an embodiment of the present invention provides an information processing method, including:
[0005] Get the text image to be processed;
[0006] Determine a standard character image corresponding to the character in the text image to be processed;
[0007] Determining a target area of the standard character image;
[0008] Determining, according to the target area, a stroke missing area of the characters in the text image to be processed;
[0009] Performing supplementary processing on the stroke missing area to obtain a target character block image of the character corresponding to the stroke missing area;
[0010] According to the target character block image and the binarized text image of the text to be processed, a target text image of the text image to be processed is obtained.
[0011] Optionally, determining a standard character image corresponding to a character in the text image to be processed includes:
[0012] A target character image corresponding to each character in the text image to be processed is generated according to the font type and character encoding of each character in the text image to be processed.
[0013] Optionally, determining the target area of the standard character image includes:
[0014] Traversing all pixel points on the skeleton line of the standard character image along the skeleton line to obtain a stroke path set of the standard character in the standard character image;
[0015] Determining preset n continuous pixel points on each stroke path in the stroke path set as a first region, and obtaining at least one first region of the standard character image, where n is a positive integer;
[0016] The target area of the first area is determined according to the coordinates of the first pixel point and the last pixel point among the preset n consecutive pixel points in the first area and the preset boundary threshold of the first area.
[0017] Optionally, determining the stroke missing region of the characters in the text image to be processed according to the target region includes:
[0018] Acquire at least one sub-image block of the text image to be processed, each of the sub-image blocks containing a character in the text image to be processed;
[0019] Mapping at least one of the target regions to the sub-image block corresponding to the target region, and obtaining at least one second region of each sub-image block in the text image to be processed;
[0020] According to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second areas, a stroke missing area in at least one of the second areas is determined.
[0021] Optionally, determining the stroke missing region in at least one of the second regions according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second regions includes:
[0022] When the stroke trend of the character in the sub-image block is the first trend, if there is any first pixel point in the second area that satisfies:
[0023]
[0024] It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area;
[0025] Among them, a i 、b i represents the coordinates of the first pixel, S1(a i , b i)≠0 means that the gray value of the first pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
[0026] Optionally, determining the stroke missing region in at least one of the second regions according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second regions includes:
[0027] When the stroke trend of the character in the sub-image block is the second trend, if there is any second pixel point in the second area that satisfies:
[0028]
[0029] It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area;
[0030] Among them, a j 、b j represents the coordinates of the second pixel, S2(a j , b j )≠0 means that the gray value of the second pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
[0031] Optionally, supplementing the stroke missing area to obtain a target character image block of a character corresponding to the stroke missing area includes:
[0032] Obtaining a binarization threshold of the text image to be processed;
[0033] Taking the binarization threshold as the starting threshold, the stroke missing area is iteratively binarized until the character strokes in the stroke missing area are complete after the iterative binarization process or the binarization threshold of the character image corresponding to the stroke missing area reaches the maximum grayscale after the iterative binarization process, thereby obtaining the target character image block of the character corresponding to the stroke missing area.
[0034] An embodiment of the present invention further provides an information processing device, comprising:
[0035] An acquisition module, configured to acquire a text image to be processed;
[0036] A processing module, configured to determine a standard character image corresponding to a character in the text image to be processed; determine a target region of the standard character image; determine a stroke missing region of the character in the text image to be processed according to the target region; perform a supplementary process on the stroke missing region to obtain a target character block image of the character corresponding to the stroke missing region; and obtain a target text image of the text image to be processed according to the target character block image and a binary text image of the text image to be processed.
[0037] An embodiment of the present invention further provides a computing device, including: a processor and a memory storing a computer program, where when the computer program is run by the processor, the method as described above is executed.
[0038] An embodiment of the present invention further provides a computer-readable storage medium storing instructions, where when the instructions are run on a computer, the computer is caused to execute the method as described above.
[0039] The above solution of the present invention has at least the following beneficial effects:
[0040] By acquiring a text image to be processed; determining a standard character image corresponding to a character in the text image to be processed; determining a target region of the standard character image; determining a stroke missing region of the character in the text image to be processed according to the target region; performing a supplementary process on the stroke missing region to obtain a target character block image of the character corresponding to the stroke missing region; and obtaining a target text image of the text image to be processed according to the target character block image and a binary text image of the text to be processed, the repair of missing strokes of characters in the text is realized, and the visual quality and efficiency of text processing are improved. Description of the Drawings
[0041] Figure 1 is a schematic flowchart of a method for processing information provided by an embodiment of the present invention;
[0042] Figure 2 is a schematic diagram of a skeleton line structure of a standard character image corresponding to the standard character "main" provided by an optional embodiment of the present invention;
[0043] Figure 3 is Figure 2 a schematic diagram of feature point marking on the skeleton line in;
[0044] Figure 4 is a schematic diagram of vertices on the skeleton line provided by an optional embodiment of the present invention,
[0045] Figure 5It is a schematic diagram of the intersection points on the backbone line provided by an alternative embodiment of the present invention;
[0046] Figure 6 It is a schematic diagram of the second region in the horizontal direction of the character stroke provided by an alternative embodiment of the present invention;
[0047] Figure 7 It is a schematic diagram of the second region in the vertical direction of the character stroke provided by an alternative embodiment of the present invention;
[0048] Figure 8 It is a schematic diagram of the process of supplementing strokes in any stroke missing region provided by an alternative embodiment of the present invention;
[0049] Fig. 9 It is a schematic diagram after binarization processing of the image corresponding to the character "主" in the to-be-processed text image obtained by an alternative embodiment of the present invention;
[0050] Fig.10 It is for Fig. 9 A schematic diagram after stroke supplementation in the stroke missing region of the character "主" in;
[0051] Fig.11 It is a schematic diagram of the module frame of the information processing device provided by an alternative embodiment of the present invention. Detailed implementation manners
[0052] Hereinafter, exemplary embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0053] As Figure 1 shown, an embodiment of the present invention provides an information processing method, including:
[0054] Step 11, obtaining a to-be-processed text image;
[0055] Step 12, determining a standard character image corresponding to the character in the to-be-processed text image;
[0056] Step 13, determining a target region of the standard character image;
[0057] Step 14, determining a stroke missing region of the character in the to-be-processed text image according to the target region;
[0058] Step 15, performing a supplementation process on the stroke missing region to obtain a target character image block corresponding to the character in the stroke missing region;
[0059] Step 16: Obtain a target text image of the text image to be processed according to the target character image block and the binarized text image of the text image to be processed.
[0060] In this embodiment, the standard character image is obtained after binarization processing is performed on the text image to be processed; the standard characters in the standard character image correspond one-to-one to the original characters in the text image to be processed;
[0061] Furthermore, the standard character image may be segmented or processed to obtain at least one target area of the standard character image, wherein the target area represents an image corresponding to any stroke segment intercepted from all strokes of the standard character in the standard character image; it should be known that each standard character in the standard character image corresponds to multiple target areas;
[0062] By segmenting the standard character image, target areas corresponding to different strokes of the standard character are obtained, thereby ensuring the accuracy of subsequent determination of stroke missing areas in the text image to be processed;
[0063] After obtaining the target area of the standard character image, the character image block corresponding to each character in the text image to be processed can be scaled to be equal to the height of the standard character image, so as to accurately align the character image block in the text image to be processed with the standard character image, so as to facilitate the subsequent determination of the stroke missing area of the character in the text image to be processed; the stroke missing area represents the image corresponding to the original character stroke in the text image to be processed after some strokes are missing;
[0064] Furthermore, the strokes of the stroke missing areas in the text character to be processed can be reconstructed by using an adaptive binarization threshold, and the character image blocks corresponding to each stroke-reconstructed area are copied to the corresponding position area in the text image to be processed, so as to obtain a complete and repaired target text image;
[0065] By comparing the originally acquired text image to be processed with its corresponding standard character image, it is possible to accurately determine whether the character strokes in the text image to be processed are complete, and automatically reconstruct the strokes in the stroke missing area through adaptive binarization threshold processing, thereby improving the visual quality and efficiency of text image processing, thereby improving the application level in specific fields such as text watermarking, archive digitization, OCR recognition, etc., and bringing convenience to document leak tracing work.
[0066] In an optional embodiment of the present invention, the above step 12 may include:
[0067] Step 121 : generating a standard character image of each character in the text image to be processed according to the font type and character encoding of each character in the text image to be processed.
[0068] In this embodiment, the text image to be processed is first binarized to obtain a first text image O after the binarization process, and character image segmentation and character recognition operations are performed on the first text image O to obtain all character image blocks of the first text image O, and the character code corresponding to each character image block; further, the standard character image is generated according to the font type and character code corresponding to the characters in each character image block; the original text image to be processed is binarized to simplify image information and reduce the amount of calculation in subsequent processing; at the same time, the text image to be processed after the binarization process can be subjected to operations such as shape, contour, and character recognition to facilitate subsequent image processing.
[0069] In an achievable example of the present invention, in order to overcome the uneven brightness that may exist in the acquired text image to be processed, an adaptive threshold method is used to perform image binarization processing, specifically:
[0070] Evenly divide the text image I to be processed with a width of k1 and a height of k2 to obtain a plurality of first image blocks of the same size, each of which has a size of s×s, and each of which contains at least one character in the text image to be processed;
[0071] Furthermore, different first image blocks are binarized using different grayscale thresholds; for each first image block K z , set its center point to P z , calculated with P z The center is k1, and the width and height are k1 ′ and the average gray value g of the first image block k2′ z ,in:
[0072]
[0073]
[0074] The first image block K z The binarization threshold T z The calculation method is as follows:
[0075] T z =g z *η;
[0076] Among them, η ∈ (0, 1), which is used to control the darkness of the binarized image. The larger η is, the darker the strokes of the processed binary image are. In this embodiment, s and η can be set to 16 and 0.85 respectively, where z represents the number of the first image blocks of the text image to be processed, and z is a positive integer; it should be noted that for different first image blocks, the corresponding center point P z has different positions, and the average gray value g z corresponding to each first image block is also different. The average gray value g z is the ratio of the sum of the gray values corresponding to all pixel points in the first image block to the number of pixel points in the first image block;
[0077] After binarizing the text image I to be processed by the above method, a first text image O is obtained, and single-character image segmentation and character recognition operations are performed on the first text image O to obtain sub-image blocks of all characters of the text image to be processed and character codes corresponding to the characters in the sub-image blocks, so as to generate a standard character image; here, each sub-image block contains one character in the text image to be processed.
[0078] In an optional embodiment of the present invention, the above step 13 may include:
[0079] Step 131, traverse all pixel points on the skeleton line of the standard character image along the skeleton line to obtain a set of stroke paths of the standard character in the standard character image;
[0080] Step 132, determine a preset n consecutive pixel points on each stroke path in the set of stroke paths as a first region, and obtain at least one first region of the standard character image, where n is a positive integer;
[0081] Step 133, determine the target region of the first region according to the coordinates of the first pixel point and the last pixel point among the preset n consecutive pixel points in the first region and the preset boundary threshold of the first region.
[0082] In this embodiment, the skeleton line of the standard character image is a simplified representation of the shape of the standard character in the standard character image, and specifically may include the central axis, main backbone line, etc. of the standard character; the skeleton line is obtained by thinning the standard character image; it should be noted that the shape of the standard character is reflected by all the strokes of the standard character, so the skeleton line can also be regarded as a simplified representation of all the stroke architectures of the standard character in the standard character image, as Figure 2 shown as the skeleton line structure of the standard character "主";
[0083] Furthermore, all pixel points on the skeleton line are traversed along the direction of the skeleton line to obtain a stroke path set of the standard character in the standard character image, each stroke path in the stroke path set includes a plurality of pixel points of different types, and the stroke path set includes all pixel points of the standard character in the standard character image. The stroke path set can also be regarded as a set of all pixel points of the standard character in the standard character image;
[0084] Further, uniform sampling is performed on the pixel points on each stroke path in the stroke path set to obtain at least one first region of the standard character in the standard character image;
[0085] Perform uniform sampling processing on the pixel points on each stroke path in the stroke path set, as follows:
[0086] Assume that the pixel point set P = {p1, p2, ..., p N} is a set of pixels on any stroke path searched along the skeleton line, where N is a positive integer representing the number of pixels on the stroke path. In the set of pixels, n consecutive pixels are grouped as a first region P. l = {P l1 ,P l2 ,…,P ln}, where n is a positive integer, and n is less than or equal to N, then (N / n) groups of the stroke path can be obtained, and when N cannot be divided evenly, several consecutive pixel points less than n should also be regarded as a group; further, according to the direction and sequence of the stroke paths in the stroke path set, the pixel point set corresponding to the stroke path set is processed in the same way, thereby obtaining multiple first areas of the standard character image; here, the number n of consecutive pixel points can be set according to the actual processing needs, for example, 5 consecutive pixel points can be regarded as a group to form a first area;
[0087] Furthermore, the target boundary value of the current first area can be determined according to the coordinates of the first pixel point and the last pixel point in the continuous pixel points in each of the at least one first area and the preset boundary threshold of the current first area; the target boundary value may include: a left boundary value, a right boundary value, an upper boundary value, and a lower boundary value;
[0088] Furthermore, the first area where the target boundary value is determined is determined as the target area, which provides a basis and boundary range for the subsequent determination of the integrity of the original character strokes in the text image to be processed, thereby ensuring the accuracy of the determination of the integrity of the original character strokes in the text image to be processed.
[0089] In an implementable example of the present invention, for any first region, the specific steps of determining its target boundary value are as follows:
[0090] Step 21, setting the preset boundary threshold of the first area: setting the min x , min y ,,max x , max y are respectively the minimum abscissa value, the minimum ordinate value, the maximum abscissa value and the maximum ordinate value in the first area;
[0091] Step 22, obtaining the absolute value of the coordinate difference between the first pixel point and the last pixel point among the preset n consecutive pixel points in the first area: taking the first area P containing 5 consecutive pixel points as an example, l = {P l1 ,P l2 ,…,P l5} as an example, the absolute value of the difference between the first pixel and the last pixel is obtained by the following formula:
[0092] diff_X=|P l1 .xP l5 .x|;
[0093] diff_Y=|P l1 .yP l5 .y|;
[0094] Where diff_X represents the absolute value of the difference between the abscissa of the first pixel and the last pixel; diff_Y represents the absolute value of the difference between the ordinate of the first pixel and the last pixel; l1 .x、P l1 .y represents the horizontal and vertical coordinates of the first pixel point; P l5 .x、P l5 .y represents the horizontal and vertical coordinates of the last pixel point respectively;
[0095] Step 23, compare the first pixel P l1 and the last pixel P l5 The absolute value of the difference between the horizontal and vertical coordinates of the first area is determined according to the comparison result:
[0096] Step 231a, when diff_X>diff_Y, the first area is located on the strokes of the character that are horizontal or transverse; therefore, when subsequently determining whether the character strokes in the text image to be processed are complete, it is necessary to detect whether there are transverse strokes in the upward or downward position along the direction of the skeleton line of the text image to be processed, so the target boundary values of the first area at this time are determined to be:
[0097] The left boundary value t0(Z) is:
[0098] t0(Z)=min x ;
[0099] The right boundary value t0(Y) is:
[0100] t0(Y)=max x ;
[0101] The upper boundary value t0(S) is:
[0102] t0(S)=min y -α;
[0103] The lower boundary value t0(X) is:
[0104] t0(X)=max y +α;
[0105] Wherein, α is the number of pixels that the text image to be processed may be offset from the standard character strokes in the standard character image, and the value thereof can be set according to actual needs during the operation;
[0106] Step 231b, when diff_X≤diff_Y, the first area is located on the strokes of the character in the vertical direction; therefore, when subsequently determining whether the character strokes in the to-be-processed text image are complete, it is necessary to detect whether there are horizontal strokes in the left or right position along the direction of the skeleton line of the to-be-processed text image, so the target boundary values of the first area at this time are determined to be:
[0107] The left boundary value t0(Z) is:
[0108] t0(Z)=min x -α;
[0109] The right boundary value t0(Y) is:
[0110] t0(Y)=max x +α;
[0111] The upper boundary value t0(S) is:
[0112] t0(S)=min y ;
[0113] The lower boundary value t0(X) is:
[0114] t0(X)=max y ;
[0115] Further, the first region for determining the target boundary value is determined as the target region of the standard character image.
[0116] In an alternative embodiment of the present invention, step 131 may include:
[0117] Step 1311, classify the pixel points on the skeleton line of the standard character image:
[0118] (1) Determine the starting pixel point or the ending pixel point of an independent skeleton line branch as a vertex, and there is only one branch pixel point in the eight-neighborhood centered on the vertex; as shown in FIG. 3, taking the standard character image of the standard character "主" as an example, the pixel point corresponding to the circular point in the figure is the vertex;
[0119] (2) Determine the pixel point where two non-parallel skeleton line structures intersect as an intersection point, and there are three or more branch pixel points in the eight-neighborhood centered on the intersection point, corresponding to three or more stroke paths in different directions; as shown in FIG. 3, the pixel point corresponding to the square point in the figure is the intersection point;
[0120] (3) Determine the remaining pixel points on the skeleton line except the vertex and the intersection point as ordinary points, and there are exactly two branch pixel points in the eight-neighborhood centered on the ordinary point;
[0121] Figure 4 is a schematic diagram of the first partial enlargement of the skeleton line of the standard character image, as Figure 4 shown, starting from pixel point A, there is only one upward branch pixel point (pixel point A1), so the Figure 4 pixel point A in is determined as the vertex, that is, corresponding to the Figure 3 pixel point corresponding to the circular point in;
[0122] Figure 5 is a schematic diagram of the second partial enlargement of the skeleton line of the standard character image; as Figure 5 shown, starting from pixel point B, three branch pixel points (pixel points B1, B2, B3) can be found, and each branch pixel point can be used as the starting pixel point of a stroke path in a specific direction, so the Figure 5 pixel point B in is determined as the intersection point, that is, corresponding to the Figure 3 pixel point corresponding to the square point in;
[0123] Step 1312, traverse according to the type of pixel points on the skeleton line of the standard character image to obtain all the stroke paths of the standard character image:
[0124] (1) Determine any vertex on the skeleton line as the initial point, start from the starting point and search for the next pixel point along the direction of the skeleton line, and determine whether the stroke path composed of the currently searched pixel points has been searched according to the different types of the newly searched pixel points:
[0125] (2) If the pixel point searched is a vertex, it means that a complete branch stroke path of the skeleton line has been searched;
[0126] (3) If the newly searched pixel point is an intersection point, find the remaining branch pixel points that have not been searched yet with the intersection point as the center, and then use each newly searched branch pixel point as a new starting point to traverse the branch stroke paths corresponding to all branch pixel points until the searched pixel point is a vertex; use a recursive method to traverse all path branches;
[0127] (4) If the newly searched pixel point is a common point, continue searching for the next pixel point along the skeleton line and repeat the above processes (2) and (3);
[0128] By enumerating all vertices on the skeleton line through the above method, all stroke path branches of the skeleton line of each standard character image are obtained, that is, all stroke paths of each standard character image are searched out to ensure the accuracy of subsequent judgment of missing stroke areas in the text image to be processed, and avoid errors in judgment of missing stroke areas due to omissions of stroke paths.
[0129] In an optional embodiment of the present invention, the above step 14 may include:
[0130] Step 141, obtaining at least one sub-image block of the text image to be processed, each of the sub-image blocks containing a character in the text image to be processed;
[0131] Step 142, mapping at least one of the target regions to the sub-image block corresponding to the target region, and obtaining at least one second region of each sub-image block in the text image to be processed;
[0132] Step 143: determining a stroke missing region in at least one of the second regions according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second regions.
[0133] In this embodiment, the sub-image blocks of the text image I to be processed are obtained by binarizing the text image I to be processed to obtain a first text image O, and dividing the first text image O into single character images, and each of the sub-image blocks contains a character in the text image to be processed; here, the first document image O obtained after the binarization is divided into single character images, and the division can be performed in a manner that is proportional to the width and height of the standard character image, and the image blocks obtained after the division are scaled until they are scaled to a height equal to that of the standard character image, and the sub-image blocks corresponding to the same character are centrally aligned with the standard character image;
[0134] Here, the center alignment operation may be performed by respectively extracting the center lines of the sub-image block corresponding to the same character and the standard character image in the vertical direction, and aligning the two center lines of the sub-image block and the standard character image. After the two center lines are aligned, the same strokes of the same character on different images approximately overlap.
[0135] Through the above operation processing, the character strokes in the sub-image block are compared with the standard character strokes in the standard character image, so as to ensure the accuracy of determining the stroke missing area of the character in the text image to be processed;
[0136] Further, at least one of the target areas is mapped to at least one sub-image block of the text image to be processed corresponding to the target area, that is, according to the stroke trend of the character, the target area of the standard character image can be mapped one-to-one to the sub-image block of the text image to be processed, and then at least one second area of each sub-image block can be determined; since the second area corresponds to the target area one-to-one, the boundary threshold of the second area is the same as the target boundary value of the target area;
[0137] Furthermore, based on the stroke trend of the characters in the sub-image block and the coordinates of the pixel points in at least one second area corresponding to the sub-image block, at least one second area is determined to be the stroke missing area; here, the stroke trend of the characters in the sub-image block may include: a first trend and a second trend; the first trend indicates that the current stroke trend is horizontal or quasi-horizontal, and the second trend indicates that the current stroke trend is vertical or quasi-vertical.
[0138] In an optional embodiment of the present invention, the above step 143 may include:
[0139] Step 1431a, when the stroke trend of the character in the sub-image block is the first trend, if there is any first pixel point in the second area that satisfies:
[0140]
[0141] It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area;
[0142] Among them, a i , b i represents the coordinates of the first pixel, S1(a i , b i )≠0 means that the gray value of the first pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
[0143] In this embodiment, since the sub-image block is a binary image block, the grayscale value of the pixel in the second area of the sub-image block has only two possible values, one of which is 0, which can indicate that the position of the pixel is black; the other grayscale value is other non-zero values (the value is less than or equal to 255), which can indicate that the position of the pixel is non-black.
[0144] When the stroke trend of the character in the sub-image block is the first trend, that is, a positive horizontal or quasi-horizontal trend, in the process of scanning from the upper boundary to the lower boundary of the second area, if there is any first pixel whose ordinate is between the upper boundary threshold and the lower boundary threshold of the second area, and the gray value corresponding to the first pixel is not 0, as shown in the above formula, it means that the current character stroke is missing, and then the current second area is determined to be a stroke missing area;
[0145] Here, the left boundary threshold t of the second region l (Z), right boundary threshold t l (Y), upper boundary threshold t l (S), lower boundary threshold t l (X) the left boundary value t0(Z), right boundary value t0(Y), upper boundary value t0(S), and lower boundary value t0(X) of the target area corresponding to it;
[0146] like Figure 6 The character strokes in the sub-image block are shown to be in a positive horizontal trend. The black area in the figure represents the stroke area after the sub-image block is binarized, and the gray value of the pixel in this area is 0; the gray horizontal lines in the figure are the skeleton lines in the sub-image block corresponding to the skeleton lines in the standard character image. The H marked by the dotted box in the figure a With Hb That is, it is a schematic diagram of two second regions extracted along the skeleton line in the sub-image block; a or H b In the process of scanning from top to bottom, the ordinate point y of any first pixel can be found i , in the sub-image block:
[0147]
[0148] Then it is determined that the sub-image block is in the second area H a or H b The strokes of the Chinese character are complete. a or H b During the scanning process from top to bottom, no ordinate y that satisfies the above conditions can be found i , then it is determined that the sub-image block is in the second sampling area H a or H b The strokes of the Chinese character are incomplete, that is, the current second area is determined to be a stroke missing area, and a subsequent stroke reconstruction operation is required.
[0149] In an optional embodiment of the present invention, the above step 143 may include:
[0150] Step 1431b, when the stroke trend of the character in the sub-image block is the second trend, if there is any second pixel point in the second area that satisfies:
[0151]
[0152] It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area;
[0153] Among them, a j 、b j represents the coordinates of the second pixel, S2(a j , b j )≠0 means that the gray value of the second pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
[0154] In this embodiment, when the stroke trend of the character in the sub-image block is the second trend, that is, a positive vertical or quasi-vertical trend, in the process of scanning from the left boundary to the right boundary of the second area, if there is any second pixel point whose horizontal coordinate is between the left boundary threshold and the right boundary threshold of the second area, and the gray value corresponding to the second pixel point is not 0, as shown in the above formula, it means that the stroke of the current character is missing, and then the current second area is determined to be a stroke missing area;
[0155] like Figure 7 The character stroke trend in the sub-image block is shown as a positive vertical trend. The black area in the figure represents the character stroke area after the sub-image block is binarized. The gray value of the pixel point in this area is 0; the gray horizontal lines in the figure are the skeleton lines in the sub-image block corresponding to the skeleton lines in the standard character image. The dotted box H in the figure c With H d That is, it is a schematic diagram of two second regions extracted along the skeleton line in the sub-image block; c or H d In the process of scanning from top to bottom, the horizontal coordinate point x of any second pixel can be found j , in the sub-image block:
[0156]
[0157] Then it is determined that the sub-image block is in the second area H c or H d The strokes of the Chinese character are complete. If the strokes of the Chinese character are complete, c or H d During the scanning process from top to bottom, no horizontal coordinate x that satisfies the above conditions can be found. j , then it is determined that the sub-image block is in the second area H c or H d The strokes of the Chinese character are incomplete, that is, the current second region is determined to be a stroke missing region, and a subsequent stroke reconstruction operation is required;
[0158] By mapping the target area of the standard character image one by one to the sub-image block of the text image to be processed, and determining the second area in the sub-image block, and judging the completeness of the character strokes in the second area according to the character strokes of different trends in the second area in the sub-image block and the boundary threshold of the second area, the accuracy of the judgment is ensured; at the same time, after determining that the character strokes in the second area are incomplete, the current second area is determined to be a stroke missing area, and then at least one stroke missing of the text image to be processed is obtained to determine the character image to be repaired.
[0159] In an optional embodiment of the present invention, the above step 15 may include:
[0160] Step 151, obtaining a binarization threshold of the text image to be processed;
[0161] Step 152, using the binarization threshold as the starting threshold, and performing iterative binarization processing on the stroke missing area until the character strokes in the stroke missing area are complete after the iterative binarization processing or the binarization threshold of the character image corresponding to the stroke missing area after the iterative binarization processing reaches the maximum grayscale, thereby obtaining the target character image block of the character corresponding to the stroke missing area.
[0162] In this embodiment, since the stroke missing area of the stroke to be supplemented is relatively small compared to the entire text image to be processed, it is not easy to segment the stroke missing area. Therefore, the binarization threshold of the entire text image to be processed is used as the starting threshold calculation standard for the stroke missing area of each character to ensure the uniformity of character stroke supplementation in the stroke missing area of each character.
[0163] In this embodiment, the binarization threshold of the text image to be processed can be calculated by Otsu's method, so as to better distinguish the characters and the background area in the text image;
[0164] For all the stroke missing regions with incomplete strokes, a stroke missing region set T = {T1, T2, ..., T m}, for any stroke missing region T in the set q , and its upper, lower, left and right boundaries are Z q , Y q , S q , X q , where q=1, 2, ..., m is a positive integer, representing the qth stroke missing region in the stroke missing region set;
[0165] Preferably, the binarization threshold is used as the starting threshold, and before performing iterative binarization processing on each stroke missing region, the method may further include: performing adaptive binarization expansion processing on the stroke missing region;
[0166] Specifically, for any stroke missing region T in the stroke missing region set q , and its corresponding adaptive binarization area is recorded as the first stroke missing area T bq , the first stroke missing area T bq The upper, lower, left and right boundaries Z sq , Y sq , S sq , X sq satisfy:
[0167] Z sq =Zq -e;
[0168] Y sq =Y q +e;
[0169] S sq =S q -e;
[0170] X sq =X q +e;
[0171] That is, the first stroke missing area T bq The boundary of any stroke missing area T q The four boundaries of the strokes are expanded outward by e pixels to ensure that any stroke missing area T q The strokes in the corresponding stroke area are wrapped in the first stroke missing area T to the greatest extent. bq In order to ensure the accuracy of subsequent stroke filling; in this embodiment, e can be set according to the specific situation of the character strokes or the specific needs of processing; of course, here any stroke missing area T q The number of pixels expanded outward from the four boundaries can also be different;
[0172] Furthermore, the binarization threshold is used as the starting threshold, and any stroke missing region T q The first stroke missing area T corresponding to the expanded pixels bq Perform iterative binarization processing, specifically:
[0173] like Figure 8 As shown, the Otsu threshold G is used as the starting threshold for region binarization, and a binarization threshold enumeration operation is performed in the first stroke missing region. After each binarization threshold enumeration operation, it is determined whether the strokes in the current first stroke missing region are complete. The determination of whether the strokes in the first stroke missing region are complete after the binarization threshold enumeration operation is consistent with the above method for determining whether the second region is a stroke missing region, which will not be repeated here.
[0174] If the character strokes in the first stroke missing area are complete after one binarization threshold enumeration operation, stop the subsequent processing; otherwise, add t gray levels on the basis of the current binarization threshold as a new round of binarization threshold, and repeat the binarization threshold enumeration operation until the new round of binarization threshold reaches the maximum gray level or the strokes in the first stroke missing area are complete, where k represents the number of iterations;
[0175] Further, after reconstructing and supplementing all the stroke missing regions in the to-be-processed text image according to the same method as above, the character regions after supplementing strokes can be copied to the corresponding binary image of the to-be-processed text image according to the same original ratio as the to-be-processed text image, so as to obtain the repaired target text image;
[0176] Taking the character "主" in the originally obtained to-be-processed text image as an example, after binarizing the sub-image block corresponding to the character "主", as Fig. 9 shown, it can be clearly seen from Fig. 9 that there are obvious stroke missing regions in the character "主";
[0177] After supplementing the stroke missing regions of the character "主" in Fig. 9 according to the above stroke supplementing method, the character "主" with complete strokes as shown in Fig.10 is obtained; by performing corresponding processing on all the characters with stroke missing regions in the entire to-be-processed text image, the entire text image can be completely and clearly retained after the above stroke supplementing;
[0178] In the above embodiments of the present invention, by determining the standard character image corresponding to the character in the obtained to-be-processed text image; and determining the target region of the standard character image; further, according to the target region, determining the stroke missing region of the character in the to-be-processed text image; performing a supplementing process on the stroke missing region to obtain the target character block image of the character corresponding to the stroke missing region; and according to the target character block image and the binary text image of the to-be-processed text image, obtaining the target text image of the to-be-processed text image, so as to realize the repair of the missing strokes of the characters in the text image, solve the problems of poor quality and incomplete strokes of the originally obtained text image in harsh situations, and further improve the text image quality repair and digital application level; by comparing the originally obtained to-be-processed text image with its corresponding standard character image, it can be accurately judged whether the character strokes in the to-be-processed text image are complete, and by performing adaptive binarization threshold processing to supplement and reconstruct the regions where the character strokes are missing, the visual quality of text image processing is improved, and further the application levels in specific fields such as text watermarking, archive digitization, and OCR (Optical Character Recognition) are enhanced.
[0179] As Fig.11 shown, an embodiment of the present invention further provides an information processing device 110, including:
[0180] An acquisition module 111, configured to acquire a to-be-processed text image;
[0181] The processing module 112 is used to determine the standard character image corresponding to the character in the text image to be processed; determine the target area of the standard character image; determine the stroke missing area of the character in the text image to be processed based on the target area; perform supplementary processing on the stroke missing area to obtain the target character block image of the character corresponding to the stroke missing area; obtain the target text image of the text image to be processed based on the target character block image and the binarized text image of the text image to be processed.
[0182] Optionally, the processing module 112 is used to determine the standard character image corresponding to the character in the text image to be processed, including:
[0183] A standard character image corresponding to each character in the text image to be processed is generated according to the font type and character encoding of each character in the text image to be processed.
[0184] Optionally, the processing module 112 is used to determine the target area of the standard character image, including:
[0185] Traversing all pixel points on the skeleton line of the standard character image along the skeleton line to obtain a stroke path set of the standard character in the standard character image;
[0186] Determining preset n continuous pixel points on each stroke path in the stroke path set as a first region, and obtaining at least one first region of the standard character image, where n is a positive integer;
[0187] The target area of the first area is determined according to the coordinates of the first pixel point and the last pixel point among the preset n consecutive pixel points in the first area and the preset boundary threshold of the first area.
[0188] Optionally, the processing module 112 is used to determine the stroke missing area of the characters in the text image to be processed according to the target area, including:
[0189] Acquire at least one sub-image block of the text image to be processed, each of the sub-image blocks containing a character in the text image to be processed;
[0190] Mapping at least one of the target regions to the sub-image block corresponding to the target region, and obtaining at least one second region of each sub-image block in the text image to be processed;
[0191] According to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second areas, a stroke missing area in at least one of the second areas is determined.
[0192] Optionally, the processing module 112 is used to determine the stroke missing area in at least one of the second areas according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second areas, including:
[0193] When the stroke trend of the character in the sub-image block is the first trend, if there is any first pixel point in the second area that satisfies:
[0194]
[0195] It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area;
[0196] Among them, a i , b i represents the coordinates of the first pixel, S1(a i , b i )≠0 means that the gray value of the first pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
[0197] Optionally, the processing module 112 is used to determine the stroke missing area in at least one of the second areas according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second areas, including:
[0198] When the stroke trend of the character in the sub-image block is the second trend, if there is any second pixel point in the second area that satisfies:
[0199]
[0200] It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area;
[0201] Among them, a j , b j represents the coordinates of the second pixel, S2(a j , b j ))≠0 means that the gray value of the second pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l(S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
[0202] Optionally, the processing module 112 is used to perform supplementary processing on the stroke missing area to obtain a target character image block of a character corresponding to the stroke missing area, including:
[0203] Obtaining a binarization threshold of the text image to be processed;
[0204] Taking the binarization threshold as the starting threshold, the stroke missing area is iteratively binarized until the character strokes in the stroke missing area are complete after the iterative binarization process or the binarization threshold of the character image corresponding to the stroke missing area reaches the maximum grayscale after the iterative binarization process, thereby obtaining the target character image block of the character corresponding to the stroke missing area.
[0205] It should be noted that the device is a device corresponding to the above-mentioned information processing method, and all implementation methods in the above-mentioned method embodiments are applicable to the embodiments of the device and can achieve the same technical effects.
[0206] The embodiment of the present invention further provides a computing device, comprising: a processor, a memory storing a computer program, wherein when the computer program is executed by the processor, the method described above is executed. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0207] The embodiment of the present invention further provides a computer-readable storage medium, including instructions, which, when executed on a computer, enable the computer to execute the method described above. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0208] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0209] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0210] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0211] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0212] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0213] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0214] In addition, it should be noted that in the apparatus and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. Moreover, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order, and some steps can be performed in parallel or independently of each other. For those of ordinary skill in the art, it is understood that all or any steps or components of the method and apparatus of the present invention can be implemented in any computing device (including processors, storage media, etc.) or a network of computing devices in hardware, firmware, software or a combination thereof, which can be achieved by those of ordinary skill in the art using their basic programming skills after reading the description of the present invention.
[0215] Therefore, the purpose of the present invention can also be achieved by running a program or a group of programs on any computing device. The computing device can be a well-known general device. Therefore, the purpose of the present invention can also be achieved by simply providing a program product containing a program code that implements the method or device. That is to say, such a program product also constitutes the present invention, and the storage medium storing such a program product also constitutes the present invention. Obviously, the storage medium can be any well-known storage medium or any storage medium developed in the future. It should also be pointed out that in the device and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. In addition, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order. Some steps can be performed in parallel or independently of each other.
[0216] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An information processing method, characterized in that: include: Get the text image to be processed; Determine a standard character image corresponding to the character in the text image to be processed; Determining a target area of the standard character image; Determining, according to the target area, a stroke missing area of the characters in the text image to be processed; Performing supplementary processing on the stroke missing area to obtain a target character block image of the character corresponding to the stroke missing area; Obtaining a target text image of the text image to be processed according to the target character block image and the binarized text image of the text image to be processed; Wherein, determining the target area of the standard character image includes: Traversing all pixel points on the skeleton line of the standard character image along the skeleton line to obtain a stroke path set of the standard character in the standard character image; Determining preset n continuous pixel points on each stroke path in the stroke path set as a first region, and obtaining at least one first region of the standard character image, where n is a positive integer; The target area of the first area is determined according to the coordinates of the first pixel point and the last pixel point among the preset n consecutive pixel points in the first area and the preset boundary threshold of the first area.
2. The information processing method according to claim 1, characterized in that: Determining a standard character image corresponding to a character in the text image to be processed includes: A standard character image corresponding to each character in the text image to be processed is generated according to the font type and character encoding of each character in the text image to be processed.
3. The information processing method according to claim 1, characterized in that: Determining, according to the target area, a stroke missing area of a character in the text image to be processed, comprising: Acquire at least one sub-image block of the text image to be processed, each of the sub-image blocks containing a character in the text image to be processed; Mapping at least one of the target regions to the sub-image block corresponding to the target region, and obtaining at least one second region of each sub-image block in the text image to be processed; According to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second areas, a stroke missing area in at least one of the second areas is determined.
4. The information processing method according to claim 3, characterized in that: Determining a stroke missing region in at least one of the second regions according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second regions comprises: When the stroke trend of the character in the sub-image block is the first trend, if there is any first pixel point in the second area that satisfies: It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area; Among them, a i 、b i represents the coordinates of the first pixel, S1(a i , b i )≠0 means that the gray value of the first pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
5. The information processing method according to claim 3, characterized in that: Determining a stroke missing region in at least one of the second regions according to the stroke trend of the character in at least one of the sub-image blocks and the coordinates of the pixel points in at least one of the second regions comprises: When the stroke trend of the character in the sub-image block is the second trend, if there is any second pixel point in the second area that satisfies: It is determined that there are missing strokes in the current second area, and the current second area is determined to be the stroke missing area; Among them, a j 、b j represents the coordinates of the second pixel, S2(a j , b j )≠0 means that the gray value of the second pixel at the current coordinate is not 0, t l (Z) represents the left boundary threshold of the current second region, t l (Y) represents the right boundary threshold of the current second region, t l (S) represents the upper boundary threshold of the current second region, t l (X) represents the lower boundary threshold of the current second area.
6. The information processing method according to claim 1, characterized in that: Performing supplementary processing on the stroke missing area to obtain a target character image block of a character corresponding to the stroke missing area includes: Obtaining a binarization threshold of the text image to be processed; Taking the binarization threshold as the starting threshold, the stroke missing area is iteratively binarized until the character strokes in the stroke missing area are complete after the iterative binarization process or the binarization threshold of the character image corresponding to the stroke missing area reaches the maximum grayscale after the iterative binarization process, thereby obtaining the target character image block of the character corresponding to the stroke missing area.
7. An information processing device, characterized in that: include: An acquisition module, used for acquiring the text image to be processed; A processing module, used for determining a standard character image corresponding to a character in the text image to be processed; Determine a target area of the standard character image; and determine a stroke missing area of the character in the text image to be processed according to the target area; Performing supplementary processing on the stroke missing area to obtain a target character block image of the character corresponding to the stroke missing area; obtaining a target text image of the text image to be processed based on the target character block image and the binarized text image of the text image to be processed; Wherein, determining the target area of the standard character image includes: Traversing all pixel points on the skeleton line of the standard character image along the skeleton line to obtain a stroke path set of the standard character in the standard character image; Determining preset n continuous pixel points on each stroke path in the stroke path set as a first region, and obtaining at least one first region of the standard character image, where n is a positive integer; The target area of the first area is determined according to the coordinates of the first pixel point and the last pixel point among the preset n consecutive pixel points in the first area and the preset boundary threshold of the first area.
8. A computing device, characterized in that include: A processor and a memory storing a computer program, wherein when the computer program is executed by the processor, the method according to any one of claims 1 to 6 is executed.
9. A computer-readable storage medium, characterized in that: Instructions are stored, and when the instructions are executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Optical character recognition method and device
CN104112130A
Character defect detection method, device and equipment
CN110197180A