CN114356201B - Writing beautifying method, device, equipment and readable storage medium - Google Patents

Writing beautifying method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN114356201B
CN114356201B CN202111592814.5A CN202111592814A CN114356201B CN 114356201 B CN114356201 B CN 114356201B CN 202111592814 A CN202111592814 A CN 202111592814A CN 114356201 B CN114356201 B CN 114356201B
Authority
CN
China
Prior art keywords
point
track
pen
points
writing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111592814.5A
Other languages
Chinese (zh)
Other versions
CN114356201A (en
Inventor
张亚兵
魏冲洲
谢名亮
常欢
刘东程
程志鹏
胡金水
殷兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
iFlytek Co Ltd
Original Assignee
iFlytek Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by iFlytek Co Ltd filed Critical iFlytek Co Ltd
Priority to CN202111592814.5A priority Critical patent/CN114356201B/en
Publication of CN114356201A publication Critical patent/CN114356201A/en
Application granted granted Critical
Publication of CN114356201B publication Critical patent/CN114356201B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Processing Or Creating Images (AREA)
  • Image Generation (AREA)

Abstract

The application discloses a writing beautification method, a device, equipment and a readable storage medium, wherein the method comprises the following steps: acquiring information of a plurality of writing track points, estimating the pen width to obtain the pen width, and carrying out track smoothing by utilizing an improved three-order Bezier algorithm to obtain information of a plurality of interpolation track points, wherein a control point used by the improved three-order Bezier algorithm comprises a current processing writing track point and the first three writing track points, the plurality of interpolation track points are arranged between a first writing track point and a second writing track point which are arranged in front of the current processing writing track point, and the outer contour of each pen section is calculated.

Description

Writing beautifying method, device, equipment and readable storage medium
Technical Field
The present application relates to the field of writing data processing technology, and in particular, to a writing beautifying method, device, apparatus and readable storage medium.
Background
With the increasing popularity of touch electronic screen terminal devices, such as smartphones, tablet computers, infrared large screens, etc., users can write on various touch electronic screens, and the device can display corresponding handwriting according to the user writing and can change various different types of handwriting effects.
In the process, the device needs to acquire the writing points of the user on the electronic screen as writing track points according to a certain time interval, and smooth and beautify a series of writing track points, so that the writing track points are closer to handwriting to be presented by the user. In the long-term research and development process, the applicant of the application finds that when the existing real-time writing beautifying method beautifies writing track points, the smoothing of the writing track points has larger delay compared with the acquisition of the writing track points.
Disclosure of Invention
The technical problem that this application mainly solves is to provide a method, device, equipment and readable storage medium of beautifying of writing, can reduce the delay of electronic screen writing beautification.
In order to solve the technical problems, one technical scheme adopted by the application is as follows: there is provided a writing beautifying method, the method comprising: collecting information of a plurality of writing track points, wherein the information of the writing track points comprises coordinates, pressure and time of the writing track points; estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and sequentially carrying out track smoothing on the writing track points by utilizing an improved third-order Bessel algorithm to obtain information of a plurality of interpolation track points, wherein the control points used by the improved third-order Bessel algorithm comprise the current writing track points and the first three writing track points thereof, the plurality of interpolation track points obtained by the improved third-order Bessel algorithm are positioned between the first writing track point and the second writing track point which are positioned before the current writing track points, and the information of the interpolation track points comprises coordinates and the pen width of the interpolation track points; the plurality of interpolation track points are divided into a plurality of pen segments, and the outer contour of each pen segment is calculated by using the information of the pen brush model and the interpolation track points.
In order to solve the technical problems, another technical scheme adopted by the application is as follows: there is provided a writing beautifying device including: the device comprises an acquisition module, a smoothing module and an outer contour calculation module, wherein the acquisition module is used for acquiring information of a plurality of writing track points, and the information of the writing track points comprises coordinates, pressure and time of the writing track points; the smoothing module is used for estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and sequentially utilizing an improved third-order Bezier algorithm to carry out track smoothing on the writing track points to obtain information of a plurality of interpolation track points, wherein a control point used by the improved third-order Bezier algorithm comprises the current writing track points and the first three writing track points thereof, the plurality of interpolation track points obtained by the improved third-order Bezier algorithm are positioned between a first writing track point and a second writing track point which are positioned before the current writing track points, and the information of the interpolation track points comprises coordinates and the pen width of the interpolation track points; the outer contour calculation module is used for calculating the outer contour of each pen segment by using the information of the brush model and the interpolation track points, wherein the interpolation track points are divided into a plurality of pen segments.
In order to solve the technical problems, another technical scheme adopted by the application is as follows: there is provided a writing beautifying device comprising a processor and a memory for storing program data, the processor being for executing the program data to implement the method described above.
In order to solve the technical problems, another technical scheme adopted by the application is as follows: there is provided a computer readable storage medium for storing program data that can be executed to implement the above-described method.
In the scheme, the information of a plurality of writing track points is acquired through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized for carrying out track smoothing on the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are between the first writing track point and the second writing track point which are in front of the current writing track points, and the outer contour of each pen section is calculated by utilizing the information of a pen brush model and the interpolation track points respectively.
Drawings
FIG. 1 is a schematic flow chart of one embodiment of a method of writing beautification of the present application;
FIG. 2 is a schematic flow chart of another embodiment of the writing beautification method of the present application;
FIG. 3 is a schematic diagram showing the comparative effect of track smoothing using the three-order Bessel algorithm before and after modification;
FIG. 4 is a flowchart illustrating another embodiment of step S230 of the present application;
FIG. 5 is a flow chart illustrating another embodiment of step S240 of the present application;
FIG. 6 is a schematic diagram of a solution to a convex hull of two adjacent track point brushes in the present application;
FIG. 7 is a schematic diagram of a result of solving a convex hull of a pen segment in the present application;
FIG. 8 is a flowchart illustrating step S543 of the present application according to another embodiment;
FIG. 9 is a schematic illustration of bump defects during a writing beautification process;
FIG. 10 is a schematic illustration of the outer contour of a pen section of the present application;
FIG. 11 is a flow chart of yet another embodiment of the writing beautification method of the present application;
FIG. 12 is a flow chart illustrating another embodiment of step S1150 of the present application;
FIG. 13 is a schematic diagram of the validation of the encoding results in the present application;
FIG. 14 is a schematic diagram showing the comparison of coding effects in the present application;
FIG. 15 is a flow chart of yet another embodiment of the writing beautification method of the present application;
FIG. 16 is a beautification result in one embodiment of the writing beautification method of the present application;
FIG. 17 is a schematic view of a frame of an embodiment of the writing beautifying device of the present application;
FIG. 18 is a schematic diagram of a frame of an embodiment of a writing beautifying device of the present application;
FIG. 19 is a schematic diagram of a framework of an embodiment of the computer readable storage medium of the present application.
Detailed Description
In order to make the objects, technical solutions and effects of the present application clearer and more specific, the present application will be further described in detail below with reference to the accompanying drawings and examples.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship. Further, "a plurality" herein means two or more than two.
It is to be understood that the method of the present application may include any one of the following method embodiments as well as any non-conflicting combination of the following method embodiments.
It is to be understood that the present writing and beautifying method may be performed by a writing and beautifying device, which may be any device having execution capabilities, such as a cell phone, tablet, computer, etc.
Referring to fig. 1, fig. 1 is a schematic flow chart of an embodiment of a writing beautifying method of the present application, the method includes:
step S110: information of a plurality of writing track points is collected.
It should be noted that the writing and beautifying device in the present application may have an electronic screen, which may also be referred to as a touch screen, where the touch screen is used for a user to write on, and may also be used for displaying a beautifying result of a writing track on the touch screen for the user to view. In some embodiments, the writing beautifying device may not have a touch screen, but may be connected to other devices having touch screens, acquire information acquired by using the touch screen, and send the beautifying result to the device for display after beautifying is completed.
The device can acquire the writing track points of the user on the touch screen by utilizing the touch screen, specifically, during the writing of the user, the device acquires the information of the current writing points of the user on the touch screen as the information of the writing track points every preset time, so that the device can acquire the information of a plurality of writing track points.
The information of the writing track points comprises coordinates, pressure and time of the writing track points. The process of writing and beautifying the writing track point can be roughly divided into two parts of smoothing the writing track point and rendering the effect on the writing track point.
Step S120: and estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and sequentially smoothing the track of the writing track points by using an improved third-order Bessel algorithm to obtain information of a plurality of interpolation track points.
It will be appreciated that the user may write on the touch screen with different strokes at different locations, and in general, the thinner the stroke at the faster the writing speed, i.e., the smaller the stroke width, the wider the stroke at the greater the pressure, i.e., the greater the stroke width. The writing speed at the writing point can be determined according to the abscissa and the ordinate at the writing point and the time, and the pen width of the writing point can be determined by combining the pressure at the writing point.
The improved third-order Bezier algorithm is used for smoothing writing track points, and specifically, the device can obtain a smooth curve by utilizing the improved third-order Bezier algorithm, then interpolation quantity is selected according to a certain interpolation density, and corresponding interpolation track points on the curve are obtained through calculation, wherein the interpolation track points are smoother than the original writing track points, so that the track smoothing of the writing track points is realized. The method can be realized through a third-order Bessel algorithm, and a smooth curve between a first control point and a fourth control point is obtained through coordinate calculation of four control points, wherein the smooth curve passes through the first control point and the fourth control point but does not pass through the second control point and the third control point. The improved third-order Bezier curve can be realized, a smooth curve between the second control point and the third control point can be calculated by utilizing the coordinates of the four control points, the smooth curve possibly passes through the second control point and the third control point, a plurality of points are selected from the curve to be used as interpolation track points by adopting certain interpolation density, and handwriting formed by connecting the interpolation track points is smoother than the original writing track points. The interpolation density can be determined by the user according to the actual requirement, and is not limited herein.
It should be noted that, the above process of collecting the information of the writing track points is performed gradually from the beginning of writing by the user, and the smoothing of the writing track points is performed together with the collection of the writing track points, that is, the smoothing of the writing track points is performed in real time. Specifically, when the currently acquired writing track point is the second writing track point, the first writing track point is used as the first three control points of the improved third-order Bessel algorithm, and the current writing track point is used as the fourth control point; when the currently acquired writing track point is a third writing track point, taking the first writing track point as the first two control points of the improved third-order Bessel algorithm, taking the second writing track point as the third control point, and taking the current writing track point as the fourth control point; when the currently acquired writing track point is the fourth writing track point and the writing track points after the fourth writing track point, the current writing track point and the first three writing track points before the current writing track point are respectively used as four control points according to the acquisition sequence, and the rule of selecting the control points can be expressed by the following formula.
Wherein P is i Indicating that the currently collected writing track point is the ith writing track point, i is more than or equal to 0 and Q is equal to 0 -Q 3 The four control points of the improved third-order Bezier curve algorithm are sequentially arranged.
When the last writing track point is obtained, the area where interpolation is not performed at this time includes between the last interpolation ending point and the last track point, the last interpolation ending point is located between the third last writing track point and the fourth last writing track point, and since the next writing track point is no longer present, interpolation is performed by adopting a third-order Bessel & b spline method, and a control point of the third-order Bessel algorithm is selected by the b spline method, for example, a midpoint between the last interpolation ending point, the third last writing track point and the second last writing track point, a midpoint between the second last writing track point and the first last writing track point, and the last writing track point are used as four control points of the third-order Bessel algorithm, so that interpolation of the whole handwriting is completed.
If the original third-order Bezier curve algorithm is adopted for interpolation, after a fourth writing track point is obtained, the four writing track points are used as control points, and interpolation is carried out on the four writing track points. For example, the currently acquired writing track point is P i When the writing track point currently processed is P i Realizing P-pair by using third-order Bezier curve algorithm i -P i-3 Interpolation is carried out between the two, and then P is obtained one by one i+1 、P i+2 No interpolation is performed at this time, but only if P is acquired i+3 Will be P to i -P i+3 Interpolation is performed, that is, the progress of smoothing the writing track points has a delay of 2-3 points compared with the progress of acquiring the writing track points.
When adopting the improved third-order Bezier curve algorithmWhen interpolation is carried out, after a new writing track point is obtained, namely the writing track point which is currently processed, the writing track point which is currently processed and three writing track points before the writing track point are used as control points, and interpolation is carried out between the first writing track point and the second writing track point which are before the writing track point which is currently processed. For example, the currently acquired writing track point is P i When the writing track point currently processed is P i Then pair P using the modified third-order Bezier curve algorithm i-1 -P i-2 Interpolation is performed between them, and then P is obtained i+1 And processing it, P i-1 -P i From this, it can be seen that, when interpolation is performed by using the improved third-order bezier curve algorithm, the progress of smoothing the writing track points has only 1 point delay compared with the progress of obtaining the writing track points. The improved third-order Bezier curve algorithm can reduce the delay of smoothing the writing track points, namely, the delay of beautifying the writing track points.
Along with the collection of writing track points, each time a new writing track point is collected, the control points are reselected according to the rule, and the improved third-order Bessel algorithm is utilized to conduct interpolation between the second control point and the third control point once, so that the coordinates and the pressure of the interpolation track points are determined, and finally, the interpolation of all the writing track points is completed, and a smoothed result is obtained. Since the improved third-order bezier curve obtained by using the writing track point as the control point of the improved third-order bezier algorithm does not necessarily pass through the writing track point, the smoothed result only includes the interpolation track point and the information thereof, but does not include the writing track point and the information thereof.
The beautifying of the writing track can be divided into brush map rendering and contour rendering, and in this embodiment, the contour rendering is taken as an example for explanation, it is understood that in some embodiments, the beautifying can also be performed by adopting the brush map rendering.
Step S130: and calculating the outer contour of each pen segment by using the information of the pen brush model and the interpolation track points.
It should be noted that, step S130 is a step in the process of performing effect rendering on the writing track points, and in the present application, the effect rendering is performed on the writing track points in a real-time processing manner, that is, after each pair of track points completes operations such as track smoothing, etc., the effect rendering is performed. That is, when the user writes, each time a writing track point is obtained, the writing track point is smoothed, and after the smoothing operation is completed, effect rendering is performed.
The brush model can be pre-stored in the writing beautifying device, after a plurality of interpolation track points are obtained, the interpolation track points can be divided into a plurality of pen sections, each pen section is processed respectively, and the outer contour of each pen section is obtained, so that the outer contour of the whole writing track is also obtained, and beautifying results can be obtained according to the outer contour.
In the scheme, the information of a plurality of writing track points is acquired through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized for carrying out track smoothing on the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are between the first writing track point and the second writing track point which are in front of the current writing track points, and the outer contour of each pen section is calculated by utilizing the information of a pen brush model and the interpolation track points respectively.
Referring to fig. 2, fig. 2 is a schematic flow chart of another embodiment of the writing beautifying method of the present application, the method includes:
step S210: information of a plurality of writing track points is collected.
The related description of step S210 may refer to the related content described above with respect to step S110.
As any device with processing capability can be used as the writing beautifying device in the application, but the screen size, screen resolution and other device parameters of the electronic screens of different devices are different, for example, if the electronic screens of two devices are identical in size but different in resolution, a user writes a writing with identical size and shape on the same screen, the two devices respectively collect coordinates of writing track points in units of pixels, for the two identical writing, the difference of the coordinates of writing track points collected by the two devices can be quite large due to the different resolutions of the two devices, and even if the same beautifying algorithm is adopted, the beautifying results obtained on the two devices can be different. If the same beautifying result is to be obtained for the same handwriting on both devices, then the beautifying algorithm adopted by one of the devices needs to be adjusted. The algorithm needs to be adjusted for the devices with different device parameters so that the beautifying result of the consistent handwriting is the same, and the method is complex.
In addition to the above manner, a simpler manner is provided in the present application, which can make different devices have the same beautifying result on consistent handwriting, that is, the writing track point coordinates in pixels are converted into physical length before performing beautifying calculation.
In some embodiments, the apparatus may further perform coordinate conversion on the writing trace point after performing step S210. Specifically, before executing step S210, the device may further collect device parameters, where the device parameters include hardware parameters related to a screen size, a screen resolution, and the like of the touch screen, calculate an actual physical distance and a pixel distance of an oblique angle of the electronic screen, determine a scaling factor for converting a value in units of pixels into a value in units of a physical length (for example, millimeters, and after executing step S210, the device may convert coordinates of a writing track point using the scaling factor, and convert coordinates of the writing track point in units of pixels into coordinates of the writing track point in units of a physical length.
By the method, all the equipment acquire the same coordinates of the writing track points based on the same handwriting, so that the same beautifying algorithm can be utilized to obtain a consistent beautifying result.
In some embodiments, after performing step S120, the device may also filter the writing trace points. Specifically, before executing step S210, the device may further collect device parameters, where the device parameters include hardware parameters related to DPI (Dots Per Inch, number of Pixels in an image Per Inch) and PPI (Pixels Per Inch, number of Pixels in a diagonal line), and the device may calculate, according to the device parameters, the number of Pixels corresponding to each point on the screen, so as to dynamically adapt parameters such as interpolation density and minimum pitch, and then after executing step S120, the device may screen the writing track point using the minimum pitch, and after the screening, false touches caused by jitter and the like may be removed, so that the writing track point may be smoothed to a certain extent.
In some embodiments, the information of the writing track point further includes a track point state, where the track point state may be divided into a pressing point, a moving point and an exiting point, and the track point state may enable the device to determine the current writing state of the user, and may facilitate dividing different strokes, so as to process the writing track point subsequently.
Step S220: and estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and sequentially smoothing the track of the writing track points by using an improved third-order Bessel algorithm to obtain information of a plurality of interpolation track points.
The related description of step S220 may refer to the related content described previously with respect to step S120.
Specifically, the pen width estimation is performed for the writing track point to obtain the pen width corresponding to the writing track point, and the pen width of the writing track point can be calculated by adopting the following width calculation formula:
wherein W is the pen width of the writing point, W max For the preset maximum pen width, v is the writing speed of the writing track point, v base For the preset writing reference speed, p is the pressure of the writing track point, and a, c and d are preset parameters. It can be understood that the device can pre-store a preset maximum value of the pen width and a preset reference writing speed, and the proportional relation between the pen width of the writing trace point and the preset maximum value of the pen width can be correspondingly determined by setting the preset pen width and the preset reference writing speed as the standard and comparing the writing speed of the writing trace point with the preset reference writing speed, so that the pen width of the writing trace point is determined.
The formula of the third-order Bessel algorithm is:
the application provides an improved third-order Bessel algorithm, and the improved third-order Bessel algorithm is sequentially utilized to carry out track smoothing on writing track points, in particular to interpolate the writing track points by utilizing the interpolation density, so that a plurality of interpolation track points are obtained, wherein the formula of the improved third-order Bessel algorithm is as follows:
wherein Q is 0 -Q 3 The four control points of the improved third-order Bezier curve algorithm are sequentially adopted, and the initial i is not considered in the interpolation process<2, when i>2, Q 0 For the third writing track point before the currently processed writing track point, Q 1 For the second writing track point before the writing track point currently processed, Q 2 For the first writing track point before the writing track point currently processed, Q 3 T is the interpolation quantity of the Bezier curve for the currently processed writing track point。
It will be appreciated that if the abscissa of the writing trace point is brought into the modified third-order Bessel algorithm, the abscissa of the interpolation trace point is obtained, and if the pen width of the writing trace point is brought into the modified third-order Bessel algorithm, the pen width of the interpolation trace point is obtained.
Interpolation is carried out by utilizing the improved third-order Bessel algorithm, wherein the interpolation starting point interpolation quantity t=0 each time, the interpolation ending point interpolation quantity t=1 each time, and the interpolation starting pointInterpolation end point->From this, it can be seen that the interpolation interval is at [ Q ] 1 ,Q 2 ]Floating in between, i.e. using Q 0 -Q 3 As a control point, the obtained interpolation point is shown as Q 1 And Q 2 Floating in between. Assume that the currently processed writing track point is P i Then the starting point of the current interpolation isThe end point of the current interpolation is +.>And at a point P i-1 The corresponding interpolation end point is +.>And P i The corresponding interpolation starting points are the same, that is, the position at which the last interpolation ends and the position at which the next interpolation starts are the same, whereby continuity of interpolation can be ensured. Compared with the interpolation by adopting the third-order Bezier algorithm, the last interpolation and the next interpolation have the same control point, and the improved third-order Bezier algorithm provided by the application is adopted, and the control points used by the last interpolation and the next interpolation are only different by one, so that the interpolation track points obtained by interpolation can be ensured to be flatterAnd (5) sliding.
Referring to fig. 3 in combination, fig. 3 is a schematic diagram showing the comparative effect of track smoothing by using the three-order bezier algorithm before and after improvement.
Wherein, fig. 3a is a handwriting obtained by performing trajectory smoothing on the handwriting of the user by using a third-order bessel algorithm (formula 3), and fig. 3b is a handwriting obtained by performing trajectory smoothing on the same handwriting by using an improved third-order bessel algorithm (formula 4), so that it can be seen by comparing that the trajectory smoothing is performed by using the improved third-order bessel algorithm, and the smoothness of the handwriting can be effectively improved.
Step S230: and performing brush modeling to obtain a brush model.
Referring to fig. 2 and fig. 4 in combination, fig. 4 is a flowchart illustrating another embodiment of step S230 of the present application, and step S230 includes:
step S431: and acquiring a brush track point sequence.
In this embodiment, brush modeling is described as an example of one brush.
The device may first determine an original brush track point sequence of the brush in response to a user operation, and then normalize the original brush track point sequence to obtain a brush track point sequence.
In particular, the device may include the original sequence of brush trace points that was composed by capturing text entered by the user or capturing one or more segments of a seal that the user rendered on the electronic screen. The original brush track point sequences can be connected to form a closed graph.
The normalization of the original brush track point sequence may include calculating a coordinate extremum, a coordinate interval and a center point coordinate of the original brush track point sequence, and scaling the coordinates of the original brush track point sequence in equal proportion so that the scaled coordinates are in a preset interval, thereby obtaining a brush track point sequence, that is, the coordinates of the brush track point sequence are all in the preset interval, which may be [ -100, 100] for example. Through the above-mentioned regulation step, no matter the size of the brush formed by original brush track point sequence, the brush formed by brush track point sequence can be obtained, the brush whose size is in the preset range can be continuously described by taking the above-mentioned preset interval as [ -100, 100] as an example, and finally the brush formed by brush track point sequence is within 200mm, so that the brush size can be uniform, and the brush model can be conveniently called.
Step S432: and performing Bezier curve fitting on the brush track point sequence.
It should be noted that, based on efficiency and accuracy, the bezier fitting herein may be a third-order bezier fitting, and of course, in some embodiments, other ways of bezier fitting may be selected.
And performing Bezier curve fitting on the brush track point sequence, and if the distance between one brush track point and the Bezier curve obtained by fitting exceeds a preset threshold value, determining the brush track point as an inflection point, wherein the distance between the brush track point and the Bezier curve is the minimum distance between the brush track point and the Bezier curve.
Step S433: and judging whether an inflection point exists.
If there is an inflection point, step S434 is performed, and if there is no inflection point, step S435 is performed.
Step S434: and taking the inflection point as a segmentation point, segmenting the brush track point sequence and performing Bezier curve fitting again.
If the inflection point still exists in the process of fitting the bezier curve again, the inflection point is taken as a segmentation point again, and the sequence of the brush track points is segmented again and the bezier curve is fitted again until the inflection point does not exist, so that the sequence of the brush track points can be converted into a plurality of sections of bezier curves.
Step S435: and storing the control points obtained by fitting into all the Bezier curves as a control point sequence of the brush, and sampling contour points of the Bezier curves to obtain a brush model.
The step of sampling the contour points of the Bezier curve specifically comprises the steps of determining a certain interpolation density according to the length of each section of the Bezier curve of the brush, and selecting the contour points from the Bezier curve by utilizing the interpolation density so as to obtain a brush contour point sequence. And then storing the Bezier curve id, the contour points and the corresponding interpolation amounts t as a brush model, so that the brush model can be called later, wherein for convenience in distinguishing, the device can allocate a unique corresponding number for each Bezier curve, namely the Bezier curve id, and the plurality of Bezier curves in the brush model can be stored in the device, and the Bezier curves can be searched and determined by the Bezier curve id.
The device may obtain a plurality of brush models by repeatedly performing step S431-step S435, and select a call from the plurality of brush models in one writing beautification process.
Step S240: and calculating the outer contour of each pen segment by using the information of the pen brush model and the interpolation track points. The description of step S240 may refer to the foregoing related content of step S130, which is not described herein.
In some embodiments, since the equidistant sampling cannot be achieved by the bezier curve interpolation sampling, that is, the distances between the writing track points are not uniform, and the pen width of each interpolation track point is different, it may happen that one track point pen brush is included in another track point pen brush, specifically, taking a pen brush as a circle as an example, the pen width of the track point a is 10mm, the pen width of the track point B is 2mm, the distance between the track point a and the track point B is 2mm, the track point pen brush corresponding to the track point B is completely included by the track point pen brush corresponding to the track point a, the included track point has no meaning of calculating the outline of the track point pen, and the included track point can be deleted directly. So before step S441, step S240 further includes: and screening the interpolation track points according to the inclusion relation.
Referring to fig. 2 and fig. 5 in combination, fig. 5 is a flowchart illustrating another embodiment of step S240 of the present application, and step S240 includes:
step S541: and carrying out affine transformation on the brush model by using the coordinate of each interpolation track point as the center and utilizing the pen width of the interpolation track point to obtain the track point brush on each interpolation track point.
The brush model includes a sequence of brush control points and a sequence of brush contour points, and the affine transformation in step S541 may specifically include performing proportional calculation and coordinate translation on the point coordinates of the sequence of brush control points and the sequence of brush contour points by using the width of the interpolated track points to obtain a track point brush on each interpolated track point, where the center of the track point brush is the center of the interpolated track point, and the width of the track point brush is equal to the width of the interpolated track point.
Step S542: and (3) for each pen section, carrying out convex hull complex solving on each two adjacent track point brushes to obtain two outer contour connection points for connecting each track point brush with the adjacent track point brushes.
In this embodiment, the portion between two writing track points where the track smoothing and effect rendering are performed once is referred to as a pen segment, and since the interpolation density is actually variable, the number of interpolation track points included in a pen segment is also uncertain due to the influence of the interpolation density.
It should be noted that, for a plurality of interpolation track points, a pen segment is taken as an example in this embodiment, specifically, each time a new writing track point is acquired, four control points are reselected, and once interpolation is performed between the second control point and the third control point, then once interpolation corresponds to a pen segment, and the interpolation track point obtained by this time interpolation corresponds to the interpolation track point included in the pen segment.
To facilitate the bezier curve fitting operation in the subsequent encoding process, the number of interpolation track points included in one pen segment and the selected bezier curve may be corresponding, for example, the three-order bezier curve is used for fitting, the interpolation track points of one pen segment may be four or a multiple of four, and if the four-order bezier curve is used for fitting, the interpolation track points of one pen segment may be five or a multiple of five. Considering the accuracy and efficiency of fitting, in the embodiment of the present application, four interpolation track points of one pen segment are used, and then three-order bezier curves are used for performing fitting to describe the fitting. If the encoding process is not performed subsequently, the number of interpolation track points can be changed by changing the interpolation density, and the number can be arbitrarily selected.
Each pen segment is processed separately, and a case of processing one pen segment will be described below.
Referring to fig. 6, fig. 6 is a schematic diagram of a solution for convex hull of two adjacent track point brushes in the present application.
A schematic diagram of a solution of a convex hull of two adjacent trajectory-point brush corresponding to four different brush models is given in fig. 6.
Firstly, taking two adjacent track point brushes as an example to describe convex envelope solving, wherein for the two adjacent track point brushes, the convex envelope solving result is a part of continuous contour points on one side of the former track point brush far from the latter track point brush, a part of continuous contour points on one side of the latter track point brush far from the former track point brush, and two connecting line segments for connecting the two parts of contour points. For a track point brush, the starting point and the end point of the continuous outline point are the outer outline connecting points, that is to say, the track point brush comprises two outer outline connecting points, and the track point brush can be divided into an upper outer outline connecting point and a lower outer outline connecting point according to the relative positions of the two outer outline connecting points in the track point brush. The connection point of the upper outer contour of the previous track point brush is connected with the connection point of the upper outer contour of the next brush to form a connection line segment in the result of convex hull solving. Similarly, the connection point of the lower outer contour of the previous track point brush is connected with the connection point of the lower outer contour of the next brush to form another connection line segment in the result of convex hull complex solving.
Taking fig. 6 as an example for illustration, the light-colored partial contour points in the track point brushes are part of continuous contour points in the result of the convex hull solving, and the line segments in the middle of the two track point brushes in the figure are connecting line segments in the result of the convex hull solving. The first/last contour points in the light-colored partial contour points are outer contour connecting points and are end points of connecting line segments in the drawing. Taking the previous track point brush in fig. 6a as an example, a is an upper outer contour connection point, and B is a lower outer contour connection point.
Then, for a pen segment, a plurality of track point brushes are included, the track point brushes can be divided into three types of a head track point brush, a middle track point brush and a tail track point brush, for the head track point brush and the tail track point brush, only one convex hull solving is needed, and for the middle track point brush, two convex hull solving is needed, so that the outer contour connecting points obtained by the two convex hull solving can be different, and then the outer contour connecting points obtained by the convex hull solving of the middle track point brush and the previous track point brush are used.
Referring to fig. 7, fig. 7 is a schematic diagram of a result of solving convex hull of a pen segment in the present application, and it can be seen that fig. 7 provides a schematic diagram of a result of solving convex hull and a trace point pen brush obtained by performing affine transformation on the same pen segment by using four different pen brush models.
Taking fig. 7a as an example, the pen segment includes four interpolation handwriting points, performing convex hull solving on every two adjacent track point brushes, performing convex hull solving only once on the first track point brush and the fourth track point brush, performing convex hull solving on the second track point brush and the first track point brush and the third track point brush respectively, taking the outer contour connecting point obtained by performing convex hull solving on the first track point brush and the third track point brush as reference, and taking the outer contour connecting point obtained by performing convex hull solving on the third track point brush and the second track point brush as reference.
In the four pen segments in fig. 7, the light contour points in the first and last two track point brushes of one pen segment are part of continuous contour points in the result of convex hull complex solving, the first and last of the light contour points are outer contour connection points, and the light contour points in the middle two track point brushes are outer contour connection points. Taking fig. 7a as an example for illustration, A, B, C and D are upper outer contour connection points in four track point brushes, E, F, G and H are lower outer contour connection points in four track point brushes, respectively, and the same principle as other brush models is adopted.
Step S543: and updating the track point brush by using the outer contour connection point.
Referring to fig. 2, fig. 5, and fig. 8 in combination, fig. 8 is a flowchart illustrating another embodiment of step S543 of the present application, where step S543 includes:
step S8431: and determining a first Bezier curve where the outer contour connecting point is located and a corresponding interpolation value.
In the step S8431 to the step S8434, one outer contour connection point is taken as an example, and the same process may be performed for all outer contour connection points. In the brush model, contour points of the brush can correspond to a plurality of Bezier curves, the track point brush is obtained by affine transformation by using the brush model, and then the contour points of the track point brush can also be divided into the corresponding plurality of Bezier curves, and a first Bezier curve where an outer contour connecting point is positioned on the track point brush and an interpolation value t corresponding to the outer contour connecting point are determined.
Step S8432: if the outer contour connection point is not the starting point or the ending point of the first Bezier curve, the first Bezier curve is divided into a second Bezier curve and a third Bezier curve by taking the outer contour connection point as a division point.
If the outer contour connection point is not the starting point or the ending point of the first bezier curve, that is, the interpolation t corresponding to the outer contour connection point is not 0 or 1, the outer contour connection point is taken as a dividing point on the first bezier curve, the first bezier curve is divided into two parts, that is, the second bezier curve and the third bezier curve, and then the contour point on the first bezier curve is divided into two parts, that is, the second bezier curve and the third bezier curve are respectively corresponding to the first bezier curve and the second bezier curve.
If the outer contour connection point is the start point or the end point of the first bezier curve, step S8433 and step S8434 are not performed.
Step S8433: and re-fitting the second Bezier curve and the third Bezier curve to obtain new control point and contour point information.
And respectively carrying out Bezier curve fitting and resampling on the two parts of contour points obtained after the segmentation to obtain control point and contour point information of the second Bezier curve and the third Bezier curve.
Step S8434: and replacing the control point and contour point information of the first Bezier curve in the track point brush with new control point and contour point information.
Specifically, the control point and contour point information corresponding to the second bezier curve and the third bezier curve are stored sequentially, and if two outer contour connection points of one track point brush are all used as the division points, the track point brush is changed from the original corresponding n bezier curves to the corresponding n+2 bezier curves.
If the encoding process is performed subsequently and only the encoding result is output, in step S834, only the new control point information may be stored instead of the control point information of the original first bezier curve, the contour point may not be updated, and only the updated control point information may be output as the outer contour subsequently. If the encoding process is not performed subsequently and the outer contour is output in the form of contour points, in step S834, only new contour point information may be saved instead of the contour point information of the original first bezier curve.
Referring to fig. 9 in combination, fig. 9 is a schematic diagram of a bump defect during a writing beautification process.
It should be noted that in the existing writing and beautifying process, the brush is composed of a plurality of bezier curves, the contour points between the two curves are brush dividing points, and due to the convex curve of the shape of the brush, the most protruding points of the convex curve in different directions are different, and in some cases, the most protruding points may not be the brush dividing points, that is, the brush dividing points are at the inner sides of the most protruding points. When the outer contour of the pen segment is obtained by carrying out convex hull complex solving on the track point pen brush only by using the pen brush dividing points, the problem that convex point defects occur among the connected pen segments in a specific direction can be caused by the fact that the most convex point is not considered to be positioned at the most edge of the outer contour when the outer contour is obtained, and the problem that the most convex point of the track point pen brush cannot be covered by the obtained outer contour is caused by the fact that the pen brush dividing points are mistakenly positioned at the most edge of the outer contour to obtain the outer contour, namely convex point defects exist in the final beautifying result.
As can be seen from the above step S542, the outer contour connection point is obtained by performing convex hull solution according to every two adjacent track point brushes, so that it can be understood that the outer contour connection point is the most salient point that may generate salient point defects, and when the outer contour connection point is not a brush dividing point, the salient point defects may occur, and then the track point brushes are divided according to the outer contour connection point, so that the most salient point becomes a brush dividing point, thereby avoiding salient point defects caused by the most salient point that is not the dividing point.
It should be noted that, step S543 is an optional step, and if step S543 is not performed, the determination of the outer contour of the pen segment is not affected.
Step S544: and respectively performing Bezier curve fitting on two outer contour connecting points of all interpolation track points in the pen section to obtain an upper section outer contour and a lower end outer contour of the pen section, and combining the first section outer contour and the tail section outer contour of the pen section to form the outer contour of the pen section.
Referring to fig. 10, fig. 10 is a schematic diagram of an outer contour of a pen segment in the present application, for one pen segment, when the outer contour of the pen segment is obtained, the outer contour of the pen segment may be divided into four parts according to a positional relationship of the contour, which are a first outer contour, a tail outer contour, an upper outer contour and a lower outer contour. The outer contour of the upper section is the outer contour in the direction of the connecting point of the upper outer contour, the outer contour of the lower section is the outer contour in the direction of the connecting point of the lower outer contour, the outer contour of the first section is the part of the first track point brush of the pen section which is not enveloped by the outer contour of the upper section and the outer contour of the lower section, and the outer contour of the tail section is the part of the last track point brush of the pen section which is not enveloped by the outer contour of the upper section and the outer contour of the lower section. Specifically, the outer contour of the first section is a part of continuous contour points between two outer contour connecting points of a first track point of the pen section, which are far away from one side of a brush of a next track point, and the continuous contour points are actually consistent with a part of continuous contour points obtained when the convex hull solution is carried out on the first track point brush, the outer contour of the tail section is a part of continuous contour points between two outer contour connecting points on the last track point brush, which are far away from one side of the brush of the previous track point, and the continuous contour points are actually consistent with a part of continuous contour points obtained when the convex hull solution is carried out on the last track point brush.
Two outer contour connecting points are finally obtained for each track point brush, and the two outer contour connecting points can be divided into an upper outer contour connecting point and a lower outer contour connecting point according to the position relation of the outer contour connecting points. The upper section outline and the lower end outline of the pen section are obtained through all upper outline connecting points and lower outline connecting points in the pen section respectively. Specifically, performing Bezier curve fitting on the upper outer contour connecting points to obtain a Bezier curve of the upper outer contour, and performing Bezier curve fitting on the lower outer contour connecting points to obtain a Bezier curve of the lower outer contour. The obtained Bezier curve can be resampled, the obtained contour points are used as the outer contours to be output, and only the control points of the Bezier curve can be output so as to facilitate subsequent encoding processing and output. It should be noted that, since the number of the track point brushes in one pen segment is not determined, the fitting may be performed on all the upper/lower outer contour connection points at a time, or may be performed by dividing all the upper/lower outer contour connection points into several parts, or may be performed by selecting a part from all the upper/lower outer contour connection points included in the pen segment. For example, if one pen segment includes 8 track point brushes, the upper/lower outer contour connection points can be divided into two parts, the first 4 and the last 4 can be respectively subjected to third-order Bessel fitting, or the 1 st, 3 rd, 5 th and 7 th can be selected for fitting. And interpolating the obtained Bezier curve to obtain contour points of the upper section outer contour/the lower section outer contour.
The outer contour of the pen section is obtained by combining the outer contour of the head section, the outer contour of the tail section, the outer contour of the upper section and the outer contour of the lower end of the pen section.
Taking fig. 10a as an example for illustration, the outer contour connection points of the track point brushes in fig. 10 may be labeled with reference to fig. 7, where the light contour point in the first track point brush is the first outer contour, the light contour point in the last track point brush is the last outer contour, the curves passing through the upper outer contour connection points of the four track point brushes are bezier curves of the upper outer contour, and the curves passing through the lower outer contour connection points of the four track point brushes are bezier curves of the lower outer contour. Comparing fig. 7 and fig. 10 shows that the outer contour obtained by bezier curve fitting is smoother and more natural.
After the outline of each pen section is obtained, the outline of the whole handwriting is also obtained, so that the beautifying effect on the handwriting can be adjusted according to the outline, and the beautifying result is obtained.
In the above scheme, the information of a plurality of writing track points is collected through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized to carry out track smoothing for the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current processing writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are between the first writing track points and the second writing track points which are in front of the current processing writing track points, the information of a pen brush model and the interpolation track points is utilized to calculate the outer contour of each pen section, and by the mode, each time when one writing track point is obtained, the control points of the improved three-order Bezier algorithm are updated, the control points of the first writing track points and the second writing track points are smoothed, the delay of the electronic screen writing smoothing can be reduced, the delay of the electronic screen writing is also reduced, and only one difference between the control points of the two interpolation track points is found, and the outer contour is further utilized to obtain the outer contour of each pen section, and the outer contour is prevented from being cut off by the outer contour points when the outer contour is obtained.
Referring to fig. 11, fig. 11 is a schematic flow chart of a further embodiment of the writing beautifying method of the present application, the method includes:
step S1110: information of a plurality of writing track points is collected.
Step S1120: and estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and sequentially smoothing the track of the writing track points by using an improved third-order Bessel algorithm to obtain information of a plurality of interpolation track points.
Step S1130: and performing brush modeling to obtain a brush model.
Step S1140: and calculating the outer contour of each pen segment by using the information of the pen brush model and the interpolation track points.
The descriptions of steps S1110 to S1140 may refer to the descriptions of steps S210 to S240, and are not described herein.
After the user writes, the device can take the strokes as objects to carry out outline data vectorization storage so as to facilitate the user to carry out operations such as translation, scaling, withdrawal, deletion and the like on the writing handwriting. In order to reduce the data memory occupation as much as possible, the writing track outline is encoded after the writing track outline is obtained. In this embodiment, the outline encoding of one pen segment is described as an example, so that the encoding result of the writing trace can be obtained.
Step S1150: the outer contour of the pen segment is encoded.
It should be noted that, encoding the outer contour of the pen segment can reduce storage without changing the beautifying effect. And because of affine invariance of Bessel codes, operations such as translation, scaling and the like of beautification results can be effectively realized.
Referring to fig. 11 and fig. 12 in combination, fig. 12 is a flowchart illustrating another embodiment of step S1150, and step S1150 includes:
step S1251: and determining a corresponding contour Bezier curve and an interpolation interval of the first section outer contour/the tail section outer contour in the track point brush.
The outer contour of the first section outer contour/the tail section outer contour comprises a plurality of contour points, the track point brush can be composed of a plurality of contour Bezier curves, and the corresponding contour Bezier curves and interpolation value intervals of the contour points in the track point brush to which the contour points belong are determined. Specifically, the track point brush to which the first-section outer contour belongs consists of 5 contour Bezier curves, and the [0,1] part of the first-section outer contour corresponding to the second contour Bezier curve and the [0, t ] part of the third-contour Bezier curve are determined.
Step S1252: if there is no contour Bezier curve with interpolation interval less than [0,1], directly using the control point sequence of existing contour Bezier curve.
Step S1253: if the contour Bezier curve with the interpolation value interval smaller than the [0,1] range exists, trisection interpolation calculation is carried out on the interpolation value interval to obtain a calculation result, bezier curve fitting is carried out on the calculation result again, and the control point sequence of the contour Bezier curve is updated.
Continuing the above description, the interpolation value interval of the first section of outer contour corresponding to the third contour Bezier curve is smaller than the [0,1] range, trisection interpolation calculation is carried out on the [0, t ] part of the third contour Bezier curve, so as to obtain a calculation result, four interpolation points are obtained, bezier curve fitting is carried out again by using the four interpolation points, and the control point sequence of the contour Bezier curve is updated.
It should be noted that, if the track point brush is already divided according to the outer contour connection point in step S1140, the interpolation interval is not smaller than the [0,1] range.
Step S1254: and taking the control point sequences of all the contour Bezier curves corresponding to the outer contours of the first section and the tail section as the coding results of the outer contours of the first section and the tail section.
Step S1255: and respectively performing Bezier curve fitting on two outer contour connection points of interpolation track points in the pen section to obtain control point sequences of the outer contours of the upper section and the lower section as corresponding coding results.
The coding result of the outer contour of the pen section can be obtained through the step S1254 and the step S1255, the bezier curves corresponding to the outer contour of the first section, the outer contour of the tail section, the outer contour of the upper section and the outer contour of the lower section can be obtained rapidly by utilizing the coding result, namely the control point sequence of the bezier curves, and compared with the outer contour before coding comprising a plurality of contour points, the data memory occupation is reduced.
It should be noted that, if in step S1140, bezier curve fitting has been performed on two outer contour connection points of all interpolation track points in the pen segment, so as to obtain a fitted curve of the outer contour of the upper segment and the outer contour of the lower segment, then in step S1255, fitting is not required again, and the control point sequence of the fitting result in step S1140 is directly adopted as the corresponding encoding result.
In some embodiments, if the outer contour connection points in the pen segment are missing due to the screening of the interpolation track points, the number of the outer contour connection points does not meet the number required by the Bezier curve fitting, and at this time, the number of the outer contour connection points can be complemented by adopting a mode of solving the center point of the two outer contour connection points, and then the Bezier curve fitting is performed.
It should be noted that, in step S1255, the control point sequence of the bezier curve corresponding to the upper/lower outer contours obtained in step S1140 may be directly obtained.
Step S1256: and verifying the coding result.
Referring to fig. 11, 12 and 13 in combination, fig. 13 is a schematic diagram illustrating verification of the encoding result in the present application. In the process of coding the upper section outer contour/the lower section outer contour, in a curve fitting algorithm, the linear distance between every two track points is adopted to estimate the curve distance between the two points, so that under the conditions of quicker writing and large trend change, the curve distance between the two points and the linear distance difference between the two points are large, fitting failure is caused, and then the coding effect is inconsistent with the original effect. In general, the radian of the upper section outer contour/the lower section outer contour only has one trend, and the fitting failure is mainly reflected in that the trend of the upper section outer contour/the lower section outer contour does not correspond to the integral writing trend, and whether the fitting failure is determined by calculating whether the number of the radian of the fitted curve is 1 or not.
Specifically, it is determined whether the number of radians of the bezier curve corresponding to the control point sequence of the upper section outer contour/the lower section outer contour is greater than one.
If the fitting fails, the fitting can be determined, and the verification of the coding result is not passed, if the control point sequence after Bezier curve fitting is not adopted as the coding result, the upper/lower outer contour connecting points are adopted as the control points of the upper outer contour/lower outer contour.
If not, then it may be determined that the encoding result verification is passed. Fig. 13a is a schematic diagram of fitting success, and fig. 13b is a schematic diagram of fitting failure.
In the scheme, the information of a plurality of writing track points is acquired through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized to carry out track smoothing for the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current processing writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are positioned between the first writing track points and the second writing track points which are positioned in front of the current processing writing track points, the outer contour of each pen section is calculated by utilizing the information of a pen brush model and the interpolation track points respectively, and by adopting the mode, each time when one writing track point is obtained, the control points of the improved three-order Bezier algorithm are updated, the control points of the improved three-order Bezier algorithm are utilized to carry out smoothing between the first writing track points and the second writing track points, the delay of the writing smoothing of the electronic screen can be reduced, the writing beautifying delay of the electronic screen can be reduced, the writing and the beautifying of the external contour can be carried out the beautifying processing, the external contour can be carried out on the writing and the external contour, the external contour can be effectively reduced under the condition that the data is not changed, the scaling effect is reduced, the scaling effect is convenient, and the memory is convenient to be achieved.
Referring to fig. 14, fig. 14 is a schematic diagram showing comparison of coding effects in the present application.
Fig. 14a is a schematic view of the outer contour of the pen segment before encoding, fig. 14b is a schematic view of the outer contour of the pen segment after encoding, and the outer contour of the pen segment is the basis for rendering and beautifying, so that it can be seen that the overall beautifying effect is not affected by encoding, and the overall beautifying effect is consistent before and after encoding.
Referring to fig. 15, fig. 15 is a schematic flow chart of a further embodiment of the writing beautifying method of the present application, the method includes:
step S1510: information of a plurality of writing track points is collected.
Step S1520: and carrying out coordinate conversion and screening on the writing track points.
Step S1530: and estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and sequentially carrying out track smoothing on the writing track points by using an improved third-order Bessel algorithm to obtain information of a plurality of interpolation track points.
Step S1540: and acquiring a brush track point sequence, and performing Bezier curve fitting on the brush track point sequence.
Step S1550: judging whether an inflection point exists, if so, dividing the brush track point sequence and fitting again with the Bezier curve by taking the inflection point as a dividing point, if not, storing control points of all the Bezier curves obtained by fitting as the control point sequence of the brush, and sampling contour points of all the Bezier curves to obtain a brush model.
Step S1560: and screening the interpolation track points according to the inclusion relation.
Step S1570: and carrying out affine transformation on the brush model by using the coordinate of each interpolation track point as the center and utilizing the pen width of the interpolation track point to obtain the track point brush on each interpolation track point.
Step S1580: and (3) carrying out convex hull complex solving on each pen section and every two adjacent track point pen brushes to obtain two outer contour connection points for connecting each track point pen brush with the adjacent track point pen brushes.
Step S1590: and updating the track point brush by using the outer contour connection point.
Step S15100: and respectively performing Bezier curve fitting on two outer contour connecting points of all interpolation track points in the pen section to obtain an upper section outer contour and a lower section outer contour of the pen section, and combining the first section outer contour and the tail section outer contour of the pen section to form the outer contour of the pen section.
Step S15110: and taking the control point sequences of all the contour Bezier curves corresponding to the outer contours of the first section and the tail section as the coding results of the outer contours of the first section and the tail section.
Step S15120: and taking the control point sequences of the upper section outline and the lower section outline as corresponding coding results.
Step S15130: judging whether the radian quantity of the corresponding Bezier curves is larger than one according to the control point sequence of the upper section outer contour/the lower section outer contour, and if so, taking the outer contour connecting points as the control points of the upper section outer contour/the lower section outer contour.
The descriptions of steps S1510 to S15130 may refer to the descriptions of the foregoing embodiments, and are not described herein.
Referring to fig. 16, fig. 16 shows the result of the beautifying according to an embodiment of the writing beautifying method of the present application.
By the writing beautifying method, handwriting written on the touch screen by a user can be beautified, and the beautified handwriting is smooth and has no problems of bump defects and the like.
Referring to fig. 17, fig. 17 is a schematic diagram of a frame of an embodiment of the writing beautifying device of the present application.
In this embodiment, the writing beautifying device 170 includes an acquisition module 171, a smoothing module 172, and an outer contour calculation module 173. Wherein, the acquisition module 171 is used for acquiring information of a plurality of writing track points, wherein, the information of the writing track points comprises coordinates, pressure and time of the writing track points. The smoothing module 172 is configured to estimate a pen width of a writing track point to obtain a pen width corresponding to the writing track point, and sequentially perform track smoothing on the writing track point by using an improved third-order bezier algorithm to obtain information of a plurality of interpolation track points, where a control point used by the improved third-order bezier algorithm includes a currently processed writing track point and the first three writing track points thereof, and the information of the interpolation track points obtained by the improved third-order bezier algorithm is between a first writing track point and a second writing track point before the currently processed writing track point, the information of the interpolation track points includes coordinates and the pen width of the interpolation track points, and the outline calculation module 173 is configured to calculate an outline of each pen segment by using the information of the pen brush model and the interpolation track points, respectively, where the plurality of interpolation track points are divided into a plurality of pen segments.
In the scheme, the information of a plurality of writing track points is acquired through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized for carrying out track smoothing on the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are between the first writing track point and the second writing track point which are in front of the current writing track points, and the outer contour of each pen section is calculated by utilizing the information of a pen brush model and the interpolation track points respectively.
Referring to fig. 18, fig. 18 is a schematic diagram of a frame of an embodiment of the writing beautifying device of the present application.
In this embodiment, the writing beautifying device 180 includes a memory 181, a processor 182, wherein the memory 181 is coupled to the processor 182. In particular, the various components of the writing instrument 180 may be coupled together by a bus, or the processor 182 of the writing instrument 180 may be coupled to each other individually. The writing beautifying device 180 may be any device having processing capabilities, such as a computer, tablet, cell phone, etc.
The memory 181 is used for storing program data executed by the processor 182, data during processing by the processor 182, and the like. For example, writing track points, interpolation track points, etc. Wherein the memory 181 includes a nonvolatile storage portion for storing the above-mentioned program data.
The processor 182 controls the operation of the writing beautifying device 180, and the processor 182 may also be referred to as a CPU (Central Processing Unit ). The processor 182 may be an integrated circuit chip having signal processing capabilities. The processor 182 may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, the processor 182 may be commonly implemented by a plurality of constituent circuit chips.
The processor 182 is operable to execute instructions to implement any of the above-described writing beautification methods by invoking program data stored in the memory 181.
For example, the processor 182 collects information of a plurality of writing track points, performs pen width estimation for the writing track points and sequentially performs track smoothing for the writing track points by using a modified third-order bezier algorithm to obtain information of a plurality of interpolation track points, and calculates an outer contour of each pen segment by using the pen brush model and the information of the interpolation track points.
In the scheme, the information of a plurality of writing track points is acquired through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized for carrying out track smoothing on the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are between the first writing track point and the second writing track point which are in front of the current writing track points, and the outer contour of each pen section is calculated by utilizing the information of a pen brush model and the interpolation track points respectively.
Referring to FIG. 19, FIG. 19 is a schematic diagram illustrating an embodiment of a computer readable storage medium of the present application.
In this embodiment, the computer readable storage medium 190 stores program data 191 executable by a processor to implement any of the above-described writing beautification methods.
The computer readable storage medium 190 may be a medium capable of storing program data, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or may be a server storing the program data, where the server may send the stored program data to another device for execution, or may also self-execute the stored program data.
In some embodiments, computer readable storage medium 190 may also be a memory as shown in FIG. 18.
In the scheme, the information of a plurality of writing track points is acquired through the touch screen, the pen width is estimated for the writing track points, the improved three-order Bezier algorithm is sequentially utilized for carrying out track smoothing on the writing track points to obtain the information of a plurality of interpolation track points, wherein the control points used by the improved three-order Bezier algorithm comprise the current writing track points and the first three writing track points, the plurality of interpolation track points obtained by the improved three-order Bezier algorithm are between the first writing track point and the second writing track point which are in front of the current writing track points, and the outer contour of each pen section is calculated by utilizing the information of a pen brush model and the interpolation track points respectively.
The foregoing description is only of embodiments of the present application, and is not intended to limit the scope of the patent application, and all equivalent structures or equivalent processes using the descriptions and the contents of the present application or other related technical fields are included in the scope of the patent application.

Claims (14)

1. A method of writing beautification, the method comprising:
collecting information of a plurality of writing track points, wherein the information of the writing track points comprises coordinates, pressure and time of the writing track points;
estimating the pen width of the writing track points to obtain the pen width corresponding to the writing track points, and carrying out track smoothing on the writing track points by using an improved third-order Bezier algorithm to obtain information of a plurality of interpolation track points, wherein a control point used by the improved third-order Bezier algorithm comprises the currently processed writing track points and the first three writing track points thereof, the plurality of interpolation track points obtained by the improved third-order Bezier algorithm are positioned between a first writing track point and a second writing track point which are positioned before the currently processed writing track points, and the information of the interpolation track points comprises coordinates and the pen width of the interpolation track points;
The interpolation track points are divided into a plurality of pen segments, and the outer contour of each pen segment is calculated by using the information of the pen brush model and the interpolation track points;
wherein, the calculating the outer contour of each pen segment by using the information of the brush model and the interpolation track point respectively includes:
carrying out affine transformation on the brush model by using the coordinate of each interpolation track point as a center and utilizing the pen width of each interpolation track point to obtain a track point brush on each interpolation track point, wherein the track point brush comprises a plurality of sections of Bezier curves;
for each pen section, convex hull complex solving is carried out on each two adjacent track point pen brushes to obtain two outer contour connection points for connecting each track point pen brush with the adjacent track point pen brushes;
determining a first Bezier curve of the outer contour connecting point on the track point brush and a corresponding interpolation value;
if the outer contour connecting point is not the starting point or the ending point of the first Bezier curve, the first Bezier curve is divided into a second Bezier curve and a third Bezier curve by taking the outer contour connecting point as a dividing point;
Re-fitting the second Bezier curve and the third Bezier curve to obtain new control point and contour point information;
replacing the control point and contour point information of the first Bezier curve in the track point brush with the new control point and contour point information;
and taking the part of the first track point brush of the pen section, which is not enveloped by the upper section outline of the pen section and the lower section outline of the pen section, as the first section outline of the pen section, and taking the part of the last track point brush of the pen section, which is not enveloped by the upper section outline of the pen section and the lower section outline of the pen section, as the tail section outline of the pen section.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the formula of the improved third-order Bessel algorithm is as follows
Wherein Q is 0 For the third writing track point before the currently processed writing track point, Q 1 For the second writing track point before the writing track point currently processed, Q 2 For the first writing track point before the writing track point currently processed, Q 3 And t is the interpolation quantity of the Bezier curve for the currently processed writing track point.
3. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the calculating the outer contour of each pen segment by using the brush model and the information of the interpolation track points respectively further comprises:
and respectively performing Bezier curve fitting on two outer contour connecting points of all interpolation track points in the pen section to obtain an upper section outer contour and a lower section outer contour of the pen section, and combining the first section outer contour of the pen section and the tail section outer contour of the pen section to form the outer contour of the pen section.
4. A method according to claim 3, wherein the method further comprises:
and encoding the outer contour of the pen section.
5. The method of claim 4, wherein the step of determining the position of the first electrode is performed,
the encoding of the outer contour of the pen segment includes:
determining a corresponding contour Bezier curve and an interpolation interval of the outer contour of the first section/the outer contour of the tail section in the track point brush;
if the contour Bezier curve with the interpolation value interval smaller than the [0,1] range exists, performing trisection interpolation calculation on the interpolation value interval to obtain a calculation result, re-performing Bezier curve fitting on the calculation result, and updating a control point sequence of the contour Bezier curve, otherwise, directly using the existing control point sequence of the contour Bezier curve;
And taking the control point sequences of all the contour Bezier curves corresponding to the outer contour of the first section/the outer contour of the tail section as coding results of the outer contour of the first section/the outer contour of the tail section.
6. The method of claim 4, wherein the step of determining the position of the first electrode is performed,
the encoding of the outer contour of the pen segment includes:
and respectively performing Bezier curve fitting on two outer contour connecting points of the interpolation track points in the pen section to obtain control point sequences of the upper section outer contour and the lower section outer contour as corresponding coding results.
7. The method according to claim 6, wherein the method further comprises:
judging whether the radian quantity of the Bezier curve corresponding to the control point sequence of the upper section outer contour/the lower section outer contour is larger than one;
and if so, taking the outer contour connecting point as a control point of the upper section outer contour/the lower section outer contour.
8. The method of claim 3, wherein said affine transformation of said brush model using said width of said interpolated track points centered on the coordinates of each said interpolated track point, said method further comprising, prior to obtaining a track point brush at each said interpolated track point:
And screening the interpolation track points according to the inclusion relation.
9. The method of claim 1, wherein before calculating the outer contour of each pen segment using the brush model and the information of the interpolated track points, respectively, further comprises:
and performing brush modeling to obtain the brush model.
10. The method of claim 9, wherein the step of determining the position of the substrate comprises,
the step of performing brush modeling to obtain the brush model comprises the following steps:
acquiring a brush track point sequence;
performing Bezier curve fitting on the brush track point sequence;
judging whether an inflection point exists, wherein the inflection point is the brush track point of which the minimum distance between the inflection point and the Bezier curve obtained by fitting exceeds a preset threshold value;
and if the curve exists, dividing the brush track point sequence by taking the inflection point as a dividing point, fitting the curve again by using the inflection point, and if the curve does not exist, storing control points of all the fitted Bezier curves as the control point sequence of the brush, and sampling contour points of all the Bezier curves to obtain the brush model.
11. The method of claim 1, wherein the collecting information of the plurality of writing trace points further comprises:
And carrying out coordinate conversion and screening on the writing track points.
12. A writing beautifying device, the writing beautifying device comprising:
the acquisition module is used for acquiring information of a plurality of writing track points, wherein the information of the writing track points comprises coordinates, pressure and time of the writing track points;
the system comprises a smoothing module, a first interpolation track point and a second interpolation track point, wherein the smoothing module is used for estimating the pen width of the writing track point to obtain the pen width corresponding to the writing track point, and sequentially utilizing an improved third-order Bezier algorithm to carry out track smoothing on the writing track point to obtain information of a plurality of interpolation track points, the control points used by the improved third-order Bezier algorithm comprise the currently processed writing track point and the first three writing track points thereof, the plurality of interpolation track points obtained by the improved third-order Bezier algorithm are arranged between the first writing track point and the second writing track point which are positioned before the currently processed writing track point, and the information of the interpolation track points comprises coordinates and the pen width of the interpolation track points;
the outer contour calculation module is used for calculating the outer contour of each pen segment by utilizing the information of the pen brush model and the interpolation track points, wherein the interpolation track points are divided into a plurality of pen segments;
Wherein, the calculating the outer contour of each pen segment by using the information of the brush model and the interpolation track point respectively includes:
carrying out affine transformation on the brush model by using the coordinate of each interpolation track point as a center and utilizing the pen width of each interpolation track point to obtain a track point brush on each interpolation track point, wherein the track point brush comprises a plurality of sections of Bezier curves;
for each pen section, convex hull complex solving is carried out on each two adjacent track point pen brushes to obtain two outer contour connection points for connecting each track point pen brush with the adjacent track point pen brushes;
determining a first Bezier curve and a corresponding interpolation value of the outer contour connection point;
if the outer contour connecting point is not the starting point or the ending point of the first Bezier curve, the first Bezier curve is divided into a second Bezier curve and a third Bezier curve by taking the outer contour connecting point as a dividing point;
re-fitting the second Bezier curve and the third Bezier curve to obtain new control point and contour point information;
replacing the control point and contour point information of the first Bezier curve in the track point brush with the new control point and contour point information;
And taking the part of the first track point brush of the pen section, which is not enveloped by the upper section outline of the pen section and the lower section outline of the pen section, as the first section outline of the pen section, and taking the part of the last track point brush of the pen section, which is not enveloped by the upper section outline of the pen section and the lower section outline of the pen section, as the tail section outline of the pen section.
13. A writing beautification device comprising a processor and a memory, the memory for storing program data, the processor for executing the program data to implement the method of any of claims 1-11.
14. A computer readable storage medium for storing program data executable to implement the method of any one of claims 1-11.
CN202111592814.5A 2021-12-23 2021-12-23 Writing beautifying method, device, equipment and readable storage medium Active CN114356201B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111592814.5A CN114356201B (en) 2021-12-23 2021-12-23 Writing beautifying method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111592814.5A CN114356201B (en) 2021-12-23 2021-12-23 Writing beautifying method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN114356201A CN114356201A (en) 2022-04-15
CN114356201B true CN114356201B (en) 2024-02-20

Family

ID=81101105

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111592814.5A Active CN114356201B (en) 2021-12-23 2021-12-23 Writing beautifying method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114356201B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024065252A1 (en) * 2022-09-28 2024-04-04 Boe Technology Group Co., Ltd. Display apparatus, display method, and computer-program product

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521858A (en) * 2011-11-28 2012-06-27 北京盛世宣合信息科技有限公司 Handwriting generating method for electronic writing brush
CN102520849A (en) * 2011-11-28 2012-06-27 北京盛世宣合信息科技有限公司 Electronic brush writing method and system
CN102937850A (en) * 2012-12-04 2013-02-20 上海合合信息科技发展有限公司 Method for beautifying handwriting in real time and electronic equipment
CN102937849A (en) * 2012-12-04 2013-02-20 上海合合信息科技发展有限公司 Method for beautifying handwriting in real time and electronic equipment
CN104268915A (en) * 2014-09-19 2015-01-07 华南理工大学 Real-time contour beautifying method of handwritten Chinese characters
CN108733293A (en) * 2018-06-11 2018-11-02 广州视源电子科技股份有限公司 Handwriting trace processing method and processing device
CN109284059A (en) * 2018-08-28 2019-01-29 广州视源电子科技股份有限公司 Person's handwriting method for drafting, device, interactive intelligent tablet computer and storage medium
CN111815743A (en) * 2020-07-14 2020-10-23 深圳市昇利扬科技有限公司 Method for beautifying handwriting of digital ink

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101126167B1 (en) * 2010-06-07 2012-03-22 삼성전자주식회사 Touch screen and method of displaying

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521858A (en) * 2011-11-28 2012-06-27 北京盛世宣合信息科技有限公司 Handwriting generating method for electronic writing brush
CN102520849A (en) * 2011-11-28 2012-06-27 北京盛世宣合信息科技有限公司 Electronic brush writing method and system
CN102937850A (en) * 2012-12-04 2013-02-20 上海合合信息科技发展有限公司 Method for beautifying handwriting in real time and electronic equipment
CN102937849A (en) * 2012-12-04 2013-02-20 上海合合信息科技发展有限公司 Method for beautifying handwriting in real time and electronic equipment
CN104268915A (en) * 2014-09-19 2015-01-07 华南理工大学 Real-time contour beautifying method of handwritten Chinese characters
CN108733293A (en) * 2018-06-11 2018-11-02 广州视源电子科技股份有限公司 Handwriting trace processing method and processing device
CN109284059A (en) * 2018-08-28 2019-01-29 广州视源电子科技股份有限公司 Person's handwriting method for drafting, device, interactive intelligent tablet computer and storage medium
CN111815743A (en) * 2020-07-14 2020-10-23 深圳市昇利扬科技有限公司 Method for beautifying handwriting of digital ink

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Weiping Xia ; Lianwen Jin.A Kai Style Calligraphic Beautification Method for Handwriting Chinese Character.《 2009 10th International Conference on Document Analysis and Recognition》.2009,第798-802页. *
基于令牌的笔迹美化方法;肖仁锋;《信息技术与信息化》;第174-175页 *

Also Published As

Publication number Publication date
CN114356201A (en) 2022-04-15

Similar Documents

Publication Publication Date Title
US9632678B2 (en) Image processing apparatus, image processing method, and program
US8787695B2 (en) Image rectification using text line tracks
KR101939936B1 (en) Method and apparatus for recognizing fingerprints
US20130147809A1 (en) Method and apparatus for calligraphic beautification of handwritten characters
US10204447B2 (en) 2D image processing for extrusion into 3D objects
EP2808828A2 (en) Image matching method, image matching device, model template generation method, model template generation device, and program
CN114356201B (en) Writing beautifying method, device, equipment and readable storage medium
US11651604B2 (en) Word recognition method, apparatus and storage medium
CN113888431A (en) Training method and device of image restoration model, computer equipment and storage medium
US20130294707A1 (en) Geometric modelization of images and applications
CN113077477B (en) Image vectorization method and device and terminal equipment
CN113688261B (en) Image data cleaning method and device, electronic equipment and readable storage medium
CN113538623B (en) Method, device, electronic equipment and storage medium for determining target image
JP5067882B2 (en) Image processing apparatus, image processing method, and program
CN115937825B (en) Method and device for generating robust lane line under BEV of on-line pitch angle estimation
JP2018180646A (en) Object candidate area estimation device, object candidate area estimation method and object candidate area estimation program
JP5111226B2 (en) Image processing method, image processing apparatus, program thereof, and computer-readable storage medium
US20100172595A1 (en) Image processing method, image processing apparatus, and computer program
CN113392820B (en) Dynamic gesture recognition method and device, electronic equipment and readable storage medium
CN113128324B (en) Gesture segmentation method based on depth data, gesture segmentation system based on depth data and electronic equipment
CN114092696A (en) Image segmentation method and device, electronic equipment and storage medium
US20050238234A1 (en) Method for edge detection and contour stroke generation
JP5083551B2 (en) Data processing apparatus, outline data generation apparatus, data processing program, outline data generation program
JP4900025B2 (en) Image processing apparatus and image processing program
CN116168402A (en) Handwriting corner determination method and device, storage medium and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant