A variable line width generation and rendering method based on trajectory sequences

CN122929006APending Publication Date: 2026-10-16TIANJIN UNIV OF SCI & TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611109046.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-24
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

纯规则线宽生成方式可解释,但规则参数调节复杂,且在不同字结构与不同风格上泛化不足,容易在拐角、起收笔、速度突变处出现不自然的线宽突变;

Benefits of technology

1.针对现有技术依赖压力采样信号且面向识别任务的问题,本发明无需压力采样信号,仅基于通用轨迹输入即可生成点级线宽序列并完成渲染输出。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122929006A_ABST
    Figure CN122929006A_ABST
Patent Text Reader

Abstract

The application discloses a variable line width generation and rendering method based on a trajectory sequence, and belongs to the technical field of computer graphics processing; the method acquires a trajectory point sequence containing relative displacement and pen state marks; absolute coordinates are calculated, and a feature sequence containing displacement, velocity, acceleration, turning amount and position context is constructed; the feature sequence is input into a sequence neural network to obtain a point-level initial normalized line width value sequence; subsequent post-processing is performed on the initial line width to enhance continuity, naturalness or conformity to a preset style, so that a final line width sequence is obtained; finally, the line width is mapped into a pixel width, and a variable line width rendering generation image connected through sampling and polygon is generated; the application takes into account naturalness, stability and controllability, and is suitable for font generation and handwriting simulation scenes; the application solves the technical problems of unnatural and unstable rendering under no pressure signal, and can generate a natural, stable and controllable variable line width image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical fields of computer graphics, artificial intelligence and digital media, and specifically relates to a variable linewidth generation and rendering technology for font generation, handwriting simulation, electronic signature beautification and digital trajectory visualization, and particularly to a variable linewidth generation and rendering method based on trajectory sequences. Background Technology

[0002] In font generation and online handwriting applications, the writing process is often represented by a sequence of trajectories. When rendering the trajectory sequence as an image, the dynamic changes in stroke width play an important role in simulating realistic handwriting style.

[0003] In the prior art:

[0004] On the one hand, regarding the stroke rendering problem in vector graphics, existing work has proposed the idea of ​​"stroke contour expansion and outer contour generation" for the input path, and has provided a stroke expansion algorithm for GPU parallel execution to generate a renderable stroke outer contour. However, this type of solution focuses more on geometric correctness and efficient rendering pipeline, and usually does not involve point-level line width prediction based on trajectory dynamics and style learning, and rarely provides interpretable tuning and stabilization strategies related to writing habits.

[0005] On the other hand, in the field of online handwriting recognition, existing research has used pressure as a dynamic feature for recognition modeling, such as combining pressure-related features in the sub-stroke HMM framework to improve the recognition rate. However, such solutions are mainly aimed at recognition tasks and pressure feature modeling, usually relying on pressure signals obtained by hardware sampling, and are not designed for the complete engineering chain of "generating natural and stable variable linewidths from the trajectory and completing the rendering output".

[0006] In summary, existing technologies focus more on the generation and rendering efficiency of outline geometry, lacking a mechanism to learn linewidth styles from general trajectory dynamics and stably output point-level linewidth sequences. They emphasize task recognition and rely on pressure sampling signals, making it difficult to directly solve the problem of generating controllable and natural linewidth sequences and completing rendering output under ordinary trajectory input conditions without pressure information. Currently, the main shortcomings are as follows: Fixed line width rendering is simple to implement, but the strokes look stiff and lack variation in stroke direction and writing pressure. The pure rule-based line width generation method is interpretable, but the rule parameters are complex to adjust and it is not generalizable enough for different character structures and styles. It is easy for unnatural line width changes to occur at corners, starting and ending strokes, and sudden changes in speed. Purely data-driven models, such as sequence networks, can learn styles, but may suffer from problems such as narrow output dynamic range, local jitter, and difficulty in intuitive control.

[0007] Therefore, a complete solution from trajectory to image is needed, which can generate linewidths that not only have the style trends learned by the model, but also ensure continuity and controllability through interpretable rules, and generate natural and stable variable linewidth rendering images based solely on trajectory sequences (without stress information). Summary of the Invention

[0008] The purpose of this invention is to provide a variable line width generation and rendering scheme based on trajectory sequence, so as to obtain continuous, natural, stable and controllable line width in corners, starting and ending strokes and speed change areas, and output font images.

[0009] To achieve the above objectives, the technical solution adopted by the present invention is as follows: In a first aspect, the present invention provides a method for generating and rendering variable linewidths based on trajectory sequences, the method comprising the following steps: S10. Obtain a trajectory point sequence, wherein the trajectory point sequence includes at least the relative displacement component for each step and the pen state marker.

[0010] S20. Feature Construction. Calculate the absolute coordinate sequence of the trajectory based on the trajectory point sequence, and construct a feature vector for each trajectory point to form a feature sequence. The constructed feature vector includes: relative displacement, velocity magnitude, acceleration magnitude, turning point, pen placement state, and normalized coordinates of the horizontal position.

[0011] S30. Linewidth Prediction. The feature sequence is input into a sequence neural network, which outputs an initial normalized linewidth value sequence for each trajectory point. The range of the initial normalized linewidth value sequence is constrained by an activation function. The sequence neural network is a bidirectional long short-term memory network, and its output is regressed by a multilayer perceptron and constrained by a sigmoid activation function. scope.

[0012] S40. Post-processing. Post-processing is performed on the initial normalized linewidth value sequence to enhance the continuity, naturalness, or conformity to a preset style of the linewidth sequence, resulting in the final normalized linewidth value sequence. The post-processing may include, but is not limited to, robust range constraints, distribution modulation, dynamic modulation, corner enhancement, start and end stroke gradation, and temporal smoothing.

[0013] S50. Rendering Output. The final normalized linewidth value sequence is mapped to the pixel linewidth range, and the trajectory point sequence is rendered with variable linewidth to generate an image.

[0014] Secondly, embodiments of the present invention also provide a variable linewidth generation and rendering system based on trajectory sequences. The system can run on a server, personal computer, or mobile terminal. The system includes: a trajectory acquisition module, a feature construction module, a linewidth prediction module, a post-processing module, and a rendering module, and supports batch generation. Wherein: The trajectory acquisition module is used to acquire a sequence of trajectory points; The feature construction module is used to calculate the absolute coordinate sequence and construct the feature sequence based on the trajectory point sequence; The linewidth prediction module has a sequence neural network internally deployed to receive the feature sequence and output an initial normalized linewidth value sequence. The post-processing module is used to perform post-processing on the initial normalized linewidth value sequence to obtain the final normalized linewidth value sequence. The rendering module is used to map the final normalized linewidth value sequence to pixel linewidths and generate images by sampling and drawing variable linewidths connected to polygons.

[0015] Thirdly, embodiments of the present invention also provide an electronic device, including a processor and a memory, wherein the memory stores a computer program that can be executed by the processor, and the processor can execute the above-described method when executing the program.

[0016] As can be seen from the above technical solution, compared with the prior art, the present invention has the following beneficial effects: 1. In view of the problem that existing technologies rely on pressure sampling signals and are geared towards recognition tasks, this invention does not require pressure sampling signals and can generate point-level line width sequences and complete rendering output based solely on general trajectory input.

[0017] 2. To address the problem that existing technologies focus on geometric expansion of outlines but lack a learnable linewidth generation mechanism, this invention achieves point-level linewidth prediction through a sequence neural network, which can learn and reproduce linewidth style trends from trajectory dynamics and training data.

[0018] 3. To address the issues of jitter and difficulty in control of pure model output, this invention introduces a parameterized post-processing module. Through robust range constraints, temporal smoothing, and speed and geometry-based modulation, the line width sequence becomes more continuous, natural, stable, and controllable in corners, starting and ending points, and speed variation regions.

[0019] 4. This invention allows for the adjustment of line width style and tool feel using a few intuitive parameters, such as contrast, gamma, speed pressure intensity, corner threshold, and start / end stroke ratio, facilitating engineering implementation and batch generation.

[0020] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.

[0021] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.

[0024] Figure 1 The present invention provides a schematic diagram of the method flow and system structure.

[0025] Figure 2 This is a schematic diagram illustrating the feature structure provided by the present invention.

[0026] Figure 3 This is a schematic diagram of the linewidth prediction network structure provided by the present invention.

[0027] Figure 4 This is a schematic diagram of the post-processing module provided by the present invention.

[0028] Figure 5 This is a schematic diagram illustrating the variable linewidth rendering principle provided by the present invention.

[0029] Figure 6 This is a schematic diagram illustrating the effect of the fixed line width provided by the present invention.

