A Handwritten Stroke Smoothing Algorithm Based on Gradient Map Laplacian Regularization

Through the handwriting smoothing algorithm based on gradient graph Laplace regularity and combined with the translation method of cyclic shift, the problems of distortion of handwriting smoothing algorithm in the prior art, the large amount of computing resource occupancy, and poor processing of discontinuous problems caused by interpolation are solved, and the efficient and memory-saving handwriting smoothing effect is achieved.

CN115393862BActive Publication Date: 2025-07-01FUZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211163459.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2025-07-01
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

The existing handwriting smoothing algorithms have problems such as distortion, high computing resources, extra memory usage, and poor processing of non-smoothing caused by writing discontinuity.

Method used

The handwriting smoothing algorithm based on the gradient map Laplace regularity is used to read the position information of the handwriting points, and the discontinuity problem is dealt with using the cyclic shift translation method, and the energy function is minimized through the gradient map Laplace regular expression to achieve the best smoothing effect of the handwriting.

Benefits of technology

It achieves a good smoothing effect of handwriting, avoids additional memory usage, improves the ability to deal with non-smooth problems caused by writing discontinuity, and meets the actual usage requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115393862B_ABST
    Figure CN115393862B_ABST
Patent Text Reader

Abstract

The present invention provides a handwritten handwriting smoothing algorithm based on gradient graph Laplacian regularization, which includes the following steps: Step S1: Read the position information of handwritten handwriting points; Step S2: Reflect the position information of handwritten handwriting points on a matrix; Step S3: Determine whether two pixel points meet the distance requirement; Step S4: Repeat the above steps; Step S5: Concatenate vectors into a matrix; Step S6: Calculate its adjacency matrix according to the gradient graph constructed by the gradient; Step S7: Obtain the Laplacian matrix; Step S8: According to the Laplacian matrix, obtain its GLR expression form with respect to the gradient; Step S9: Define the energy function of the algorithm in this article; Step S10: Minimize the energy to obtain the best smoothing effect of handwritten handwriting; Applying this technical solution can finally achieve a better handwritten handwriting smoothing effect without occupying additional memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer application technologies, and in particular to a handwritten stroke smoothing algorithm based on gradient graph Laplacian regularization. Background Art

[0002] Handwritten stroke smoothing refers to smoothing the handwritten strokes input through a graphics tablet to make them better conform to the stroke state in natural conditions and more in line with people's aesthetics. It plays an important role in electronic notes and electronic blackboards.

[0003] Today, with the rapid development of science and technology, the frequency of using paper for writing in our daily lives is decreasing, especially for some office workers and students. Because the notes written on paper are not convenient to carry and demonstrate, and it is also very difficult to copy the notes if needed. Using electronic devices such as computers and tablets for taking notes is undoubtedly very convenient to carry. Especially for a large number of notes, using these electronic devices for taking notes is convenient to carry and demonstrate, and if you need to copy the notes, you don't need to use a printer or copy them manually. You just need to copy your note file. Although keyboard input is very convenient for recording text information, it is very inconvenient for some formulas. Moreover, the speed of recording these formulas is too slow, which does not meet the requirements of fast note-taking at all. Online teaching is not convenient for teachers to write on the blackboard, and some professional symbols and formulas are very commonly used when teachers give lectures. Obviously, keyboard input cannot meet the needs of online teaching. Therefore, graphics tablet input has become a new input method.

[0004] A good handwritten stroke smoothing algorithm is very important for electronic notes and online teaching. It can make the electronic blackboard of electronic notes cleaner and more beautiful, facilitating the reading of electronic notes and electronic blackboards. However, there are few existing handwritten stroke smoothing algorithms. The commonly used handwritten stroke smoothing algorithm is the Bezier curve. Currently, mainly the second-order Bezier curve and the third-order Bezier curve are used as handwritten stroke smoothing algorithms. However, using the second-order Bezier curve has a distortion phenomenon, while the third-order Bezier curve requires 4 control points and occupies more computing resources. Moreover, all existing handwritten stroke smoothing algorithms use the interpolation method, which requires additional memory resources. And for the unevenness caused by discontinuous writing, the smoothing effect of existing handwritten stroke smoothing algorithms is poor. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a handwritten stroke smoothing algorithm based on gradient graph Laplacian regularization.

