A method, device and equipment for separating a coalesced character and a storage medium
By constructing a weighted undirected graph model and an energy function, the problem of the dependence of the recognizer on the segmentation method of sticky characters is solved, and high-accuracy segmentation of sticky characters is achieved, which is suitable for the segmentation of sticky handwritten characters.
Patent Information
- Application Number
- CN202210725026.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-06-23
AI Technical Summary
Existing methods for segmenting contiguous characters rely excessively on the performance of the recognizer, resulting in segmentation results that are greatly affected by the quality of the recognizer, making it difficult to accurately segment contiguous handwritten characters.
By constructing a weighted undirected graph model of the image of the sticky characters, the weight of the edge is determined by the energy function, and the segmentation point is solved by combining the maximum flow minimum cut theorem, thus achieving accurate positioning of the sticky characters.
It improves the accuracy and stability of segmenting connected characters, achieving a segmentation accuracy of 96.8%, and is suitable for connected characters with both complex and simple structures.
Smart Images

Figure CN116798040B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to character segmentation technology, and in particular to a method and device for segmenting a connected character, an apparatus and a storage medium. BACKGROUND
[0002] Character segmentation is a difficult problem in the field of character recognition, and the emergence of connected handwritten characters makes this problem more urgent to solve. Current methods for segmenting connected characters include iterative segmentation methods. Iterative segmentation methods segment an image as many times as possible based on the foreground features, background features or combined features of the foreground and background of a connected character image, and obtain the optimal segmentation method based on a recognizer. However, iterative segmentation methods rely too much on the selection of a recognizer, and the performance of a segmentation method is greatly affected by the quality of a recognizer. SUMMARY
[0003] To solve the above technical problems, the present application aims to provide a method and device for segmenting a connected character, an apparatus and a storage medium.
[0004] The technical solution of the present application is implemented as follows:
[0005] In a first aspect, a method for segmenting a connected character is provided, and the method comprises:
[0006] Preprocessing a first connected character image to obtain a second connected character image constructed by M paths; wherein all pixel points on a path share the same label, and a path corresponds to a vertex of a weighted undirected graph;
[0007] Constructing the second connected character image into a weighted undirected graph; wherein the vertex set of the weighted undirected graph is composed of M vertices corresponding to the M paths, and the edge set is composed of a first type of edges between adjacent vertices and a second type of edges respectively connecting each vertex to the start point and the end point;
[0008] Constructing an energy function; wherein a boundary term of the energy function is used to determine a first weight value of the first type of edges, and the first weight value is determined by the depth value of the concave valley and / or convex peak of the path of a character in the second connected character image; and a region term of the energy function is used to determine a second weight value of the second type of edges, and the second weight value is determined by the probability that the vertex has the same label as the start point or the probability that the vertex has the same label as the end point;
[0009] Solving the minimum value of the energy function to obtain the segmentation result of the second connected character image.
[0010] In the above solution, the method further comprises:
[0011] When determining the path forming the valley of the character in the second connected character image, obtaining a first pixel point and a second pixel point respectively at the highest position on two paths forming the valley;
[0012] Determining the distance between the lowest point of the valley and the first pixel point and the second pixel point in the vertical direction respectively;
[0013] Taking the shortest distance as the depth value of the valley;
[0014] And / or, when determining the path forming the convex peak of the character in the second connected character image, obtaining a third pixel point and a fourth pixel point respectively at the lowest position on two paths forming the convex peak;
[0015] Determining the distance between the highest point of the convex peak and the first pixel point and the second pixel point in the vertical direction respectively;
[0016] Taking the shortest distance as the depth value of the convex peak.
[0017] In the above scheme, the first weight is the power of the negative value of the depth value of the valley with the base e and the exponent;
[0018] Or, the first weight is the power of the negative value of the depth value of the convex peak with the base e and the exponent;
[0019] Or, the first weight is the power of the negative value of the sum of the depth value of the valley and the depth value of the convex peak with the base e and the exponent.
[0020] In the above scheme, the method further comprises: obtaining N bifurcation points formed by the M paths; taking the bifurcation point as a reference, finding all pixel points at the highest position on the path connected with the bifurcation point in a first direction; finding all pixel points at the lowest position on the path connected with the bifurcation point in a second direction;
[0021] The determination of the path forming the valley of the character in the second connected character image comprises:
[0022] When two pixel points are found in the first direction, it is determined that the path forming the valley of the character in the second connected character image is formed;
[0023] And / or, the determination of the path forming the convex peak of the character in the second connected character image comprises:
[0024] When two pixel points are found in the second direction, it is determined that the path forming the convex peak of the character in the second connected character image is formed.
[0025] In the above scheme, the method further comprises:
[0026] obtaining a leftmost pixel point and a rightmost pixel point of the second connected character, and calculating a first distance between the leftmost pixel point and the rightmost pixel point;
[0027] calculating a second distance between a center point of each path and the leftmost pixel point, and calculating a ratio of the second distance to the first distance to obtain a probability that a corresponding vertex of each path is consistent with a start point label;
[0028] calculating a third distance between the center point of each path and the rightmost pixel point, and calculating a ratio of the third distance to the first distance to obtain a probability that the corresponding vertex of each path is consistent with an end point label.
[0029] In the above scheme, the second weight is the reciprocal of the logarithm of the first probability with base e; wherein the first probability is the probability that the vertex is consistent with the start point label;
[0030] Alternatively, the second weight is the reciprocal of the logarithm of the second probability with base e; wherein the second probability is the probability that the vertex is consistent with the end point label.
[0031] In the above scheme, the pre-processing of the first connected character image to be segmented comprises:
[0032] performing binarization processing and thinning processing on the first connected character image to obtain a third connected character image;
[0033] traversing all black pixel points of the third connected character image to find P feature points; wherein the feature points include branch points, or end points and branch points;
[0034] splitting characters in the third connected character image based on the P feature points to obtain the second connected character image constructed by M paths.
[0035] In a second aspect, a connected character segmentation device is provided, and the device comprises:
[0036] a processing unit configured to pre-process a first connected character image to obtain a second connected character image constructed by M paths; wherein all pixel points on a path share the same label, and a path corresponds to a vertex of a weighted undirected graph;
[0037] a construction unit configured to construct the second connected character image into a weighted undirected graph; wherein a vertex set of the weighted undirected graph is composed of M vertices corresponding to the M paths, and an edge set is composed of a first type of edges between adjacent vertices, and a second type of edges respectively connecting each vertex to a start point and an end point;
[0038] The constructing unit is further configured to construct an energy function, wherein a boundary term of the energy function is configured to determine a first weight value of the first type of edges, and the first weight value is determined by a depth value of a valley and / or a peak of a path of the second connected character; and a region term of the energy function is configured to determine a second weight value of the second type of edges, and the second weight value is determined by a probability that a vertex is consistent with a start label or a probability that a vertex is consistent with an end label.
[0039] The processing unit is further configured to solve a minimum value of the energy function to obtain a segmentation result of the second connected character image.
[0040] In a third aspect, a connected character segmentation device is provided, which includes a processor and a memory configured to store a computer program capable of running on the processor, wherein the processor is configured to execute steps of the foregoing method when running the computer program.
[0041] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program, wherein the computer program is executed by a processor to implement steps of the foregoing method.
[0042] The present application discloses a connected character segmentation method, device, equipment and storage medium. The connected character segmentation method is to construct a weighted undirected graph model of a second connected character image, construct an energy function for determining weight values of all edges of the weighted undirected graph, solve a minimum solution of the energy function according to the max-flow min-cut theorem, and then accurately locate a segmentation point to accurately segment the second connected character. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 A flowchart of a connected character segmentation method in an embodiment of the present application is shown;
[0044] Figure 2 A preprocessing diagram of a connected character image "90" in an embodiment of the present application is shown;
[0045] Figure 3 A preprocessing flowchart of a connected character image in an embodiment of the present application is shown;
[0046] Figure 4 Two types of edges of a weighted undirected graph in an embodiment of the present application are shown;
[0047] Figure 5 A region term feature representation diagram of an energy function in an embodiment of the present application is shown;
[0048] Figure 6 A boundary term feature representation diagram in an embodiment of the present application is shown;
[0049] Figure 7This is a schematic diagram of a weighted undirected graph model in an embodiment of this application;
[0050] Figure 8 This is a schematic diagram of the process of segmenting connected characters in an embodiment of this application;
[0051] Figure 9 This is a sample set of adhering character data in the embodiments of this application;
[0052] Figure 10 This is the segmentation result of the connected characters in the embodiments of this application;
[0053] Figure 11 This is a schematic diagram of the structure of the character segmentation device in the embodiments of this application;
[0054] Figure 12 This is a schematic diagram of the structure of the character segmentation device in the embodiments of this application. Detailed Implementation
[0055] In order to gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit the embodiments of this application.
[0056] This application provides a method for segmenting contiguous characters. Figure 1 This is a schematic diagram of the first process of the method for segmenting contiguous characters in an embodiment of this application, as shown below. Figure 1 As shown, this method for splitting contiguous characters can specifically include:
[0057] Step 101: Preprocess the first image of the sticky characters to obtain a second image of the sticky characters constructed from M paths; wherein, all pixels on a path share the same label, and a path corresponds to a vertex of a weighted undirected graph.
[0058] For example, Figure 2 This is a schematic diagram of the preprocessing of the image "90" of the sticky character in an embodiment of this application, as shown below. Figure 2 As shown, Figure 2 (a) is the original image of the sticky character image "90", i.e., the first sticky character image; Figure 2 (d) is for Figure 2 (a) The second image of the sticky characters, constructed from four paths, namely path 1, path 2, path 3 and path 4, obtained after preprocessing.
[0059] In this embodiment, all pixels along a path share the same label and belong to the same category. A path corresponds to a vertex in a weighted undirected graph.
[0060] That is, path 1, path 2, path 3 and path 4 correspond to vertex 1, vertex 2, vertex 3 and vertex 4 of the weighted undirected graph respectively.
[0061] Figure 3 A processing flow diagram of the connected character image in the embodiment of the present application is shown in FIG. 1. Figure 3 As shown in FIG. 1, step 101 can specifically include:
[0062] Step 301: performing binarization processing and thinning processing on the first connected character image to obtain a third connected character image.
[0063] Here, the binarization processing refers to a process of setting the gray value of the pixel point of the foreground part (i.e., the connected character) on the image to 0 (i.e., black) and setting the gray value of the pixel point of the background part to 255 (i.e., white), so that the entire image presents a clear black and white effect. The binarization processing greatly reduces the data amount in the image, thereby highlighting the contour of the foreground part (i.e., the connected character).
[0064] Here, the thinning processing refers to a process of processing the thick connected character in the image into a skeleton character with a pixel width, which not only removes the redundant information in the image, but also retains the basic framework and main feature information of the character, thereby facilitating subsequent feature extraction and segmentation.
[0065] For example, Figure 2 (a) is the original image of the connected character image "90", i.e., the first connected character image; in Figure 2 (a), the gray value of all pixel points of the connected character image "90" is set to 0 (i.e., black), and the thick "90" is processed into a skeleton character with a pixel width through thinning processing, i.e., the second connected character image.
[0066] Step 302: traversing all black pixel points of the third connected character image to find P feature points; wherein the feature points include bifurcation points, or end points and bifurcation points.
[0067] Here, the number of black pixel points in the eight-neighborhood of the target black pixel point is counted when traversing all black pixel points. When the number of black pixel points in the eight-neighborhood of the target black pixel point is equal to 1, the target pixel point is referred to as an end point. When the sum of the number of black pixel points in the eight-neighborhood of the target black pixel point is greater than or equal to 3, the target pixel point is referred to as a bifurcation point.
[0068] For example, Figure 2 (c) are four feature points found after traversing all black pixel points of the third connected character image, including three bifurcation points a, b and c and one end point d.
[0069] Generally, the distance between adjacent feature points on a path is calculated, and when the distance is less than a preset distance threshold, the adjacent feature points on the path are merged into one feature point. Figure 2 (c) the b and c bifurcation points are merged into one bifurcation point e, i.e. Figure 2 (d) as shown.
[0070] Step 303: splitting the characters in the third connected character image based on the P feature points, to obtain a second connected character image constructed by M paths.
[0071] Exemplarily, Figure 2 (d) the a and e bifurcation points and the d end point, splitting the characters in the third connected character image, to obtain a second connected character image constructed by 4 paths, i.e., path 1, path 2, path 3 and path 4.
[0072] Step 102: constructing the second connected character image into a weighted undirected graph; wherein the vertex set of the weighted undirected graph is composed of M vertices corresponding to the M paths, and the edge set is composed of the first kind of edges between adjacent vertices, and the second kind of edges respectively connecting each vertex to the start point and the end point.
[0073] It should be noted that in the embodiments of the present application, the second connected character image is constructed into a weighted undirected graph model, and according to the maximum flow minimum cut theorem, the minimum cut is equal to the maximum flow, so the minimum cut of the weighted undirected graph can be found by the maximum flow method, and then the second connected character image is segmented.
[0074] Wherein, a cut is a subset C of the edge set E of the undirected graph, and the cost of the cut (denoted as |C|) is the sum of the weights of all edges in the edge subset C. The weight of the edge is determined by the energy function (which will be described in detail below).
[0075] Here, the weighted undirected graph G=(V,E,W) includes a vertex set V, an edge set E and an edge weight set W.
[0076] Wherein, the vertex set V includes two parts, which are defined as:
[0077] V=V'∪{S,T} (1)
[0078] V' represents a set of vertices corresponding to each path in the weighted undirected graph, i.e., path 1, path 2, path 3 and path 4 correspond to vertex 1, vertex 2, vertex 3 and vertex 4 of the weighted undirected graph respectively. S represents the start point of the weighted undirected graph, and T represents the end point of the weighted undirected graph. S belongs to the pixel set of the left character and is labeled as 0; T belongs to the pixel set of the right character and is labeled as 1.
[0079] The edge set E includes two types of edges. The first type is the edges between adjacent vertices in the vertex set V′, called n-links. Figure 2 In (d), path 1 is adjacent to path 2, path 2 is adjacent to path 3 and path 4 respectively, and path 3 is adjacent to path 4. Therefore, vertex 1 is connected to vertex 2, vertex 2 is connected to vertex 3 and vertex 4 respectively, and vertex 3 is connected to vertex 4. Figure 4 As shown in (a). Figure 4 These are schematic diagrams of two types of edges in a weighted undirected graph as illustrated in the embodiments of this application, such as... Figure 4 As shown in (a), the mathematical representation is U{p, q}, where p, q ∈ V′. Let ε be the edge set of t-links.
[0080] The second type of edge consists of vertices 1, 2, 3, and 4 in V′, which are connected to the starting point S and the ending point T, respectively. These are called t-links, i.e., as shown in the image. Figure 4 As shown in (b), the mathematical representation is U{p,S},U{p,T},p∈V′.
[0081] In summary, the edge set E is defined as follows:
[0082] E=ε∪ p∈V′ {{p,S},{p,T}} (2)
[0083] The weight W of an edge is the process of assigning values to edges t–links and n–links, which correspond to the region term R(L) and the boundary term B(L) in the energy function, respectively.
[0084] Step 103: Construct an energy function; wherein, the boundary term of the energy function is used to determine the first weight of the first type of edge, the first weight being determined by the depth value of the valley and / or peak of the path that constructs the second sticky character; the region term of the energy function is used to determine the second weight of the second type of edge, the second weight being determined by the probability that the vertex is consistent with the starting label or the probability that the vertex is consistent with the ending label.
[0085] Here, we assume that the labels of all vertices corresponding to the second contiguous character image are L=∪{l1,l2,…,l p}, where l i (i = 1, 2, ..., p) takes the value 0 (the number on the left) or 1 (the number on the right).
[0086] Assuming the cut of the second image of the connected characters is L, the energy function is defined as follows:
[0087] E(L)=λR(L)+B(L) (3)
[0088] A cut is a subset C of the edge set E of an undirected graph, and the cost of the cut (denoted as |C|) is the sum of the weights of all edges in the subset C.
[0089] It should be noted that the embodiment of the present application needs to obtain a cut L of the second character image, i.e., a subset C of the edge set E of an undirected graph, and the disconnection of all edges in the subset C will disconnect the connection between the start point S and the end point T, i.e., the left character and the right character of the character are separated, so the edge subset is called "cut". If the sum of all weights of the edges of a cut is the minimum, the cut is called a minimum cut, which is the result of the graph cut.
[0090] Here, the energy function mainly includes two characteristic terms: a region term R(L) and a boundary term B(L).
[0091] The region term R(L) calculates the penalty of assigning the vertex p to the label L p , i.e., the probability that the vertex p belongs to the label L p (0 or 1), and the greater the probability, the smaller the energy. The boundary term B(L) calculates the penalty of discontinuity between adjacent pixel points, and the greater the difference between two adjacent pixel points, the smaller the energy. λ is a balance factor between the two characteristic terms, which determines the influence of the two characteristics on the segmentation.
[0092] The region term R(L) is defined as:
[0093] R(L) = ∑ p∈P R p (L p ) (4)
[0094] R p (L p ) represents the probability that the vertex p belongs to the label L p .
[0095] In some embodiments, the method further includes:
[0096] Obtaining the leftmost pixel point and the rightmost pixel point of the second character, and calculating a first distance between the leftmost pixel point and the rightmost pixel point;
[0097] Calculating a second distance between the center point of each path and the leftmost pixel point, and calculating the ratio of the second distance to the first distance to obtain the probability that the vertex corresponding to each path is consistent with the start point label;
[0098] A third distance between the center point of each path and the rightmost pixel point is calculated, and a ratio of the third distance to the first distance is calculated to obtain a probability that the vertex and the terminal label of each path correspond.
[0099] Figure 5 As shown in a feature representation diagram of a region term of an energy function in an embodiment of the present application, Figure 5 the leftmost pixel point and the rightmost pixel point of the second connected character are found, and x l and x r are respectively the horizontal positions of the leftmost pixel point and the rightmost pixel point, x r -x l represents the width (i.e., the first distance) of the two connected numbers, and x m represents the horizontal position of the center point of the path.
[0100] The label of the left character is 0, and the label of the right character is 1. In the horizontal direction, a second distance x m -x l between the center point of each path and the leftmost pixel point is calculated, and a ratio of the second distance to the first distance is calculated and a third distance x r -x m between the center point of each path and the rightmost pixel point is calculated, and a ratio of the third distance to the first distance is calculated
[0101] The greater the probability (i.e., the ratio), the smaller the energy consumed, i.e., the smaller the second weight. Exemplarily, in some embodiments, the second weight is the reciprocal of the logarithm of the first probability with base e; wherein the first probability is the probability that the vertex and the starting label are consistent.
[0102] Alternatively, the second weight is the reciprocal of the logarithm of the second probability with base e; wherein the second probability is the probability that the vertex and the terminal label are consistent.
[0103] Here, the second weight of the t-links is calculated as follows:
[0104]
[0105] The boundary term B(L) calculates the penalty for discontinuity between adjacent pixel points. The greater the difference between two adjacent pixel points, the smaller the energy.
[0106] The boundary term B(L) is defined as:
[0107] B(L) =∑ p,q∈N B <p,q> δ(L p ,L q ) (6)
[0108] in,
[0109]
[0110] B <p,q> δ(L) represents the penalty for feature dissimilarity between adjacent vertices p and q. p ,L q The statement indicates that the weight of an edge is calculated only if the labels of p and q belong to different categories; otherwise, the weight is 0. In the problem of segmenting contiguous handwritten characters, for the same bifurcation point, if two paths connected to it can form a "valley" (e.g., ...), the weight is calculated. Figure 6 (a) shown) or "convex peak" (as shown in the image) Figure 6 (b) As shown, the second weight B of the second type of edge is determined by calculating the depth value of the "valley" or "peak". <p,q> .
[0111] For example, in some embodiments, the method further includes:
[0112] When determining the path of the character in the second sticky character image to form the valley, the pixel point at the highest position on the two paths that form the valley is obtained respectively, namely the first pixel point and the second pixel point.
[0113] Determine the vertical distances between the lowest point of the valley and the first pixel and the second pixel, respectively;
[0114] The shortest distance is taken as the depth value of the valley;
[0115] And / or, when determining the path for constructing the second adhesive character to form the convex peak, the pixel points at the lowest position on the two paths that form the convex peak are respectively obtained, namely the third pixel point and the fourth pixel point;
[0116] Determine the vertical distances between the highest point of the convex peak and the first pixel and the second pixel, respectively;
[0117] The shortest distance is taken as the depth value of the peak.
[0118] Figure 6 This is a feature representation diagram of boundary terms in the embodiments of this application, such as... Figure 6 As shown in (a), path 2 and path 4 form a valley. The lowest point of the valley is the fork point e. Obtain the pixels at the highest positions on paths 2 and 4 that form the valley, namely the first pixel and the second pixel. The vertical position of the fork point e is denoted as y. c The vertical positions of the first and second pixels are denoted as y and y', respectively. A and y B Calculate yc respectively with y A and y B The vertical distance is the depth value, and the shortest distance is taken as the depth value of the valley. The mathematical expression for the valley depth value h1 is:
[0119] h1 = y c -min(y A ,y B (8)
[0120] like Figure 6 As shown in (b), path 3 and path 4 form a peak. The highest point of the peak is the bifurcation point e. Obtain the pixels at the lowest position on paths 3 and 4 that form the peak, namely the third and fourth pixels. The vertical position of the bifurcation point e is denoted as y. c The vertical positions of the third and fourth pixels are denoted as y and y', respectively. A and y B Calculate y c respectively with y A and y B The vertical distance is the depth value, and the shortest distance is taken as the depth value of the peak. The mathematical expression for the depth value h2 of the peak is:
[0121] h2 = max(y A ,y B )-y c (9)
[0122] The larger the depth value, the greater the probability that adjacent vertices p and q are dissimilar in features, and the less energy is required, i.e., the smaller the first weight. For example, in some embodiments,
[0123] The first weight is a power of the base e and the exponent being the negative of the depth value of the valley;
[0124] Alternatively, the first weight is a power of a negative value of the depth of the peak, with base e and exponent e.
[0125] Alternatively, the first weight is a power of the negative sum of the depth values of the valley and the depth values of the peak, with base e and exponent e.
[0126] Here, the first weight of n-links is calculated as follows:
[0127] B <p,q> =exp(-(h1+h2)) (10)
[0128] In some embodiments, the method further comprises: obtaining N branch points formed by the M paths; taking the branch point as a reference, finding the pixel point at the highest position on all paths connected to the branch point in a first direction; and finding the pixel point at the lowest position on all paths connected to the branch point in a second direction.
[0129] The determination that the paths for constructing the characters in the second connected character image form the valleys comprises:
[0130] When two pixel points are found in the first direction, it is determined that the paths for constructing the characters in the second connected character image form the valleys.
[0131] And / or, the determination that the paths for constructing the characters in the second connected character image form the peaks comprises:
[0132] When two pixel points are found in the second direction, it is determined that the paths for constructing the characters in the second connected character image form the peaks.
[0133] Examples, Figure 2 (d) 2 branch points a and e and 1 end point d are shown. Taking the branch point e as a reference, find the pixel point y at the highest position on all paths (i.e., path 2 and path 4) connected to the branch point e in a first direction (i.e., upward) A and y B That is, it is determined that there are two pixel points, so it is determined that path 2 and path 4 form a valley. Find the pixel point y at the lowest position on all paths (i.e., path 3 and path 4) connected to the branch point e in a second direction (i.e., downward) A and y B That is, it is determined that there are two pixel points, so it is determined that path 3 and path 4 form a peak. Find whether all paths connected to the branch point a form a valley and / or a peak, which is the same as the above scheme and will not be described.
[0134] According to the energy function, the first weight B of the first kind of edge connecting the vertex and the start point S or the end point T is calculated <p,q> , and the second weight R of the second kind of edge connecting adjacent vertices p (L p ) are marked on the corresponding edges. Here, Figure 7 is a model diagram of a weighted undirected graph in an embodiment of the present application, that is, a weighted undirected graph constructed according to the second connected character image.
[0135] Step 104: solving the minimum value of the energy function to obtain the segmentation result of the first connected character image.
[0136] Figure 8 is a schematic diagram of a connected character segmentation process in an embodiment of the present application, such asFigure 8 As shown, by solving for the minimum value of the energy function, we obtain the cut L{(1,T),(2,T),(3,T),(4,S)} (the dashed line in the middle of Figure 8(a)), which cuts the edges between vertex 1 and T, vertex 2 and T, vertex 3 and T, and vertex 4 and S. Correspondingly, the labels of vertices 1, 2, and 3 are consistent with the label of the starting point S, and the label of vertex 4 is consistent with the label of the ending point T. Therefore, the bifurcation point of path 2, path 3, and path 4 is the "90" dividing point. Figure 8 (b) shown). Finally, the split characters are restored to their original form. Figure 8 (c)
[0137] Here, the execution entity for steps 101 to 104 can be the processor of the sticky character splitting device.
[0138] This application discloses a method, apparatus, device, and storage medium for segmenting contiguous characters. The method for segmenting contiguous characters involves constructing a weighted undirected graph model of a second contiguous character image, constructing an energy function to determine the weights of all edges in the weighted undirected graph, obtaining the minimum solution of the energy function according to the maximum flow minimum cut theorem, and then accurately locating the segmentation point to accurately segment the second contiguous character.
[0139] Based on the above embodiments, in order to verify the effectiveness of the method for segmenting contiguous characters in this application, experiments were conducted using the NIST Special Database 19 (NIST SD19) dataset. Figure 9 This is a sample set of adhering character data in the embodiments of this application, such as... Figure 9 As shown, a sample of partially connected handwritten characters is presented, specifically for evaluating the accuracy of the connected character segmentation disclosed in this application.
[0140] Figure 10 The segmentation result of the connected characters in the embodiments of this application is as follows: Figure 10 As shown, the display Figure 9 The segmentation results of the middle sample clearly demonstrate that the segmentation method for connected characters in this application has excellent segmentation performance. It can accurately segment both simple numerical strings with few connected parts, no closed loops, or few cycles (e.g., 00, 03, 17, 32) and complex numerical strings with many connected parts, cycles, or multiple branches (e.g., 14, 28, 68, 96). The segmentation accuracy of the connected character segmentation method in this application can reach 96.8%.
[0141] To implement the method of the embodiments of this application, based on the same inventive concept, the embodiments of this application also provide a device for separating sticky characters. Figure 11 This is a schematic diagram of the structure of the character segmentation device in the embodiments of this application, as shown below.Figure 11 As shown, the connected character segmentation device 110 includes:
[0142] The processing unit 1101 is configured to pre-process the first connected character image to obtain a second connected character image constructed by M paths; wherein all pixel points on a path share the same label, and a path corresponds to a vertex of a weighted undirected graph;
[0143] The construction unit 1102 is configured to construct the second connected character image into a weighted undirected graph; wherein the vertex set of the weighted undirected graph is composed of M vertices corresponding to the M paths, and the edge set is composed of the first edges between adjacent vertices and the second edges respectively connected between each vertex and the start point and the end point;
[0144] The construction unit 1102 is further configured to construct an energy function; wherein the boundary term of the energy function is used to determine the first weight value of the first edge, and the first weight value is determined by the depth value of the valley and / or the convex peak of the path constructing the second connected character; the area term of the energy function is used to determine the second weight value of the second edge, and the second weight value is determined by the probability that the vertex is consistent with the label of the start point, or the probability that the vertex is consistent with the label of the end point;
[0145] The processing unit 1101 is further configured to solve the minimum value of the energy function to obtain the segmentation result of the second connected character image.
[0146] The present application discloses a connected character segmentation method, device, equipment and storage medium. The connected character segmentation method is to construct a weighted undirected graph model of a second connected character image, construct an energy function for determining the weight values of all edges of the weighted undirected graph, obtain the minimum solution of the energy function according to the maximum flow minimum cut theorem, and accurately locate the segmentation points to accurately segment the second connected character.
[0147] In some embodiments, the determination unit is further configured to determine that when the path constructing the character in the second connected character image forms the valley, the first pixel point and the second pixel point at the highest position on the two paths forming the valley are obtained respectively;
[0148] The shortest distance is determined as the depth value of the valley.
[0149] The shortest distance is determined as the depth value of the valley.
[0150] And / or, when the path constructing the second connected character forms the convex peak, the third pixel point and the fourth pixel point at the lowest position on the two paths forming the convex peak are obtained respectively;
[0151] determining distances between the highest points of the convex peak and the first pixel point and the second pixel point in a vertical direction, respectively;
[0152] taking the shortest distance as a depth value of the convex peak.
[0153] In some embodiments, the first weight is a power of e with an exponent being a negative value of the depth value of the concave valley.
[0154] Alternatively, the first weight is a power of e with an exponent being a negative value of the depth value of the convex peak.
[0155] Alternatively, the first weight is a power of e with an exponent being a negative value of a sum of the depth value of the concave valley and the depth value of the convex peak.
[0156] In some embodiments, the method further comprises: obtaining, by an obtaining unit, N branch points formed by the M paths; taking the branch points as a reference, finding, in a first direction, pixel points at the highest positions on all paths connected to the branch points; finding, in a second direction, pixel points at the lowest positions on all paths connected to the branch points; and determining, by a determining unit, that the paths for constructing the characters in the second connected character image form the concave valley when two pixel points are found in the first direction.
[0157] And / or, determining that the paths for constructing the characters in the second connected character image form the convex peak when two pixel points are found in the second direction.
[0158] In some embodiments, the obtaining unit is further configured to obtain a leftmost pixel point and a rightmost pixel point of the second connected character, and calculate a first distance between the leftmost pixel point and the rightmost pixel point.
[0159] calculating a second distance between a center point of each path and the leftmost pixel point, and calculating a ratio of the second distance to the first distance to obtain a probability that a vertex corresponding to each path is consistent with a start point label;
[0160] calculating a third distance between the center point of each path and the rightmost pixel point, and calculating a ratio of the third distance to the first distance to obtain a probability that the vertex corresponding to each path is consistent with an end point label.
[0161] In some embodiments, the second weight is a power of e with an exponent being a reciprocal of a logarithm of a first probability; wherein the first probability is the probability that the vertex is consistent with the start point label.
[0162] Alternatively, the second weight is a power of e with an exponent being a reciprocal of a logarithm of a second probability; wherein the second probability is the probability that the vertex is consistent with the end point label.
[0163] In some embodiments, the processing unit 1101 is specifically configured to perform binarization processing and thinning processing on the first connected character image to obtain a third connected character image.
[0164] All black pixel points in the third connected character image are traversed to find P feature points, wherein the feature points include branch points, or end points and branch points.
[0165] The P feature points are used to split characters in the third connected character image to obtain the second connected character image constructed by M paths.
[0166] The present application also provides another connected character segmentation device, Figure 12 As shown in the structural schematic diagram of the connected character segmentation device in the present application, Figure 12 the connected character segmentation device 120 includes a processor 1201 and a memory 1202 configured to store a computer program capable of running on the processor.
[0167] When the processor 1201 is configured to run the computer program, the method steps in the foregoing embodiments are executed.
[0168] Of course, in actual application, as shown in the connected character segmentation device, Figure 12 all components in the connected character segmentation device are coupled together through a bus system 1203. It can be understood that the bus system 1203 is used to realize the connection and communication between the components. The bus system 1203 includes a data bus, a power supply bus, a control bus and a state signal bus. However, for the purpose of clear illustration, all kinds of buses are marked as the bus system 1203 in the present application. Figure 12
[0169] In actual application, the above processor can be at least one of an application specific integrated circuit (ASIC), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic device used to realize the function of the above processor can also be other, and the present application does not make specific limitation.
[0170] The above memory can be a volatile memory, such as a random-access memory (RAM), or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk (HDD) or a solid-state disk (SSD), or a combination of the above kinds of memories, and provides instructions and data to the processor.
[0171] In the example embodiments, the application also provides a computer readable storage medium for storing the computer program.
[0172] Optionally, the computer readable storage medium can be applied to any of the methods in the embodiments of the application, and the computer program causes the computer to execute the corresponding procedures realized by the processor in the various methods of the embodiments of the application. For brevity, details are not repeated here.
[0173] In several embodiments provided in the application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division, and actual implementation can have another division manner, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the various components shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0174] The units described above as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place or distributed on multiple network units; part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0175] In addition, each function unit in each embodiment of the present application can be integrated in one processing module, or each unit can be separately as a unit, or two or more units can be integrated in one unit; the integrated unit can be realized in the form of hardware or in the form of hardware plus software function unit. Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware, and the above-mentioned program can be stored in a computer readable storage medium, and the program executes the steps of the above-mentioned method embodiments when executed; and the above-mentioned storage medium includes mobile storage device, read-only memory (ROM), random access memory (RAM), magnetic disc or optical disc and various storage program codes.
[0176] The methods disclosed in the several method embodiments provided by the present application can be combined arbitrarily without conflict to obtain new method embodiments.
[0177] The features disclosed in the several product embodiments provided by the present application can be combined arbitrarily without conflict to obtain new product embodiments.
[0178] The features disclosed in the several method or device embodiments provided by the present application can be combined arbitrarily without conflict to obtain new method or device embodiments.
[0179] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited to this, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for segmenting contiguous characters, characterized in that, The method includes: The first image of the sticky characters is preprocessed to obtain the second image of the sticky characters constructed from M paths; where all pixels on a path share the same label and a path corresponds to a vertex of a weighted undirected graph. The second image of the sticky characters is constructed as a weighted undirected graph; wherein, the vertex set of the weighted undirected graph consists of the M vertices corresponding to the M paths, and the edge set consists of the first type of edge between adjacent vertices, and the second type of edge connecting each vertex to the start point and the end point respectively; Construct an energy function; wherein, the boundary term of the energy function is used to determine the first weight of the first type of edge, the first weight being determined by the depth value of the valley and / or peak of the path of the character in the second sticky character image; the region term of the energy function is used to determine the second weight of the second type of edge, the second weight being determined by the probability that the vertex is consistent with the starting label or the probability that the vertex is consistent with the ending label; The minimum value of the energy function is obtained to get the segmentation result of the second image of the sticky characters; The method further includes: obtaining the leftmost and rightmost pixels of the second sticky character, and calculating a first distance between the leftmost and rightmost pixels; calculating a second distance between the center point of each path and the leftmost pixel, and calculating the ratio of the second distance to the first distance to obtain the probability that the vertex corresponding to each path is consistent with the starting label; calculating a third distance between the center point of each path and the rightmost pixel, and calculating the ratio of the third distance to the first distance to obtain the probability that the vertex corresponding to each path is consistent with the ending label; The second weight is the reciprocal of the logarithm of the first probability with base e and argument e; wherein the first probability is the probability that the vertex and the starting point label are the same. Alternatively, the second weight is the reciprocal of the logarithm of the second probability with base e and argument e; wherein the second probability is the probability that the vertex and the ending point label are the same.
2. The method according to claim 1, characterized in that, The method further includes: When determining the path of the character in the second sticky character image to form the valley, the pixel point at the highest position on the two paths that form the valley is obtained respectively, namely the first pixel point and the second pixel point. Determine the vertical distances between the lowest point of the valley and the first pixel and the second pixel, respectively; The shortest distance is taken as the depth value of the valley; And / or, when determining the path of the character in the second sticky character image to form the convex peak, respectively obtain the pixel point at the lowest position on the two paths that form the convex peak, namely the third pixel point and the fourth pixel point; Determine the vertical distances between the highest point of the convex peak and the first pixel and the second pixel, respectively; The shortest distance is taken as the depth value of the peak.
3. The method according to claim 2, characterized in that, The method further includes: obtaining N branching points formed by the M paths; using the branching points as a reference, searching along a first direction for the highest pixel on all paths connected to the branching points; and searching along a second direction for the lowest pixel on all paths connected to the branching points. The step of determining the path of the character in the second contiguous character image to form the concave valley includes: When two pixels are found along the first direction, the path for constructing the character in the second image of the adhered character is determined to form the valley; And / or, determining the path of the character in the second contiguous character image to form the convex peak includes: When two pixels are found along the second direction, the path of the character in the second contiguous character image is determined to form the convex peak.
4. The method according to claim 1, characterized in that, The first weight is a power of the base e and the exponent being the negative of the depth value of the valley; Alternatively, the first weight is a power of a negative value of the depth of the peak, with base e and exponent e. Alternatively, the first weight is a power of the negative sum of the depth values of the valley and the depth values of the peak, with base e and exponent e.
5. The method according to claim 1, characterized in that, The preprocessing of the first image of the contiguous characters includes: The first image of the connected characters is binarized and thinned to obtain the third image of the connected characters. Traverse all black pixels in the third image of the connected characters and find P feature points; wherein, the feature points include bifurcation points, or endpoints and bifurcation points; Based on the P feature points, the characters in the third sticky character image are split to obtain the second sticky character image constructed from M paths.
6. A device for separating stuck characters, characterized in that, The device includes: The processing unit is used to preprocess the first image of the sticky characters to obtain a second image of the sticky characters constructed from M paths; wherein, all pixels on a path share the same label, and a path corresponds to a vertex of a weighted undirected graph; The construction unit is used to construct the second sticky character image into a weighted undirected graph; wherein, the vertex set of the weighted undirected graph consists of M vertices corresponding to the M paths, and the edge set consists of a first type of edge between adjacent vertices and a second type of edge connecting each vertex to the start point and the end point respectively; The construction unit is further configured to construct an energy function; wherein, the boundary term of the energy function is used to determine the first weight of the first type of edge, the first weight being determined by the depth value of the valley and / or peak of the path for constructing the second sticky character; the region term of the energy function is used to determine the second weight of the second type of edge, the second weight being determined by the probability that the vertex is consistent with the starting label or the probability that the vertex is consistent with the ending label; The processing unit is also used to solve for the minimum value of the energy function to obtain the segmentation result of the second sticky character image; It also includes an acquisition unit, which is used to acquire the leftmost and rightmost pixels of the second sticky character, and calculate a first distance between the leftmost and rightmost pixels; calculate a second distance between the center point of each path and the leftmost pixel, and calculate the ratio of the second distance to the first distance to obtain the probability that the vertex corresponding to each path is consistent with the starting label; calculate a third distance between the center point of each path and the rightmost pixel, and calculate the ratio of the third distance to the first distance to obtain the probability that the vertex corresponding to each path is consistent with the ending label; The second weight is the reciprocal of the logarithm of the first probability with base e and argument e; wherein the first probability is the probability that the vertex and the starting point label are the same. Alternatively, the second weight is the reciprocal of the logarithm of the second probability with base e and argument e; wherein the second probability is the probability that the vertex and the ending point label are the same.
7. A device for segmenting contiguous characters, characterized in that, The contiguous character segmentation device includes: a processor and a memory configured to store a computer program capable of running on the processor. Wherein, when the processor is configured to run the computer program, it performs the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
RTOS power optimization method based on discrete Hopfield neural network
CN101017509A
A digital character recognition method of a character wheel type water meter based on image processing
CN109543676A