[0030] Figure 7 This is a schematic diagram of the model effect provided by the present invention.

[0031] Figure 8 This is a schematic diagram illustrating the effect of the rule only provided by the present invention.

[0032] Figure 9 This is a schematic diagram of the rendering effect after fusion provided by the present invention.

[0033] Figure 10 This is a schematic diagram of the electronic device structure provided by the present invention. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0035] In the description of this invention, it should be noted that some processes described in this application specification and drawings include multiple operations that appear in a specific order. However, it should be clearly understood that these operations may be performed in any order or in parallel. Furthermore, various numbers are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0036] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0037] This invention aims to provide a method and system for generating and rendering variable linewidths based on trajectory sequence-based neural network prediction and post-processing fusion. This method achieves continuous, natural, stable, and controllable linewidths at corners, stroke start / end points, and speed variation areas, and outputs font images. This invention solves the visual unnaturalness caused by fixed linewidths; addresses the problem of abrupt or unstable linewidth changes at key points such as corners, stroke start / end points, and speed variations in purely rule-based or purely model-based methods; and addresses the lack of a learnable point-level linewidth generation mechanism and reliance on pressure sampling signals in existing technologies. It generates continuous, natural, and controllable point-level linewidth sequences under ordinary trajectory input conditions without pressure information and achieves stable variable linewidth rendering output.

[0038] To achieve the above objectives, see [link to relevant documentation]. Figure 1 As shown in the figure, this invention discloses a method for generating and rendering variable linewidths based on trajectory sequences, which mainly includes the following steps: S10. Obtain the trajectory point sequence. The trajectory point sequence includes at least the relative displacement components for each step and the pen status markers.

[0039] S20. Feature Construction. Calculate the absolute coordinate sequence of the trajectory based on the trajectory point sequence, and construct a feature vector for each trajectory point to form a feature sequence.

[0040] S30. Linewidth Prediction. The feature sequence is input into a sequence neural network, which outputs an initial normalized linewidth value sequence for each trajectory point. The range of values ​​for the initial normalized linewidth value sequence is constrained by the activation function. .

[0041] S40. Post-processing. Perform post-processing on the initial normalized linewidth value sequence to enhance the continuity, naturalness, or conformity to a preset style of the linewidth sequence, and obtain the final normalized linewidth value sequence; post-processing may include, but is not limited to, robust range constraints, distribution modulation, dynamic modulation, corner enhancement, start and end stroke gradation, and temporal smoothing.

[0042] S50, Rendering Output. The final normalized linewidth value sequence is mapped to the pixel linewidth range, and the trajectory point sequence is rendered with variable linewidth to generate an image.

[0043] The specific embodiments of the present invention will be described in detail below: I. Trajectory and Preprocessing: In some implementations, the sequence of trajectory points is expressed in the form of relative displacement, denoted as... , The absolute coordinates are obtained by accumulating them:

[0044] Where P0 is the absolute coordinate of the starting point of the trajectory, determined by the initial relative displacement ( P is obtained directly. i Let be the absolute coordinates of the i-th point, derived from the absolute coordinates of the previous point. Add the relative displacement of the current point get.

[0045] In some implementations, the trajectory can be divided into several stroke segments based on the end marker or pen break marker of the trajectory, for subsequent speed-pressure modulation, start and end stroke processing, etc.

[0046] II. Construction of 7-dimensional features: In a preferred embodiment, see Figure 2 As shown, for each point Constructing 7-dimensional feature vectors : 1. Relative displacement .

[0047] 2. Relative displacement .

[0048] 3. Velocity Module The velocity vector is obtained by subtracting the absolute coordinates and taking the norm, and then normalized according to the maximum value of the sequence;

[0049]

[0050]

[0051] in, Let be the velocity vector at point i, which consists of the relative displacements in the horizontal and vertical directions. The L2 norm of the velocity vector represents the magnitude of the pen tip's movement speed; N This represents the total number of sampling points for a single stroke trajectory. This represents the maximum velocity modulus over the entire trajectory. The normalized velocity modulus has a range of values. A higher value indicates a faster writing speed.

[0052] 4. Acceleration modulus The acceleration vector is obtained by subtracting the velocity vector and taking its norm, and then normalized according to the maximum value of the sequence.

[0053]

[0054]

[0055] in, For the first i- The velocity vector at point 1; : This is the difference between the velocity vectors of two adjacent points, i.e., the acceleration vector; : is the L2 norm of the acceleration vector, representing the magnitude of the velocity change; This represents the maximum magnitude of the acceleration modulus for the entire trajectory. The normalized acceleration modulus takes values ​​of [0,1]. A larger value indicates a more pronounced change in writing speed.

[0056] 5. Turning point Take the angle between two adjacent vector segments. and define Then normalize according to the maximum value of the sequence.

[0057] 6. Pen-writing state When the trajectory includes end / end marker dimensions, the following can be taken: ; 7. Horizontal position normalization Using absolute coordinates Perform min-max normalization on the components.

[0058] III. Linewidth Prediction Network: In some implementations, see Figure 3 As shown, the linewidth prediction network includes: a bidirectional LSTM layer to extract forward and backward contextual features, an MLP regression head to perform point-level regression of linewidth, and a Sigmoid activation to constrain the output to... .

[0059] In a preferred embodiment, the bidirectional LSTM has 2 layers and a hidden dimension of 128; the MLP includes at least two layers of nonlinear transformation and dropout.

[0060] IV. Post-processing: In some implementations, see Figure 4 As shown, post-processing may include two or more of the following; in the preferred embodiment, it is performed in the following order.

[0061] S401 Robust Quantile Normalization: Let the original linewidth sequence output by the network be... Take the lower quantile. or high quantile :

[0062] in, express Quantiles. First, crop to... :

[0063] Then linearly scale to :

[0064] in, To prevent stable terms with a denominator of zero.

[0065] S402 distributed modulation: ① Contrast modulation:

[0066] ② Gamma modulation:

[0067] in, Contrast coefficient, Gamma coefficient, This indicates range clipping.

[0068] S403 timing smoothing: right Perform a one-dimensional smooth convolution:

[0069] in, The length of the smoothing kernel is an odd number. This is a relative offset index. The moving average kernel weighting coefficient; This indicates an offset from the i-th point. The line width value at the location.

[0070] S404 Speed-Pressure Modulation: The velocity is calculated based on stroke segments, and the velocity sequence is then quantile-trimmed and normalized to obtain the result. Constructing the stress factor:

[0071] With adjustable intensity Multiplicative modulation linewidth:

[0072] in, It is a stress factor.

[0073] S405 Corner Enhancement: The turning angle is obtained from the angle between adjacent vectors. (Unit: degree). When Time-based dot-multiplicative enhancement ( (for corner thresholds)

[0074] in, The corner reinforcement strength coefficient; It can also perform a light smoothing on the enhanced local segments.

[0075] S406 begins with a gradual change in the ending stroke: For each stroke, the starting and ending segments are proportionally extracted, and multiplicative enhancement / attenuation curves are applied to each segment, with a lower limit set to avoid excessive thinness.

[0076] Parameter value range: In some implementations, the range of values ​​for the above parameters can be referenced as follows: Quantiles: , Preferred ; Preferred ; Preferred ; It is an odd number and Preferred ; Preferred ; Preferred ; Preferred .

[0077] V. Variable linewidth rendering: In some implementations, the normalized linewidth is mapped to the pixel linewidth. :

[0078] In a preferred embodiment, , In other embodiments, Desirable Pixels Desirable Pixel.

[0079] In some implementations, see Figure 5 As shown, the rendering process includes: sampling line segments formed by adjacent points; drawing filled circles or ellipses at the sampling points, with the axes aligned to the bounding boxes; and using quadrilateral polygon fills to connect adjacent sampling segments to reduce gaps, thereby outputting a grayscale image.

[0080] VI. Methods for constructing linewidth monitoring data: To train the linewidth prediction network, training sample pairs can be obtained, namely trajectory sequences and point-level linewidth labels. This invention is not limited to a single data source; two preferred data construction methods are given below.

[0081] (1) Automatically construct point-level line width labels from offline handwritten images: The input is a grayscale or binary image of a single character or a single stroke. Binarizing the image yields the foreground region. and to Perform skeletonization to obtain the centerline skeleton. Then the skeleton Convert to an ordered set of paths Each path A sequence of pixels sorted by their connectivity.

[0082] For each point in the path Estimating local line width can preferably be achieved using at least one of the following methods: Distance transformation: for Calculate the Euclidean distance transformation graph Then the local radius Line width label ; Normal detection: Search along the positive and negative directions of the normal to the foreground boundary to obtain the distances on both sides. and Line width ; Hybrid approach: Combine the two by weight or select the more robust one in case of failure / instability.

[0083] To suppress outliers and spikes, robust filtering can be applied to the linewidth labels, such as quantile clipping, local median filtering, and spike suppression, to achieve the desired effect. It remains continuous and stable at corners, intersections, and endpoints.

[0084] (2) Construct line width labels from existing online trajectory data: When the input is an online writing trajectory containing information such as pressure or contact area, the pressure or contact area can be normalized and used as... Reference; or the linewidth label can be obtained by fitting the pressure and geometric features together.

[0085] VII. Training Methods for Linewidth Prediction Networks: The linewidth prediction network is trained using supervised learning. The network input is a feature sequence, and the output is a point-level predicted linewidth. , tag as The training objective can be weighted mean square error:

[0086] in, This is a valid point mask used to ignore lift-off points, invalid fills, or endpoint anomalies.

[0087] In some implementations, general model parameters and general checkpoints can be obtained by first training on a large-scale general dataset, and then fine-tuned on a small-scale target style data to achieve style adaptation.

[0088] 8. Implementation methods for style adaptation with few samples: To achieve few-shot line width style transfer and make the rendering result mimic the line width style of a specific writer or pen, a few-shot style adaptation can be used: obtain a set of sample examples of the target style. It automatically constructs target style training sample pairs and fine-tunes them based on general checkpoints to obtain suitable checkpoints.

[0089] Adaptation strategies may include, but are not limited to: Full parameter fine-tuning: Updates all network parameters, suitable when there is a large difference between the target style and the general style (in the preferred implementation, a general checkpoint can be used as the initialization and fine-tuned to obtain a new checkpoint). Fine-tuning of some parameters: Freeze the bidirectional LSTM layer and only update the MLP regression head parameters. This is suitable when there are few target samples and it is necessary to suppress overfitting. Only by learning the output scale and bias, we obtain :

[0090] in, b is the scaling factor, and b is the bias term; Through the aforementioned few-sample adaptation, the line width distribution output by the model (e.g., overall thickness / thinness, contrast between thickness and thinness, and the degree of thickening at corners) can be aligned with the target style, thereby achieving a more consistent visual style on the same trajectory.

[0091] IX. Post-processing controllability and parameter configuration methods: To enable both automatic and intuitive adjustment of linewidth post-processing, this invention provides a parameterized configuration method, with parameters including at least: quantile threshold and contrast coefficient. Gamma coefficient Smooth kernel length Speed, pressure, and intensity Corner threshold With enhanced strength The starting and ending stroke ratios and intensity, etc. To avoid unreasonable output caused by parameter combinations, boundaries and default values ​​can be set, and a validity check can be performed before rendering.

[0092] 10. Experimental Verification: In this embodiment of the invention, under the same trajectory input, the rendering effects of fixed linewidth (setting the linewidth of all points to a constant), rule-only (generating linewidth directly from rules such as speed and turning angle without using neural network prediction), model-only (using only network output and directly mapping it to pixel linewidth, without post-processing or with weakened post-processing), and the present invention (network prediction + post-processing + variable linewidth rendering) were compared. The results are respectively referred to [reference needed]. Figures 6-9 As shown, fixed line width rendering results in an overall uniform appearance but lacks sharpness; only the regular scheme can reflect the thickness of simple strokes, but abrupt changes are prone to occur at complex structures, corners, and endpoints; only the model scheme can reflect a certain style trend, but there may be local jitter, a narrow dynamic range, or excessive thickness / thinness at a few abnormal points; the fusion scheme of this invention, through robust range constraints, smoothing, and local enhancement, makes the line width more natural in key parts and more stable overall.

[0093] XI. Exception Handling and Boundary Conditions (Robust Implementation): In some embodiments, the present invention provides robust handling for abnormal inputs or boundary conditions, including but not limited to: 1) Trajectory length is too short: When the number of points in a stroke segment is less than the threshold, skip corner enhancement and start and end stroke gradation, and only perform basic clipping and smoothing; 2) Width distribution degradation: when ` `and` If scaling becomes unstable due to the area being too close, it degenerates into simple cropping or uses the default range. 3) No effective change in velocity sequence: When the velocity quantile range is too small, making normalization unreliable, skip velocity-pressure modulation; 4) Self-intersecting / crossing regions: In locally geometrically unstable regions, robust filtering is used to suppress spikes, and sampling and connection strategies are employed during the rendering stage to reduce holes and breaks.

[0094] Through the robust design described above, the present invention can maintain acceptable rendering quality under different character complexities, different sampling densities, and different input noise levels.

[0095] 12. Other optional implementation methods: Without departing from the concept of this invention, various modifications and substitutions can be made: 1) Network structure replacement: Bidirectional LSTM can be replaced by GRU, Transformer encoder or one-dimensional convolutional network; 2) Feature expansion: Based on the 7-dimensional features, features such as stroke sequence number, relative time, local radius of curvature, and neighborhood density can be added; 3) Rendering method replacement: Rendering based on signed distance field (SDF), rendering based on brush texture, or vector output (SVG / PDF) can be used; 4) Output channel expansion: In addition to line width, it can also predict transparency, ink density or brush tilt angle for richer ink stroke representation.

[0096] It should be understood that the above-mentioned optional embodiments are all within the protection scope of this invention.

[0097] As described in the above embodiments, this invention provides a variable linewidth generation and rendering method based on trajectory sequences. This method acquires a trajectory point sequence containing relative displacement and pen state markers, constructs a feature sequence including displacement, velocity, acceleration, turning point, pen position state, and positional context, and inputs it into a sequence neural network to predict the initial normalized linewidth at the point level. Subsequently, post-processing is performed on the initial linewidth to enhance continuity, naturalness, or conformity to a preset style, such as robust normalization, distribution modulation, temporal smoothing, and modulation based on velocity, turning angle, and endpoints, to obtain the final linewidth sequence. The linewidth is mapped to pixel width, and an image is generated by rendering the variable linewidth connected to polygons through sampling. This invention balances naturalness, stability, and controllability, and is suitable for scenarios such as font generation and handwriting simulation. This method has the following technical advantages: 1) Compared with the scheme that focuses on the expansion of the outer contour of the stroke, the present invention introduces point-level line width prediction and parameterized post-processing based on trajectory dynamics, which can generate a line width sequence that is more in line with writing habits and provide controllable adjustment. 2) Compared with recognition and modeling schemes that rely on pressure sampling signals, this invention can generate line widths and complete rendering outputs from general trajectory inputs without the need for pressure sampling signals; 3) Compared with fixed line width rendering, the present invention outputs point-level dynamic line width, which can express the changes in writing pressure and pen stroke shape; 4) Compared with pure rule-based solutions, this invention learns style trends through neural networks and suppresses jitter and outliers through post-processing, making the effect more stable and having stronger generalization. 5) Compared with the pure model solution, the present invention introduces interpretable operators such as quantile constraints, smoothing, corner enhancement, and stroke transition, making the output more controllable and easier to adjust in engineering, and achieving a more natural visual performance in key parts. 6) This invention supports general training and few-sample style adaptation, and can quickly transfer line width distribution between different writers / different pen styles to meet personalized needs.

[0098] XIII. System Structure and Operating Environment: This invention also provides a variable linewidth generation and rendering system, which can run on a server, personal computer, or mobile terminal. The system includes: a trajectory acquisition module, a feature construction module, a linewidth prediction module, a post-processing module, a rendering module, and a parameter configuration and management module, wherein: The trajectory acquisition module is used to receive or generate trajectory point sequences. The trajectory point sequences can come from online acquisition devices, trajectory generation networks (such as handwritten trajectory generation models), or external vector data.

[0099] The feature construction module is used to calculate the absolute coordinate sequence and construct the feature sequence based on the trajectory point sequence.

[0100] The linewidth prediction module has a sequence neural network internally deployed to receive the feature sequence and output an initial normalized linewidth value sequence.

[0101] The post-processing module is used to perform post-processing on the initial normalized linewidth value sequence to obtain the final normalized linewidth value sequence.

[0102] The rendering module maps the final normalized linewidth value sequence to pixel widths and generates an image by sampling and drawing variable linewidths connected to polygons. It can output grayscale images, PNGs with alpha channels, or a final image overlaid with a background.

[0103] Parameter configuration and management module: Used to manage post-processing and rendering parameters. In some optional implementations, parameter presets (such as "hard pen / soft pen / brush style preset", "emphasis on brushstroke preset", "smoothness priority preset", etc.) can be further saved and can be switched by task.

[0104] In some implementations, the system can support batch generation: input a set of trajectories (or character encoding sequences) and a set of style parameters, and automatically output the corresponding set of rendered images, which is suitable for font library generation, sample synthesis and data augmentation.

[0105] The system provided in this embodiment of the invention has the same implementation principle and technical effects as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the aforementioned method embodiment, and will not be repeated here.

[0106] Additionally, refer to Figure 10 As shown, this embodiment of the invention also provides an electronic device that can perform the above-described method. The electronic device may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and capable of running on the processor 10.

[0107] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits packaged with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 and calls data stored in the memory 11 to perform various functions of the electronic device and process data.

[0108] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, electronic devices, or computer program products, etc. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0109] It should be noted that the word "comprising" does not exclude the presence of components or steps not listed in the claims. The words "a" or "an" preceding a component do not exclude the presence of a plurality of such components. This invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer.

[0110] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0111] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for generating and rendering variable linewidths based on trajectory sequences, characterized in that, The method includes the following steps: Obtain a trajectory point sequence, which includes the relative displacement components of each step and pen state markers; Calculate the absolute coordinate sequence based on the trajectory point sequence, and construct a feature vector for each trajectory point to form a feature sequence; The feature sequence is input into a sequence neural network, which outputs the initial normalized linewidth value sequence for each trajectory point. Post-processing is performed on the initial normalized linewidth value sequence to obtain the final normalized linewidth value sequence; wherein, the post-processing includes, but is not limited to, one or more of the following: robust quantile normalization, distributed modulation, temporal smoothing, velocity-pressure modulation, corner enhancement, and start-end stroke gradation; The final normalized linewidth value sequence is mapped to pixel linewidth, and an image is generated by sampling and drawing variable linewidths connected to polygons.

2. The method according to claim 1, characterized in that, The constructed feature vector includes: relative displacement, velocity magnitude, acceleration magnitude, turning point, pen stroke state, and normalized coordinates of horizontal position.

3. The method according to claim 1, characterized in that, The sequence neural network is a bidirectional long short-term memory network, and its output is regressed by a multilayer perceptron and constrained to a preset range by a sigmoid activation function.

4. The method according to claim 1, characterized in that, The robust quantile normalization specifically includes: calculating the first and second quantiles of the initial normalized linewidth value sequence, and then pruning and linearly scaling out values ​​that exceed the range to a preset interval.

5. The method according to claim 1, characterized in that, The distribution modulation specifically includes: performing gamma modulation and contrast adjustment on the normalized line width value to make the line width distribution match the dynamic range of the target writing style.

6. The method according to claim 1, characterized in that, The time-series smoothing specifically includes: performing one-dimensional smoothing filtering on the linewidth value sequence to suppress local jitter and enhance time-series continuity.

7. The method according to claim 1, characterized in that, The speed-pressure modulation specifically includes: calculating the speed sequence by stroke segmentation, constructing a pressure factor negatively correlated with speed after quantile clipping and normalization of the speed sequence, and multiplying it with an adjustable intensity parameter to the line width value.

8. The method according to claim 1, characterized in that, The corner enhancement specifically includes: calculating the angle between adjacent vectors to obtain the corner; when the corner is greater than a preset threshold, multiplicatively enhancing the line width value; and smoothing the enhanced local line width sequence.

9. The method according to claim 1, characterized in that, The starting and ending stroke gradient specifically includes: for each stroke, selecting point segments at its starting and ending ends according to a preset length ratio, and applying a multiplicative enhancement curve and a multiplicative decay curve respectively.

10. A variable linewidth generation and rendering system based on trajectory sequences, characterized in that, The system comprises: generating an image by performing variable linewidth rendering using the method described in any one of claims 1-9. The trajectory acquisition module is used to acquire a sequence of trajectory points; The feature construction module is used to calculate the absolute coordinate sequence and construct the feature sequence based on the trajectory point sequence; The linewidth prediction module has a sequence neural network internally deployed to receive the feature sequence and output an initial normalized linewidth value sequence. The post-processing module is used to perform post-processing on the initial normalized linewidth value sequence to obtain the final normalized linewidth value sequence. The rendering module is used to map the final normalized linewidth value sequence to pixel width and generate an image by sampling and drawing variable linewidths connected to polygons.