[0006] To achieve the above object, the present invention adopts the following technical solution: A handwritten handwriting smoothing algorithm based on Laplacian regularization of gradient maps, comprising the following steps:

[0007] Step S1: Read the position information of a set of handwritten handwriting points, and store the abscissa and ordinate in vectors a x , a y respectively, where

[0008] Step S2: Reflect the position information of the handwritten handwriting points, i.e., the position information of the pixel points, on the matrix That is, construct matrix A using the following formula:

[0009]

[0010] where and represent the k-th elements of vectors a x and a y respectively;

[0011] Step S3: Determine whether two adjacent pixel points meet a certain distance requirement. If so, use circular shift for region matching. If the matching is successful, perform a translation operation;

[0012] Step S4: Repeat the above steps until all pixel points are traversed. Then, update vectors a x , a y according to the obtained new pixel points;

[0013] Step S5: Concatenate vectors a x , a y into matrix Calculate its vertical gradient g = Fx, where x is the matrix X concatenated by columns, i.e., x is the new vector concatenated by vectors a x , a y , D is a matrix of all zeros,

[0014] Step S6: Calculate the adjacency matrix W of the gradient map constructed based on gradient g;

[0015] Step S7: Calculate its diagonal matrix D, and then obtain the Laplacian matrix L = D - W;

[0016] Step S8: According to the obtained Laplacian matrix L, obtain its GLR expression form with respect to gradient g:

[0017]

[0018] Step S9: Define the energy function E of the present algorithm as

[0019]

[0020] where y is the signal with noise, that is, the vector formed by splicing the coordinate information after the handwritten handwriting passes through the translation method based on cyclic shift, and μ is a regularization coefficient greater than 0, is the signal dependence function of x;

[0021] Step S10: Minimize the energy to obtain the best smoothing effect of the handwritten handwriting.

[0022] In a preferred embodiment: In the step S3, the following steps are further included:

[0023] Step S31: Calculate the Euclidean distance between two adjacent pixel points P i+1 and P i Set two upper and lower thresholds, and perform region matching when the distance between the two pixel points is between these two thresholds;

[0024] Step S32: Select two 5×5 regions R i+1 and P i centered on the two pixel points P i+1 and R i in the matrix A, calculate the circulant matrices of these two regions, and calculate in the Fourier domain,

[0025]

[0026] where ⊙ represents the multiplication of the elements in the matrix R i+1 by the elements in the same position in the matrix R i ; and represent the Fourier transform and its inverse transform respectively;

[0027] Step S33: Set a threshold. When the value of the maximum element of C(R i+1 )R i obtained in step S32 is greater than this threshold, it is considered that the regions where these two pixel points are located are matched, and thus a translation operation is performed. The calculation formula for the translation distance is

[0028]

[0029] Translate all the points after P i by this translation distance.

[0030] In a preferred embodiment: In the step S6, the following steps are further included:

[0031] Step S61: Select each element of the gradient g as a node of the gradient map. Then there are a total of 2(N - 1) nodes.

[0032] Step S62: Define the weight value of the edge connecting node i and node j.

[0033]

[0034] Where is the neighborhood of node i, σ > 0, and is a parameter that controls the weight value between 0 and 1.

[0035] Step S63: Construct the gradient map according to the information of each node and the weight value of the edge between nodes obtained in steps S61 and S62.

[0036] In a preferred embodiment: In the step S10, the following steps are further included:

[0037] Step S101: Minimize the energy function in step S9 and solve it by an iterative method. Fix Solve it using the following analytical formula

[0038]

[0039] When solving, directly solving can improve the calculation speed.

[0040] Step S102: Every time an iteration is performed in step 101, update the gradient map according to steps S5 and S6, and update according to steps S7 and S8.

[0041] Step S103: Substitute the obtained in step S102 into step S101.

[0042] Step S104: Repeat steps S101, S102, and S103 until convergence. The optimal solution obtained later is a vector x, and decompose it from the middle into two vectors x x , x y , that is Combine x x , x y at the corresponding positions to form new pixel points, and these pixel points constitute the best handwritten strokes smoothed by this algorithm.

[0043] ​The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a handwriting smoothing algorithm based on the gradient graph Laplace regularization are implemented.

[0044] Compared with the prior art, the present invention has the following beneficial effects:

