Handwritten chinese character writing path generation method and device based on CT-GSA

By optimizing triangulation using the CT-GSA method, writing paths that preserve stroke style are generated, solving the problems of skeleton distortion and edge noise in traditional methods, and achieving effective preservation of stroke topology features and path optimization.

CN116597452BActive Publication Date: 2026-04-07ZHEJIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-05
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Traditional writing path generation methods based on triangulation are prone to skeleton distortion and edge noise, and under unconstrained conditions, they are prone to producing intersecting and crossing writing paths, resulting in the loss of stroke topology features.

Method used

A CT-GSA-based approach is adopted, which increases endpoints through triangulation, performs boundary degradation and sorts the topological feature point set, generates stroke writing paths by combining graph search algorithm, establishes boundary collision constraints, and optimizes the skeleton topological point set.

Benefits of technology

It effectively preserves stroke style, reduces redundant triangles, avoids path branches and crossings, and generates writing paths that retain stroke topological features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116597452B_ABST
    Figure CN116597452B_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for generating handwritten Chinese character writing paths based on CT-GSA. It involves sampling the stroke contours of handwritten Chinese characters and establishing a constraint dictionary. Based on constrained triangulation (CT), it solves for the stroke skeleton topology point set, thus obtaining a writing path topology feature point set that preserves the stroke style. Boundary degradation is applied to the geometric stroke contours of handwritten Chinese characters to optimize the result, yielding a skeleton topology point set suitable for stroke path search. The path points in the point set are sorted by nearest neighbor, and corresponding boundary collision constraints are established during the path search process, completing the preprocessing of the stroke skeleton topology point set before path search. Stroke paths are generated from the topology point set using the graph search algorithm (GSA), resulting in a final handwritten Chinese character stroke writing path suitable for robotic arms, preserving both stroke style and topology features. This invention can obtain a relatively smooth writing path that preserves the topology features of handwritten Chinese character strokes, suitable for robotic arms.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of calligraphy digitization, and particularly relates to a handwriting Chinese character writing path generation method and device based on CT-GSA. BACKGROUND

[0002] The handwriting Chinese character writing path generation method is one of the core technologies of calligraphy digitization. The existing research methods mainly focus on methods based on morphology, methods based on graphics, and methods based on learning. However, in a mechanical arm writing system, in order to obtain a writing path that retains the stroke style and fills in the features as much as possible, a handwriting Chinese character mechanical arm writing path generation method based on graphics is constructed. However, in the process of constructing the method, the following problems exist:

[0003] (1) The traditional writing path generation method based on triangular subdivision often processes the original character image at the pixel level, and directly subdivides the disordered contour points. This method is easily affected by the image contour width and edge noise, and is prone to obtain a "distorted" skeleton point set. Moreover, for soft pen character images with variable contour stroke width, a large number of redundant triangles will be generated.

[0004] (2) The traditional writing path generation method based on triangular subdivision is stored in disordered form after subdivision, and it is difficult to filter the influence of the complex contour of the handwriting Chinese character stroke. This method is prone to produce "crossing" and "crossing" writing paths under unconstrained conditions, and directly searching the path point set will lose the stroke filling feature.

[0005] Therefore, a handwriting Chinese character mechanical arm writing path generation method based on CT-GSA is needed to solve the problems of "skeleton distortion" and being easily affected by edge noise in the traditional triangular subdivision method, and the problem of "distorted" writing path under unconstrained conditions in the traditional writing path generation method based on triangular subdivision. SUMMARY

[0006] To solve the problems of the prior art and achieve the purpose of avoiding "skeleton distortion" and reducing the influence of edge noise, the application adopts the following technical solutions:

[0007] The handwriting Chinese character writing path generation method based on CT-GSA includes the following steps:

[0008] Step 1: Based on the stroke geometric contour and triangular subdivision, the end points are increased through the subdivided triangles, and the point set is supplemented to obtain a writing path filling feature point set that retains the stroke style;

[0009] Step 2: Based on the area threshold, the boundary of the triangle is degenerated to optimize the skeleton filling point set.

[0010] Step 3: Sort the topological feature points as path points, and establish boundary collision constraints based on the path segments formed between the path points and the lines connecting adjacent two points in the contour boundary point set;

[0011] Step 4: Generate the stroke writing path based on the graph search algorithm GSA in combination with the boundary collision constraints.