[0045] 1) The present invention uses a translation method based on circular shift, which can be used to deal with the problem of uneven handwriting caused by discontinuous writing, and has a good smoothing effect, which is not available in other handwriting smoothing algorithms;

[0046] 2) Using the gradient graph Laplace regularization to smooth handwriting does not generate additional interpolation points like other handwriting smoothing algorithms, and does not occupy additional memory. Experiments show that the handwriting smoothing effect of the present invention is better than other handwriting smoothing algorithms. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 The flowchart of the handwriting smoothing algorithm based on the gradient graph Laplace regularization in the preferred embodiment of the present invention.

[0048] Figure 2 Only two groups of handwritten traces to be processed in the preferred embodiment of the present invention are listed here.

[0049] Figure 3 This is a diagram showing the effect of handwriting smoothing in a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0050] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0051] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.

[0052] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application; as used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or their combinations.

[0053] like Figures 1 - 3 As shown, a handwriting smoothing algorithm based on gradient graph Laplace of the present invention is implemented by the following steps:

[0054] Step S1: Read the position information of a group of handwritten trace points, i.e., the position information of pixel points, and store the horizontal and vertical coordinates in vector a respectively. x , a y Among them

[0055] Step S2: Place the handwriting position information in the matrix The above is reflected, that is, the matrix A is constructed using the following formula:

[0056]

[0057] Among them, and Respectively represent a x Vector and a y The kth element of the vector;

[0058] Step S3: Determine whether two adjacent pixel points meet a certain distance requirement. If so, use circular shift to perform region matching. If the match is successful, perform a translation operation.

[0059] Step S4: Repeat the above steps until all pixels are traversed, and then re-update the vector a according to the new pixels obtained. x , a y ;

[0060] Step S5: transform vector a x , a y Splice into a matrix Since the horizontal gradient of matrix X is actually the subtraction of the horizontal coordinate and the vertical coordinate of the same pixel, it is only related to the pixel itself and has nothing to do with the pixels near it. Therefore, the horizontal gradient is not considered when constructing the gradient map, so we can calculate its vertical gradient g = Fx, where x is the matrix X concatenated by column, that is, x is the vector a x , a y The new vector formed by concatenation, O is an all-zero matrix,

[0061] Step S6: Gradient map constructed based on gradient g Calculate its adjacency matrix W;

[0062] Step S7: Calculate its diagonal matrix D, and then obtain the Laplace matrix L=DW;

[0063] Step S8: Based on the obtained Laplace matrix L, its GLR expression for the gradient g can be obtained:

[0064]

[0065] Step S9: Define the energy function of the algorithm in this article as

[0066]

[0067] where y is the signal with noise, which is the vector formed by splicing the coordinate information after the handwritten strokes pass through the translation method based on cyclic shift here, μ is a regularization coefficient greater than 0, is the signal dependence function of x;

[0068] Step S10: Minimizing the energy can obtain the best smoothing effect of the handwritten strokes.

[0069] Specifically, in the said Step S3, the following steps are further included:

[0070] Step S31: Calculate the Euclidean distance between two adjacent pixel points P i+1 and P i Set two thresholds, upper and lower. When the distance between the two pixel points is between these two thresholds, area matching is performed;

[0071] Step S32: Select two 5×5 regions R i+1 and P i centered on the two pixel points in matrix A respectively, i+1 、R i Calculate the circulant matrices of these two regions, which can be calculated in the Fourier domain,

[0072]

[0073] where ⊙ represents the multiplication of the elements in matrix R i+1 and the elements in matrix R i at the same position, and represent the Fourier transform and its inverse transform respectively;

[0074] Step S33: Set a threshold. When the maximum element value of C(R i+1 )R i obtained in Step S32 is greater than this threshold, it is considered that the regions where these two pixel points are located are matched, and thus a translation operation is performed. The calculation formula for the translation distance is

[0075]

[0076] Translate all the points after P i by this translation distance.

[0077] Specifically, in the said Step S6, the following steps are further included:

[0078] Step S61: Select each element of the gradient g as the gradient map , then there are 2(N-1) nodes in total;

[0079] Step S62: Define the weight of the edge connecting node i and node j

[0080]

[0081] in is the neighborhood of node i, σ>0, and is a parameter controlling the weight between 0 and 1;

[0082] Step S63: Construct a gradient graph based on the weight information of each node and the edges between nodes obtained in steps S61 and S62

[0083] Specifically, in said S10, the following steps are also included:

[0084] Step S101: Minimize the energy function in S9, solve it by iterative method, and fix Use the following analytical formula to solve

[0085]

[0086] When solving, you can directly use the inverse matrix to solve, or you can use the conjugate iteration method to solve and improve the calculation speed;

[0087] Step S102: Each time in step 101, the gradient map is updated according to steps S5 and S6, and the gradient map is updated according to steps S7 and S8.

[0088] Step S103: The Substitute into step S101;

[0089] Step S104: Repeat steps S101, S102 and S103 until convergence. The optimal solution is a vector x, which is decomposed into two vectors x of the same size. x , x y ,Right now x x , x y New pixels are formed by combining them according to the corresponding positions, and these pixels constitute the best handwriting after smoothing by this algorithm.

[0090] The following is the specific implementation process of the present invention.

[0091] The specific steps of the algorithm proposed by the present invention for image stitching are as follows:

[0092] 1. Read the position information of a group of handwritten stroke points, and store the abscissa and ordinate in vectors a x , a y respectively, where

[0093] 2. Construct matrix A according to vectors a x , a y ;

[0094] 3. Select adjacent stroke points P i+1 , P i in turn, and calculate the Euclidean distance between them;

[0095] 4. Set two thresholds a and b. If the distance between two adjacent stroke points is within the range of these two thresholds, take these two points as the center, and select regions R i+1 , R i of the same size in matrix A;

[0096] 5. Calculate the circulant matrix C(R i+1 ) of these two regions R i ;

[0097] 6. Set a threshold T. If the largest element in the circulant matrix C(R i+1 ) of R i is greater than T, it is considered that these two regions match, perform a translation operation, and update matrix A;

[0098] 7. Repeat steps 3-6 until all stroke points are traversed. According to the obtained new stroke point position information, update vectors a x , a y . Concatenate vectors a x , a y by columns to obtain vector

[0099] 8. Concatenate vectors a x , a y to form a matrix and vectors to construct gradient g and gradient map

[0100] 9. Calculate the adjacency matrix W according to the gradient map . For the degree matrix D, Laplacian matrix L = W - D, and the signal dependence function of x

[0101] 10. Define the energy function

[0102] 11. Minimize the energy function in 10 to obtain the best smoothing effect for the handwritten strokes.

[0103] Figure 2 For two groups of unsmoothed handwritten stroke images, from Figure 2 We can see that there are obvious non - smoothing problems, and due to the discontinuous writing, there are some intermittent strokes. Figure 3 is the effect diagram of the above - mentioned handwritten stroke smoothing algorithm. From Figure 3 It can be seen that in this example, the algorithm uses the translation method based on cyclic shift to handle the non - smoothing problem caused by discontinuous writing, and then uses the gradient - map Laplacian regularization to process the handwritten strokes, and finally obtains the best smoothing effect for the handwritten strokes. We can clearly see that the smoothed handwritten strokes retain the overall characteristics of the handwritten strokes, look more natural, and have a good effect on the non - smoothing problems caused by discontinuous writing.

[0104] The present invention relates to a handwritten stroke smoothing algorithm based on gradient - map Laplacian regularization. With the development of science and technology, electronic notes have become an important tool in people's daily study and life. A good handwritten stroke smoothing algorithm can help us better use electronic notes and electronic blackboards. However, there are few existing handwritten stroke smoothing algorithms, and the smoothing effect needs to be improved. There is no good smoothing effect for the non - smoothing phenomenon caused by discontinuous writing, which is not conducive to the use of electronic notes and electronic blackboards. Moreover, the existing handwritten stroke smoothing algorithms use the interpolation method, which requires additional memory. Therefore, the present invention first reads the position information of each handwritten stroke point, and then uses the translation method based on cyclic shift, which has a good smoothing effect on the non - smoothing problem caused by discontinuous writing; then uses the method based on gradient - map Laplacian regularization to smooth the handwritten strokes, and finally obtains a better smoothing effect for the handwritten strokes without occupying additional memory. Experiments prove that the smoothing effect of the present invention on handwritten strokes is better than that of other handwritten stroke smoothing algorithms, and it has a good effect on the non - smoothing problems caused by discontinuous writing that other handwritten stroke smoothing algorithms cannot handle. Moreover, the running speed of the present invention fully meets the time requirements for the actual use of handwritten stroke smoothing, and there is no additional memory consumption.