[0012] Further, the step 1 comprises the following steps:

[0013] Step 1.1: By means of the iterative adaptive point method, connect the arranged pixel point coordinates two by two, and connect the adjacent two points in the contour boundary point set according to a certain step length t step Segment, by traversing each pixel point P of the current segment, obtain the pixel point P mid with the maximum distance d max from the chord, if d max is less than a pre-defined distance threshold, replace the original multi-segment polyline with the straight line connecting the two end points, if d max is greater than the pre-defined distance threshold, connect P mid with the head and tail points of the segment respectively to obtain two new segments, repeat the above connection and segmentation operation, and finally realize sampling of the single stroke contour point set data;

[0014] Step 1.2: Establish a constraint dictionary Dic for the graph to be dissected, and obtain the geometric contour of the stroke after sampling based on the constraint dictionary Dic, the constraint dictionary Dic is as follows:

[0015] Dic=[D vertices =T v , D segments =T s , D holes =T h ]

[0016] T v =[(i, x1, y1), (i, x2, y2),..., (i, x m , y m )]

[0017] T s =[(0,1), (1,2), (2,3),..., (m-1,m), (m,0)]

[0018] T h =[(0,0)]

[0019] Wherein, let the geometric contour graph point set D vertices of the current stroke to be dissected be T v , and the boundary set Dsegments For T s Hole set D holes For T h m represents the number of vertices in the point set of the geometric stroke outline, x and y represent the vertex coordinates, i represents the current stroke index, and there is a constraint dictionary element T for any geometric stroke. v T s and T h ;

[0020] Step 1.3: Use the Triangle graphics library to triangulate the sampled geometric contours;

[0021] Step 1.4: Calculate the geometric contour of the segmented figure and solve for the skeleton topology feature point set.

[0022] Furthermore, step 1.4 includes the following steps:

[0023] Step 1.4.1: Classify triangles. First, calculate the index distance d between the three sides e1, e2, and e3 of each triangle. 1st d 2nd and d 3rd When the index distance of the edge is equal to 1, e = 1; otherwise, e = 0. Calculate the sum of the three edge labels of the current triangle. If sum(e1, e2, e3) = 0, it is an inset triangle; if it is 1, it is an adjacent triangle; if it is 2, it is a boundary triangle; if it is 3, it is an isolated triangle. Isolated triangles are an abnormal message and should be checked for errors.

[0024] Step 1.4.2: For the boundary triangle, add the two endpoints of the median to the topological set P. s ;

[0025] Step 1.4.3: For adjacent triangles, denote the two vertices with adjacent indices on their boundary edges as T. n and T n+1 The other point is denoted as T. k Two points on the midline of each triangle parallel to the boundary side and Added as a skeleton topology point to the topology point set P s ;

[0026] Step 1.4.4: For an inset triangle, the indices of its vertices are the three non-adjacent points, denoted here as T. n T k T q Find the midpoints of the three sides and the centroid of the triangle. and Add as a candidate topological point to the topological point set P s .

[0027] Further, the step 2 comprises the following steps:

[0028] Step 2.1: Set area threshold A threshold , the original set of subdivision triangles G t is performed type lookup;

[0029] Step 2.2: If the current triangle is a boundary triangle, the index of the current triangle in the original triangle set is queried, the internal edge of the current ordered triangle is queried, and the index of the current boundary triangle, the triangle point set, and the internal edge are recorded. If the current triangle is not a boundary triangle, step 2.3 is directly jumped to;

[0030] Step 2.3: Step 2.1 is jumped to until all original sets of subdivision triangles G t are traversed;

[0031] Step 2.4: Degeneration operation is performed on the marked boundary triangle, and the current boundary triangle is initialized;

[0032] Step 2.5: If it is an embedded triangle, step 2.6 is executed by entering the next boundary triangle and returning to step 2.4 until all marked boundary triangles are traversed. If it is not, the size of the area of the current boundary triangle is compared with the area threshold A threshold . If it is smaller than the area threshold, the index of the contour of the triangle is recorded, and the adjacent triangle is set as the current triangle. Step 2.5 is executed again;

[0033] Step 2.6: The index of the contour recorded in step 2.5 is deleted.

[0034] Further, the step 3 comprises the following steps:

[0035] Step 3.1: The ordered skeleton point set P′ S is obtained by a nearest neighbor point ordering algorithm in a clockwise or counterclockwise order;