[0105] The above are the preferred embodiments of the present invention. All changes made according to the technical solution of the present invention, when the functional effects produced do not exceed the scope of the technical solution of the present invention, shall fall within the protection scope of the present invention.

Claims

1. A handwritten handwriting smoothing method based on Laplacian regularization of gradient maps, characterized in that: It includes the following steps: Step S1: Read the position information of a set of handwritten stroke points, and store the abscissa and ordinate in vectors a x , a y respectively, where Step S2: Reflect the position information of the handwritten stroke points, i.e., the position information of the pixel points, in the matrix That is, construct matrix A using the following formula: Among them, among them and respectively represent the x vector and the k-th element of the y vector; Step S3: Determine whether two adjacent pixel points meet the distance requirement. If they do, use circular shift for region matching. If the matching is successful, perform a translation operation; Step S4: Repeat the above steps until all the pixel points are traversed, and then update the vector a according to the obtained new pixel points x , a y ; Step S5: Combine the vectors a x , a y to form a matrix and calculate its vertical gradient g = Fx, where x is the matrix X concatenated by columns, that is, x is the new vector formed by concatenating the vectors a x , a y , O is a matrix of all zeros, Step S6: Gradient map constructed based on gradient g Calculate its adjacency matrix W; Step S7: Calculate its diagonal matrix D, and then obtain the Laplacian matrix L = D - W; Step S8: According to the obtained Laplacian matrix L, obtain its GLR expression form with respect to the gradient g: Step S9: Define the energy function E of the algorithm in this article as where y is the signal with noise, that is, the vector formed by splicing the coordinate information after the handwritten strokes pass through the translation method based on cyclic shift, and μ is a regularization coefficient greater than 0, is the signal-dependent function of x; Step S10: Minimize the energy to obtain the best smoothing effect of the handwritten handwriting; In the said Step S3, it further includes the following steps: Step S31: Calculate the Euclidean distance between two adjacent pixel points P i+1 and P i Set two upper and lower thresholds. When the distance between the two pixel points is between these two thresholds, region matching is performed; Step S32: Select two 5×5 regions R i+1 and R i centered on two pixel points P i+1 and P i in matrix A, calculate the circulant matrices of these two regions in the Fourier domain where ⊙ represents multiplying the elements in matrix R i+1 by the elements at the same positions in matrix R i and and represent the Fourier transform and its inverse transform respectively; Step S33: Set a threshold. When the value of the maximum element of C(R i+1 )R i obtained in step S32 is greater than this threshold, it is considered that the regions where these two pixel points are located are matched, and thus a translation operation is performed. The calculation formula for the translation distance is Translate P i All subsequent points are translated according to this translation distance; In the said Step S6, it further includes the following steps: Step S61: Select each element of the gradient g as a node of the gradient map , then there are a total of 2(N - 1) nodes; Step S62: Define the weight of the edge connecting node i and node j Among them is the neighborhood of node i, σ > 0, and is a parameter with the control weight between 0 and 1; Step S63: Construct a gradient graph based on the weight information of each node and the edges between nodes obtained in steps S61 and S62 In the said Step S10, it further includes the following steps: Step S101: Minimize the energy function in Step S9 and solve it using an iterative method. Fix Solve it using the following analytical formula When solving, directly solve to improve the calculation speed; Step S102: Every time an iteration is performed in Step 101, the gradient map needs to be updated according to Steps S5 and S6, and updated according to Steps S7 and S8 Step S103: Substitute the result obtained in Step S102 into Step S101; ​ Step S104: Repeat the three steps of Step S101, Step S102, and Step S103 until convergence. After that, the obtained optimal solution is a vector x, which is decomposed into two vectors x of the same size from the middle. x , x y , that is Combine x x , x y According to the corresponding positions to form new pixel points, and these pixel points constitute the best handwritten strokes after smoothing of this algorithm.

2. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it realizes the steps of a handwritten handwriting smoothing method based on Laplacian regularization of the gradient map as described in Claim 1.

Citation Information

Patent Citations

  • Calculating method for coastline detection of active contour model of inverse Gaussian distribution

    CN107316310A

  • Method for achieving rejection of hand-written character

    CN107679505A