[0036] Step 3.2: It is judged whether the current searched stroke path segment S path intersects the line between two adjacent points in the contour boundary point set. The stroke path segment S path is the line between the current path point s pre and the target path point s nxt .

[0037] Step 3.3: If yes, step 3.4 is entered. If not, the next path segment is entered, and step 3.2 is executed again;

[0038] Step 3.4: A penalty term is applied when calculating the search path weight.

[0039] Furthermore, the nearest neighbor sorting algorithm in step 3.1 includes the following steps:

[0040] Step 3.1.1: For the topological set P s Perform a preliminary sorting based on the x-coordinate priority;

[0041] Step 3.1.2: Obtain the initial point in the point set P s The index is removed from the memory of the point set to reduce memory consumption, and the initial point is appended to the result point set P′. S ;

[0042] Step 3.1.3: Starting from the initial point, sequentially select points in the point set as p. start Find the remaining set of points P s Mid-range p start For the nearest point, obtain its index and remove it from the point set P. s Delete from memory and append to the skeleton topological point set P′ as the result point set. S Update the initial point to the current point, and repeat step 3.1.3 until p. start Iterate through all the points.

[0043] Furthermore, the nearest neighbor sorting algorithm in step 3.2 includes the following steps:

[0044] Step 3.2.1: Add points p to the current stroke skeleton. j The candidate paths obtained by applying breadth-first search (BFS) to them With all contour boundary segments and etc., respectively by boundary contour segments and the current path segment Draw a rectangle along the diagonal; the coordinates of the endpoints of the two line segments are represented as b. i (x i ,y i ) and b i+1 (x i+1 ,y i+1 ) and p j (x j ,y j ) and p j+1 (x j+1 ,y j+1 Then, we get two diagonal rectangles R. i and R j Vertex coordinates are represented as:

[0045] R i [(x i ,y i ),(x i,y i+1 ),(x i+1 ,y i ),(x i+1 ,y i+1 )]

[0046] R j [(x j ,y j ),(x j ,y j+1 ),(x j+1 ,y j ),(x j+1 ,y j+1 )]

[0047] Step 3.2.2: Determine the diagonal rectangle R i and R j Whether they intersect; if the coordinate operations simultaneously satisfy the following four conditions, the diagonal rectangles are considered to intersect; otherwise, they are considered not to intersect:

[0048]

[0049] Step 3.2.3: If the rectangles are determined to intersect, proceed to step 3.2.4, the straddle experiment; if the rectangles are determined not to intersect, terminate the experiment.

[0050] Step 3.2.4: Perform further cross-crossing determination on the two line segments that intersect the rectangles.

[0051] Furthermore, in step 3.2.4, the two line segments intersecting the diagonal rectangles exist in two states: one is that the line segments are straddling each other, and the other is that the line segments are separate. The coordinate calculation form for determining the collision is as follows:

[0052]

[0053] Furthermore, step 4 includes the following steps:

[0054] Step 4.1: Visit the points in the skeleton topology set of each stroke and use them as vertices of the graph. Connect the points in the order of the nearest neighbor points to obtain subgraphs. Superimpose all the subgraphs to build a directed graph.

[0055] Step 4.2: Calculate the weight of each edge, transform the subgraph of the directed graph into a weighted graph, and select the Minkowski distance between any two vertices in the subgraph as the weight of that edge. For any subgraph G... i <V i E i Any two vertices (v) in > i ,v j In the Cartesian coordinate system, the coordinates of the two vertices are v0 and v0 respectively. i (x′i ,y′ i ) and v j (x′ j ,y′ j If the weight d between the vertex pairs is given, then the weight d between the vertex pairs is given. ij The following relationship must be satisfied:

[0056]

[0057] Step 4.3: Use level-order traversal to perform path search. According to step 4.2, solve the weight between two vertices of each subgraph and backtrack to store them into a container to obtain all possible paths. Use quicksort to find the path with the lowest weight cost, i.e., the shortest path is the shortest, and it is determined to be converged.

[0058] The handwritten Chinese character writing path generation device based on CT-GSA includes a memory and one or more processors. The memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the handwritten Chinese character writing path generation method based on CT-GSA.

[0059] The advantages and beneficial effects of this invention are as follows:

[0060] The present invention relates to a method and apparatus for generating handwritten Chinese character writing paths based on CT-GSA. By obtaining a set of writing path topological feature points that preserves the stroke style, it solves the problem that traditional thinning methods are sensitive to contours and easily lose the original stroke topological structure features. Through boundary degradation, it optimizes the skeleton topological point set, reducing computational load and solving the problem of redundant triangles leading to path "branching" caused by traditional triangulation methods. By sorting the path points, it establishes boundary collision constraints. Based on the graph search algorithm GSA, it generates stroke writing paths, solving the problem that direct searching of the stroke skeleton topological point set obtained by traditional triangulation methods will result in path "crossing". In a robotic arm writing system, this invention can reduce redundant triangles caused by the triangulation algorithm and obtain writing paths that preserve stroke topological features. Attached Figure Description

[0061] Figure 1 This is a flowchart of a method for generating handwritten Chinese character writing paths based on CT-GSA in an embodiment of the present invention.

[0062] Figure 2 This is a schematic diagram of the process of generating geometric stroke contour graphics based on CT in an embodiment of the present invention.

[0063] Figure 3 This is a schematic diagram illustrating the classification of geometric strokes (triangles) in an embodiment of the present invention.

[0064] Figure 4aThis is a schematic diagram of the topological point set of the writing trajectory skeleton before boundary degradation in an embodiment of the present invention.

[0065] Figure 4b This is a schematic diagram of the topology point set of the writing trajectory skeleton after the boundary degradation algorithm is optimized in an embodiment of the present invention.

[0066] Figure 5 This is a schematic diagram of the stroke boundary collision constraint determination process in an embodiment of the present invention.

[0067] Figure 6a This is a schematic diagram illustrating the line segment state discrimination in the boundary contour and current path intersection state determination in an embodiment of the present invention.

[0068] Figure 6b This is one of the schematic diagrams of the cross product of line segment vectors in determining the intersection state of the boundary contour and the current path in an embodiment of the present invention.

[0069] Figure 6c This is the second schematic diagram of the cross product of line segment vectors in determining the intersection state of the boundary contour and the current path in an embodiment of the present invention.

[0070] Figure 7 This is a schematic diagram of a directed graph based on a skeleton topology point set in an embodiment of the present invention.

[0071] Figure 8 This is a schematic diagram of the structure of the handwritten Chinese character writing path generation device based on CT-GSA in an embodiment of the present invention. Detailed Implementation

[0072] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0073] like Figure 1 As shown, the method for generating handwritten Chinese character writing paths based on CT-GSA includes the following steps:

[0074] Step 1: Obtain the set of topological feature points for the writing path that preserves the stroke style, such as Figure 2 As shown, it includes the following steps:

[0075] Step 1.1: Using the iterative adaptive point method, connect the coordinates of the arranged pixels pairwise, according to a certain step size t. step Divide the curve into segments, and by traversing each pixel P in the current segment, find the pixel P that is furthest from the chord in that segment. mid and maximum distance d max If d max If the distance is less than a pre-defined threshold, the straight line connecting the two endpoints is used to replace the original polyline. If d maxIf the distance exceeds a pre-defined threshold, then the first and last points of the segment will be connected to P respectively. mid Connect the two segments to obtain two new segments, repeat the above operation, and finally achieve sampling of the single stroke outline point set data;

[0076] Step 1.2: Establish a constraint dictionary Dic for the graphic to be subdivided. Let T be the geometric contour point set of the current stroke to be subdivided. v The boundary set is T s The hole set is T h The constraint dictionary then becomes as follows:

[0077] Dic = [D vertices =T v D segments =T s D holes =T h ]

[0078] Let m represent the number of vertices in the point set of the geometric stroke outline, and i represent the current stroke index. For any geometric stroke, there is a constraint dictionary element T. v T s and T h :

[0079] T v =[(i,x1,y1),(i,x2,y2),…,(i,x m ,y m )]

[0080] T s =[(0,1),(1,2),(2,3),…,(m-1,m),(m,0)]

[0081] T h =[(0,0)]

[0082] The geometric contours of the sampled strokes were obtained by solving the problem;

[0083] Step 1.3: Use the Triangle graphics library to triangulate the sampled geometric contours;

[0084] Step 1.4: Calculate the geometric contour of the partitioned figure and solve for the skeleton topology point set, including the following steps:

[0085] Step 1.4.1: Classify triangles, such as... Figure 3 The triangles shown are divided into three categories: boundary triangles, adjacent triangles, and inset triangles. The specific classification method is to first calculate the index distance d of the three sides e1, e2, and e3 of each triangle (e = 1 when the index distance of the side is equal to 1, otherwise e = 0). 1st d 2ndand d 3rd Calculate the sum of the three side markings of the current triangle. If sum(e1,e2,e3) = 0, it is an inset triangle; if it is 1, it is an adjacent triangle; if it is 2, it is a boundary triangle; if it is 3, it is an isolated triangle. This is an abnormal message and you should check if there is an error.

[0086] Step 1.4.2: For the boundary triangle, add the two endpoints of the median to the topological set P. s ;

[0087] Step 1.4.3: For adjacent triangles, denote the two vertices with adjacent indices on their boundary edges as T. n and T n+1 The other point is denoted as T. k For each triangle, place two points on the midline parallel to the boundary side. and Added as a skeleton topology point to the topology point set P s ;

[0088] Step 1.4.4: For an inset triangle, the indices of its vertices are the three non-adjacent points, denoted here as T. n ,T k ,T q Find the midpoints of the three sides and the centroid of the triangle. and Add as a candidate topological point to the topological point set P s .

[0089] Step 2: Perform boundary degradation and optimize the skeleton topology point set, such as... Figure 4a , Figure 4b As shown, it includes the following steps:

[0090] Step 2.1: Set area threshold A threshold For the original set of partitioned triangles G t Perform a type search;

[0091] Step 2.2: If it is determined to be a boundary triangle, query the index of the current triangle in the original triangle set, query the internal edges of the currently sorted triangles, and record the index, triangle point set, and internal edges of the current boundary triangle. If it is determined to be a non-boundary triangle, jump directly to step 2.3.

[0092] Step 2.3: Jump to step 2.1 and continue until all original triangular sets G have been traversed. t Perform step 2.4;

[0093] Step 2.4: Perform a degenerate operation on the marked boundary triangles to initialize the current boundary triangles;

[0094] Step 2.5: If it is an inset triangle, proceed to the next boundary triangle and return to step 2.4 until all marked boundary triangles have been traversed, then proceed to step 2.6. If not, compare the area of ​​the current boundary triangle with the area threshold A. threshold If the value is smaller than the value, record the index of the triangle outline and set the adjacent triangle as the current triangle, then execute step 2.5 again.

[0095] Step 2.6: Delete the index of the contour recorded in Step 2.5 and update the topology point set P. s .

[0096] Step 3: Sort the path points and establish boundary collision constraints, including the following steps:

[0097] Step 3.1: Using the nearest neighbor sorting algorithm, obtain the sorted skeleton topology point set P′ after scanning and storing in clockwise or counterclockwise order. S The nearest neighbor sorting algorithm includes the following steps:

[0098] Step 3.1.1: For the topological set P s Perform a preliminary sorting based on the x-coordinate priority;

[0099] Step 3.1.2: Obtain the initial point in the point set P s The index is removed from the memory of the point set to reduce memory consumption, and the initial point is appended to the result point set P′. S ;

[0100] Step 3.1.3: Starting from the initial point, sequentially select points in the point set as p. start Find the remaining set of points P s Mid-range p start For the nearest point, obtain its index and remove it from the point set P. s Delete from memory and append to result point set P′ S Update the initial point to the current point, and repeat step 3.1.3 until p. start Iterate through all the points.

[0101] Step 3.2: Determine the currently searched stroke path segment S path (Current path point s) pre and target path point s nxt Whether the line connecting the points intersects with the line connecting any two adjacent points in the contour boundary point set includes the following steps:

[0102] Step 3.2.1: Add points p to the current stroke skeleton. j The candidate paths obtained by applying breadth-first search (BFS) to them With all contour boundary segments and etc., respectively by boundary contour segments and the current path segment Draw a rectangle along the diagonal. Let the coordinates of the endpoints of the two line segments be represented as b. i (x i y i ) and b i+1 (x i+1 y i+1 ) and p j (x j y j ) and p j+1 (x j+1 y j+1 Then, we can obtain two diagonal rectangles R. i and R j Vertex coordinates are represented as:

[0103] R i [(x i y i ), (x i y i+1 ), (x i+1 y i ), (x i+1 y i+1 )]

[0104] R j [(x j y j ), (x j y j+1 ), (x j+1 y j ), (x j+1 y j+1 )]

[0105] Step 3.2.2: Determine the diagonal rectangle R i and R j Whether they intersect. Specifically, if the coordinate operations simultaneously satisfy the following four conditions, the diagonal rectangles are considered to intersect; otherwise, they are considered not to intersect:

[0106]

[0107] Step 3.2.3: If the rectangles are determined to intersect, proceed to step 3.2.4, the straddle experiment; if the rectangles are determined not to intersect, terminate the experiment.

[0108] Step 3.2.4: Perform further cross-sectional determination on the two intersecting line segments of the rectangles. For example... Figure 6a to Figure 6c As shown, it is Figure 5For example, two line segments intersecting diagonal rectangles can exist in two states: either the line segments are straddling each other, or they are disjoint. The general form of the coordinate calculation for determining a collision is:

[0109]

[0110] Step 3.3: If yes, proceed to step 3.4; otherwise, proceed to the next path and execute step 3.2 again.

[0111] Step 3.4: Apply a penalty term when calculating the search path weight.

[0112] Step 4: Generate stroke writing paths based on the Graph Search Algorithm (GSA), including the following steps:

[0113] Step 4.1: Access the points in the skeleton topology set of each stroke as vertices of the graph, connect the points in the order of nearest neighbor points to obtain subgraphs, and superimpose all the subgraphs to build a directed graph.

[0114] Step 4.2: Calculate the weight of each edge, transform the subgraph of the directed graph into a weighted graph, and select the Minkowski distance between every two vertices in the subgraph as the weight of that edge. For any subgraph G... i <V i E i Any two vertices (v) in > i ,v j Let the coordinates of the two vertices in the Cartesian coordinate system be v0 and v1 respectively. i (x′ i ,y′ i ) and v j (x′ j ,y′ j If the weight d between the vertex pairs is given, then the weight d between the vertex pairs is given. ij The following relationship must be satisfied:

[0115]

[0116] Step 4.3: Finally, a level-order traversal is used for path search. Based on Step 4.2, the weights between the two vertices of each subgraph are calculated, and these weights are backtracked and stored in a container to obtain all possible paths. The path with the lowest weight cost (shortest path) is then determined to be converged using quicksort. Figure 7 As shown.

[0117] Corresponding to the aforementioned embodiments of the handwritten Chinese character writing path generation method based on CT-GSA, the present invention also provides embodiments of a handwritten Chinese character writing path generation device based on CT-GSA.

[0118] See Figure 8The handwritten Chinese character writing path generation device based on CT-GSA provided in this embodiment of the invention includes a memory and one or more processors. The memory stores executable code. When the one or more processors execute the executable code, they are used to implement the handwritten Chinese character writing path generation method based on CT-GSA in the above embodiment.

[0119] The embodiments of the CT-GSA-based handwritten Chinese character writing path generation device of the present invention can be applied to any device with data processing capabilities, such as a computer. The device embodiments can be implemented through software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by the processor of any data processing device loading the corresponding computer program instructions from non-volatile memory into memory for execution. From a hardware perspective, such as... Figure 8 The diagram shown is a hardware structure diagram of any device with data processing capabilities, including the CT-GSA-based handwritten Chinese character writing path generation device of this invention. (Except for...) Figure 8 In addition to the processor, memory, network interface, and non-volatile memory shown, any data processing device in the embodiment may also include other hardware depending on the actual function of the data processing device, which will not be described in detail here.

[0120] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.

[0121] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the present invention according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0122] This invention also provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements the CT-GSA-based method for generating handwritten Chinese character writing paths as described in the above embodiments.

[0123] The computer-readable storage medium can be an internal storage unit of any data processing device as described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be an external storage device of any data processing device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units and external storage devices of any data processing device. The computer-readable storage medium is used to store the computer program and other programs and data required by the data processing device, and can also be used to temporarily store data that has been output or will be output.

[0124] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating handwritten Chinese character writing paths based on CT-GSA, characterized in that: Includes the following steps: Step 1: Based on the geometric contour of the strokes, perform triangulation, add endpoints to the triangulated triangles, and fill in the point set to obtain the topological feature point set; Specifically, the following steps are included: Step 1.1: Using the iterative adaptive point method, connect the coordinates of the arranged pixels pairwise, according to a certain step size t. step Divide the curve into segments, and by traversing each pixel P in the current segment, find the pixel P that is furthest from the chord in that segment. mid and maximum distance d max If d max If the distance is less than a pre-defined threshold, the straight line connecting the two endpoints is used to replace the original polyline. If d max If the distance exceeds a pre-defined threshold, then the first and last points of the segment will be connected to P respectively. mid Connect the two segments to obtain two new segments. Repeat the above connection and segmentation operation to finally sample the data of a single stroke outline point set. Step 1.2: Establish a constraint dictionary Dic for the graphic to be subdivided. Based on the constraint dictionary Dic, the geometric contours of the sampled strokes are obtained. The constraint dictionary Dic is as follows: Dic=[D vertices =T v ,D segments =T s ,D holes =T h ] T v =[(i,x1,y1),(i,x2,y2),…,(i,x m ,y m )] T s =[(0,1),(1,2),(2,3),…,(m-1,m),(m,0)] T h =[(0,0)] Let D be the set of geometric contour points of the stroke to be subdivided. vertices For T v Boundary set D segments For T s Hole set D holes For T h m represents the number of vertices in the point set of the geometric stroke outline, x and y represent the vertex coordinates, i represents the current stroke index, and there is a constraint dictionary element T for any geometric stroke. v T s and T h ; Step 1.3: Use the Triangle graphics library to triangulate the sampled geometric contours; Step 1.4: Calculate the geometric contour of the segmented figure and solve for the skeleton topology feature point set; specifically including the following steps: Step 1.4.1: Classify triangles. First, calculate the index distance d between the three sides e1, e2, and e3 of each triangle. 1st d 2nd and d 3rd When the index distance of the edge is equal to 1, e = 1; otherwise, e = 0. Calculate the sum of the three edge markings of the current triangle. If sum(e1,e2,e3) = 0, it is an inset triangle; if it is 1, it is an adjacent triangle; if it is 2, it is a boundary triangle. Step 1.4.2: For the boundary triangle, add the two endpoints of the median to the topological set P. s ; Step 1.4.3: For adjacent triangles, denote the two vertices with adjacent indices on their boundary edges as T. n and T n+1 The other point is denoted as T. k Two points on the midline of each triangle parallel to the boundary side and Added as a skeleton topology point to the topology point set P s ; Step 1.4.4: For an inset triangle, the indices of its vertices are the three non-adjacent points, denoted here as T. n ,T k ,T q Find the midpoints of the three sides and the centroid of the triangle. and Add as a candidate topological point to the topological point set P s ; Step 2: Based on the area threshold, perform boundary degradation on the triangle that serves as the boundary; Step 3: Sort the topology feature points as path points, and establish boundary collision constraints based on the path segments formed between the path points and the lines connecting adjacent points in the contour boundary point set. Step 4: Combine boundary collision constraints and generate stroke writing paths based on graph search algorithm.

2. The method for generating handwritten Chinese character writing paths based on CT-GSA according to claim 1, characterized in that: Step 2 includes the following steps: Step 2.1: Set area threshold A threshold For the original set of partitioned triangles G t Perform a type search; Step 2.2: If it is determined to be a boundary triangle, query the index of the current triangle in the original triangle set, query the internal edges of the currently sorted triangles, and record the index, triangle point set, and internal edges of the current boundary triangle. If it is determined to be a non-boundary triangle, jump directly to step 2.

3. Step 2.3: Jump to step 2.1 and continue until all original triangular sets G have been traversed. t Perform step 2.4; Step 2.4: Perform a degenerate operation on the marked boundary triangles to initialize the current boundary triangles; Step 2.5: If it is an inset triangle, proceed to the next boundary triangle and return to step 2.4 until all marked boundary triangles have been traversed, then proceed to step 2.6; otherwise, compare the area of ​​the current boundary triangle with the area threshold A. threshold If the size is less than the area threshold, record the index of the triangle outline and set the neighboring triangles as the current triangle, then execute step 2.5 again; Step 2.6: Delete the index of the outline recorded in Step 2.

5.

3. The method for generating handwritten Chinese character writing paths based on CT-GSA according to claim 1, characterized in that: Step 3 includes the following steps: Step 3.1: Using the nearest neighbor sorting algorithm, obtain the sorted skeleton topology point set P, which is scanned and stored in clockwise or counterclockwise order. S ′ ; Step 3.2: Determine the currently searched stroke path segment S path Does the stroke path segment S intersect with the line connecting two adjacent points in the contour boundary point set? path For the current path point s pre and target path point s nxt The lines connecting them; Step 3.3: If yes, proceed to step 3.4; otherwise, proceed to the next path and execute step 3.2 again. Step 3.4: Apply a penalty term when calculating the search path weight.

4. The method for generating handwritten Chinese character writing paths based on CT-GSA according to claim 3, characterized in that: The nearest neighbor sorting algorithm in step 3.1 includes the following steps: Step 3.1.1: For the topological set P s Perform a preliminary sorting based on the x-coordinate priority; Step 3.1.2: Obtain the initial point in the topological set P s The index is removed from the memory of the point set to reduce memory consumption, and the initial point is appended to the skeleton topology point set P. S ′ ; Step 3.1.3: Starting from the initial point, sequentially select points in the point set as p. start Find the remaining topological set P s Mid-range p start For the nearest point, obtain its index and add it to the topological set P. s Delete and add the skeleton topology point set P as the result point set. S ′ Update the initial point to the current point, and repeat step 3.1.3 until p. start Iterate through all the points.

5. The method for generating handwritten Chinese character writing paths based on CT-GSA according to claim 3, characterized in that: The nearest neighbor sorting algorithm in step 3.2 includes the following steps: Step 3.2.1: Add points p to the current stroke skeleton. j The candidate paths are obtained by applying a breadth-first search. With all contour boundary segments and Each with boundary contour segment and the current path segment Draw a rectangle along the diagonal; the coordinates of the endpoints of the two line segments are represented as b. i (x i ,y i ) and b i+1 (x i+1 ,y i+1 ) and p j (x j ,y j ) and p j+1 (x j+1 ,y j+1 Then, we get two diagonal rectangles R. i and R j Vertex coordinates are represented as: R i [(x i ,and i ),(x i ,and i+1 ),(x i+1 ,and i ),(x i+1 ,and i+1 )] R j [(x j ,and j ),(x j ,and j+1 ),(x j+1 ,and j ),(x j+1 ,and j+1 )] Step 3.2.2: Determine the diagonal rectangle R i and R j Whether they intersect; if the coordinate operations simultaneously satisfy the following four conditions, the diagonal rectangles are considered to intersect; otherwise, they are considered not to intersect: Step 3.2.3: If the rectangles are determined to intersect, proceed to step 3.2.4, the straddle experiment; if the rectangles are determined not to intersect, terminate the experiment. Step 3.2.4: Perform further cross-crossing determination on the two line segments that intersect the rectangles.

6. The method for generating handwritten Chinese character writing paths based on CT-GSA according to claim 5, characterized in that: In step 3.2.4, there are two states for the two line segments intersecting the diagonal rectangles: one is that the line segments are straddling each other, and the other is that the line segments are separate. The coordinate calculation form for determining the collision is as follows:

7. The method for generating handwritten Chinese character writing paths based on CT-GSA according to claim 1, characterized in that: Step 4 includes the following steps: Step 4.1: Visit the points in the skeleton topology set of each stroke and use them as vertices of the graph. Connect the points in the order of the nearest neighbor points to obtain subgraphs. Superimpose all the subgraphs to build a directed graph. Step 4.2: Calculate the weight of each edge, transform the subgraph of the directed graph into a weighted graph, and select the Minkowski distance between any two vertices in the subgraph as the weight of that edge. For any subgraph G... i <V i E i Any two vertices (v) in > i ,v j In the Cartesian coordinate system, the coordinates of the two vertices are v0 and v0 respectively. i (x' i ,y' i ) and v j (x' j ,y' j If the weight d between the vertex pairs is given, then the weight d between the vertex pairs is given. ij The following relationship must be satisfied: Step 4.3: Use level-order traversal to perform path search. Solve the weight between two vertices of each subgraph according to step 4.2, and store them backtrackingly to obtain all possible paths. Find the path with the lowest weight cost by quicksort, i.e., the shortest path is the shortest, and it is determined to be converged.

8. A handwritten Chinese character writing path generation device based on CT-GSA, characterized in that, The method includes a memory and one or more processors, wherein the memory stores executable code, and the one or more processors execute the executable code to implement the method for generating handwritten Chinese character writing paths based on CT-GSA as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Chinese character zooming method

    CN107507129A

  • Automatic stroke extraction method for calligraphy single character

    CN110659644A