Stroke extraction method fusing template features
By using a residual backbone network with shared weights and an offset prediction network, semantic alignment and non-rigid deformation of handwritten characters and template features are achieved, solving the problem of incomplete stroke extraction in existing technologies and ensuring the preservation of stroke edges and texture details. This method is suitable for stroke extraction in complex writing scenarios.
Patent Information
- Application Number
- CN202511875832.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-03-20
AI Technical Summary
Existing technologies struggle to accurately extract stroke features when dealing with non-rigid topological deformations and multi-style handwritten Chinese characters. Especially in high-degree-of-freedom writing scenarios, the model cannot establish a pixel-level elastic mapping relationship between the micro-texture of the handwritten character and the standard template, making it difficult to extract the integrity of the strokes.
A residual backbone network with shared weights is used to extract handwritten and template feature tensors respectively. Semantic channel projection and element-level difference operations are performed through convolutional layers to generate differential feature tensors. An offset prediction network is used to generate a spatial offset field, which drives the template features to undergo non-rigid geometric deformation. Feature fusion is performed through a spatial gated weight map. Finally, a stroke segmentation mask is output through a cascaded detector.
It achieves high-fidelity stroke extraction in feature space, solves the problem of high-frequency phase information loss caused by traditional interpolation upsampling, ensures the preservation of stroke edge sharpness and texture details, can handle complex deformation and low signal-to-noise ratio regions, and outputs a complete stroke segmentation mask.
Smart Images

Figure CN121708601A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a stroke extraction method that integrates template features, belonging to the field of computer vision technology. Background Technology
[0002] Current Chinese character stroke extraction technologies are mostly based on fully convolutional neural networks or instance segmentation architectures. They utilize backbone networks to downsample step by step to obtain deep semantic features, and then use upsampling or deconvolution to restore spatial resolution and generate pixel-level segmentation masks. This approach relies on reducing spatial resolution to expand the receptive field, using deep networks to identify stroke category attributes, and then using interpolation algorithms to map low-resolution features back to the original size.
[0003] In calligraphy teaching or the digitization of ancient books, handwritten Chinese characters exhibit non-rigid topological deformation and multi-style characteristics, containing high-frequency micro-structures such as fine lines and dry brushstrokes. Conventional linear interpolation upsampling is essentially a low-pass filter, which cannot restore the high-frequency phase information lost during downsampling. This causes topological breaks or edge blurring in the reconstruction of fine strokes. In addition to the inherent defects of the basic sampling reconstruction mechanism, existing technologies that utilize multi-dimensional features for enhancement have limitations. For example, the Chinese invention patent with publication number CN116994255A discloses a multi-level deep feature fusion stroke extraction method. Although it integrates visual temporal and spatial features to enhance stroke representation capabilities, its core logic still focuses on the extraction and linear splicing of handwritten character features, lacking explicit spatial correction for the topological structure of standard characters. Quasi-mechanisms, when faced with high-degree-of-freedom writing scenarios such as cursive script, struggle to establish pixel-level elastic mapping relationships between the micro-texture of handwritten characters and standard templates. They also struggle to handle severely deformed or discontinuous ink areas, leading to feature semantic alignment deviations due to the model's inability to accurately infer missing topological connections. This makes it difficult to solve the challenge of extracting stroke integrity under complex conditions. While industry attempts have attempted to introduce standard Chinese character templates as prior information, many employ a rigid fusion strategy that directly splices template features with handwritten features. However, because handwritten characters exhibit local geometric distortions relative to standard templates, direct splicing results in semantic misalignment of handwritten and template stroke features at the same coordinate position in the feature map. This spatial misalignment fails to fully utilize the template's guiding role, introduces background noise, and causes the model to consume channel resources, resulting in fitting mismatches.
[0004] Therefore, constructing a stroke extraction scheme that preserves high-frequency detail information within the feature space and achieves adaptive elastic alignment of standard template features with non-rigid handwritten features is the technical problem to be solved by this invention. Summary of the Invention
[0005] To address the problems raised in the background art, the technical solution of the present invention is as follows: A stroke extraction method integrating template features, the method comprising: The handwritten Chinese character image to be tested and the standard Chinese character template image are obtained. The handwritten feature tensor and the template feature tensor are extracted respectively using a residual backbone network with shared weights. By using convolutional layers, the handwritten feature tensor and the template feature tensor are projected onto the same semantic channel dimension and element-level difference operations are performed to generate a difference feature tensor representing the misaligned distribution of semantic space. A spatial offset prediction network is driven by the differential feature tensor as input, and regression is used to generate a spatial offset field containing the horizontal and vertical sub-pixel displacement vectors of each feature point in the template feature tensor. Bilinear interpolation resampling is performed on the template feature tensor based on the spatial offset field. By performing non-rigid geometric deformation on the template feature tensor in the feature space, a calibration template feature that is topologically aligned with the handwritten feature tensor is generated. A spatially gated weight map representing the importance of feature points is calculated. The spatially gated weight map is used to weight and adjust the calibration template features and merge them with the handwritten feature tensor execution channel to generate enhanced hybrid features. Candidate regions are generated based on enhanced hybrid features, and stroke segmentation masks and bounding boxes are output through cascaded detectors.
[0006] Preferably, the steps for generating the handwritten feature tensor include a subpixel feature reconstruction process, obtaining a low-resolution feature map output by the residual backbone network, performing an upsampling operation on the low-resolution feature map using a subpixel convolution operator, rearranging the depth information of the low-resolution feature map in the channel dimension and mapping it to the planar information in the spatial dimension through a periodic filtering mechanism, thereby increasing the spatial resolution of the low-resolution feature map to a preset multiple, and smoothing the rearranged feature map using convolutional layers to eliminate checkerboard artifacts, thereby generating a high-resolution handwritten feature tensor containing high-frequency texture details.
[0007] Preferably, the offset prediction network includes cascaded feature extraction layers and regression layers. The regression generates a spatial offset field containing the horizontal and vertical sub-pixel displacement vectors of each feature point in the template feature tensor. This includes: extracting local gradient features of the differential feature tensor using a first convolutional layer and enhancing the semantic expressive power of the local gradient features through a nonlinear activation function; mapping the local gradient features into an output tensor with two channels using a second convolutional layer, where the two channels of the output tensor correspond to the displacement components in the X-axis and Y-axis directions in the pixel coordinate system, respectively; and applying initialization constraints to the output tensor to restrict the numerical distribution of the spatial offset field to approach zero during the initial training phase.
[0008] Preferably, the spatial gating weight map for calculating the importance of feature points includes: concatenating the calibration template features and the handwritten feature tensor in the channel dimension to form a combined feature map; using a convolution kernel to perform dimensionality reduction and aggregation on the combined feature map to extract features that reflect the local correlation between the calibration template features and the handwritten feature tensor after alignment; and using the Sigmoid activation function to map the feature values to the interval between 0 and 1 to generate the spatial gating weight map.
[0009] Preferably, the calibration template features are weighted and adjusted using a spatial gating weight map and then fused with the handwritten character feature tensor execution channel, following the following operational rules: ,in, For enhanced hybrid features, For handwritten character feature tensor, For spatial gating weight graph, To calibrate template features, This is an element-wise multiplication operation.
[0010] Preferably, generating candidate regions based on enhanced hybrid features includes: using a region proposal network to slide anchor boxes of a preset proportion on the enhanced hybrid features, and calculating the foreground confidence score of each anchor box; performing non-maximum suppression processing on anchor boxes whose foreground confidence scores exceed a preset threshold, and filtering out redundant boxes whose overlap exceeds the threshold; extracting the corresponding region features on the enhanced hybrid features according to the retained anchor boxes, and using a region of interest alignment layer to uniformly adjust the region features into a feature map of a fixed size.
[0011] Preferably, the stroke segmentation mask and bounding box are output through a cascaded detector, including: constructing a cascaded architecture containing multiple sequential detection stages, each detection stage containing an independent classifier and regressor; in the first detection stage, setting a first intersection-union threshold, using the classifier and regressor to perform preliminary screening and coordinate correction of candidate regions, and outputting the first-stage detection box; in subsequent detection stages, receiving the first-stage detection box output from the previous stage as input samples, setting a second intersection-union threshold higher than the first intersection-union threshold, and using the corresponding classifier and regressor to finely adjust the first-stage detection box.
[0012] Preferably, the method further includes constructing a multi-task joint loss function to optimize network parameters; defining a classification loss function to measure the accuracy of stroke category prediction; defining a bounding box regression loss function to measure the accuracy of stroke bounding box localization; defining a mask segmentation loss function to measure pixel-level stroke classification accuracy; calculating the weighted sum of the classification loss function, bounding box regression loss function, and mask segmentation loss function; and updating the weight parameters of the residual backbone network, offset prediction network, and cascaded detector through the backpropagation algorithm.
[0013] Preferably, the process involves acquiring the handwritten Chinese character image to be tested and the standard Chinese character template image, including data augmentation processing: performing a random rotation operation on the original handwritten Chinese character image with the rotation angle limited to a preset range; performing Gaussian blur processing on the original handwritten Chinese character image to simulate ink diffusion; and inputting the image after random rotation and Gaussian blur processing as a training sample into the network.
[0014] Preferably, after outputting the stroke segmentation mask and bounding box, the method further includes: parsing the geometric features of the stroke segmentation mask, calculating the curvature distribution and aspect ratio parameters of the strokes; comparing the geometric features with preset standard evaluation indicators to generate objective quantitative evaluation data for the handwritten Chinese character image to be tested.
[0015] Compared with the prior art, the beneficial effects of the present invention are: 1. In the stroke extraction of fusion template features, a sub-pixel fusion channel is constructed in the horizontal connection of the feature pyramid. Sub-pixel convolution is used to rearrange and map the channel-dimensional data of the deep feature map into spatial-dimensional pixels, establishing a high-fidelity feature reconstruction space. This avoids the loss of high-frequency phase information caused by the neighborhood averaging calculation in traditional interpolation upsampling, and preserves the edge sharpness and texture details of handwritten strokes. Standard Chinese character template features are introduced as semantic anchors on the basis of the feature space. The complete topological structure of the standard template is used to logically constrain and correct the edges of the handwritten features after sub-pixel reconstruction. Sub-pixel convolution provides high-frequency details and provides clear physical boundaries for accurate matching of template features. The topological prior of the standard template provides semantic filling basis for the blurred areas of sub-pixel features. This enables the detection network to output a complete stroke segmentation mask based on the inherent topological continuity of the features when processing low signal-to-noise ratio areas such as dry strokes, flying white strokes, or stroke adhesion. This solves the technical problem that small target strokes cannot be separated from the background after multiple downsampling.
[0016] 2. Construct an alignment path for deformation-aware features based on difference maps, calculate the semantic difference field between handwritten features and template features, and generate a spatial offset field containing horizontal and vertical displacement vectors based on the difference field regression. Drive the standard template features to undergo pixel-level elastic resampling and distortion in the feature space, so that the stroke trend dynamically approximates the actual distribution of handwritten features geometrically. Eliminate spatial misalignment between modalities before feature fusion, accurately map the standard template texture features to the corresponding coordinate positions of the handwritten characters, and decouple the handwritten style differences from the semantic structure of the strokes through dynamic calibration. Ensure that the convolution kernel focuses on recognizing the texture features of the strokes themselves, without consuming computing power to fit spatial mismatch and generate noise, and achieve generalized segmentation of large-scale deformed fonts such as cursive and clerical scripts without increasing the diversity of labeled samples.
[0017] 3. A coarse-to-fine feature selection mechanism is established by combining a feature pyramid network and a cascade detector. The feature pyramid integrates deep features rich in semantics with shallow features containing fine positional information at multiple scales, and maintains the spatial resolution of each level of features through sub-pixel modules. The cascade detector uses a progressively increasing cross-union threshold to perform multi-stage regression on candidate regions. The high-quality regression box output of the previous stage is used as the input sampling benchmark for the next stage, so that the distribution of input samples tilts towards a high proportion of positive samples as the detection progresses. This dynamically suppresses the interference of background noise on stroke edge determination, ensuring that the deep network focuses on semantic consistency while using shallow features to accurately define the start and end positions of strokes and edge contours, thus ensuring the dual reliability of the geometric accuracy and semantic category of the final output stroke mask. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the overall process architecture of stroke extraction for the sub-pixel fusion and deformation alignment mechanism of this invention. Figure 2 This is a bar chart comparing the performance of the proposed solution and the control group in stroke segmentation and detection accuracy. Figure 3 This is a diagram illustrating the system application deployment and data flow of the integrated optical acquisition and intelligent computing center of this invention. Detailed Implementation
[0019] To enable those skilled in the art to better understand the present invention, the technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0020] A stroke extraction method integrating template features receives a handwritten Chinese character image to be tested and a corresponding standard Chinese character template image through a preprocessing module, and adjusts them to a preset input size, which is set to [size missing] in this embodiment. For each pixel, a ResNet101 residual backbone network with shared weights is used to perform multi-level feature extraction on the two images, generating corresponding feature pyramids. In the feature fusion stage, an integrated sub-pixel fusion module, namely the SPF module, and a template-induced deformation-aware feature alignment mechanism, namely the T-DFA mechanism, are used to achieve semantic alignment and complementary enhancement of handwritten features and template features at sub-pixel precision. The enhanced feature tensor is fed into the Region Proposal Network (RPN) to generate candidate regions. Finally, the stroke extraction results containing accurate bounding boxes and pixel-level segmentation masks are output through the Cascade R-CNN cascaded detector. To address the technical problem of high-frequency detail loss caused by traditional interpolation upsampling, this method deploys an SPF module in the lateral connection path of the feature pyramid network. This module uses a sub-pixel convolution operator to perform upsampling operations for images with a number of channels. Spatial resolution is The low-resolution feature map is processed by sub-pixel convolution, which uses a periodic filtering mechanism to rearrange the depth information in the channel dimension and map it to the spatial plane, directly generating a channel number of... Spatial resolution is High-resolution feature maps, in which The upsampling factor is set to 2 in this embodiment. This operation establishes a feature reconstruction space, preserves the phase information and texture sharpness of the handwritten stroke edges, and ensures that the subsequent detection network can accurately define the start and end contours of the strokes based on the preserved high-frequency features.
[0021] Given the nonlinear geometric deformation of handwritten Chinese characters relative to a standard template, this method constructs a T-DFA mechanism to drive non-rigid deformation of the standard template within the feature space to achieve topological alignment with the handwritten character features. This mechanism obtains the handwritten character feature tensor processed by the SPF module. Compared with the standard template feature tensor extracted through the same backbone network Through shared weights The convolutional layer projects both onto the same semantic channel dimension, which is 256 channels in this embodiment, and performs element-wise subtraction to generate a semantic difference tensor. The difference tensor This method represents the semantic distance distribution of handwritten stroke features relative to standard template features at the current feature map grid points. After projecting the handwritten feature tensor and template feature tensor to the same semantic channel dimension using convolutional layers, and before performing element-wise difference operations, instance normalization is performed on both feature tensors. The mean and variance of pixel intensity in the current feature map spatial dimension are calculated, and the feature pixel values are standardized and mapped to a normal distribution space with a mean of 0 and a variance of 1. Backpropagation during training updates the affine transformation parameters, linearly rescaling the standardized features to preserve the semantic topological structure of the strokes and eliminate unstructured background noise introduced by differences in grayscale response of the input image within the feature channel. This allows the generated difference feature tensor to represent the misaligned distribution of the handwritten strokes and template geometric topology in the spatial dimension. Based on the generated semantic difference tensor... The system uses a lightweight offset prediction network to regress and generate a spatial offset field. The prediction network consists of two cascaded layers. The convolutional layer is composed of a ReLU activation function, and the output tensor has a dimension of . The two values of the channel dimension correspond to the displacement components in the X-axis direction of the pixel coordinate system. displacement components in the Y-axis direction The displacement component is a floating-point number, representing the displacement vector that should occur when aligning the template features to the handwritten features, and the sampling points on the standard template feature map. In the initial training phase, the initial offset is made close to zero by initializing the weights of the last layer of the prediction network to zero, ensuring that the network gradually learns non-rigid deformation features from a rigid matching state.
[0022] Spatial offset field obtained by regression The system uses standard template features Perform differentiable bilinear interpolation resampling; specifically, for each integer coordinate position on the output feature map... According to the formula Calculate non-integer sampled coordinates The pixel value at that coordinate is calculated using a bilinear interpolation algorithm to generate a calibrated template feature. This process drives the geometric distortion of the stroke features of standard Chinese characters in the feature space, making the stroke orientation approximate the actual distribution of handwritten characters in terms of topological structure, thereby eliminating spatial misalignment during feature fusion; for enhanced hybrid features The tensor operation logic involved in the generation process needs to be explicitly specified in the construction of the spatial gating weight graph. At that time, the system utilizes a convolution kernel size of The dimension reduction projection layer reduces the channel dimension to... The combined feature map is compressed into a single-channel effective feature tensor, which is then used to generate a weight map after Sigmoid activation. Limited in physical dimension And then in executing the formula When defining element-wise multiplication operations, the weight graph Based on the tensor broadcast mechanism, it automatically extends along the channel axis to the features of the calibration template. Exact match The system calculates a spatially gated weight map representing the importance of feature points to further optimize feature fusion quality and filter out background noise that may be introduced during alignment. This ensures independent weighting and semantic enhancement for each pixel location within the feature space. Features of original handwriting The features are concatenated along the channel dimension to form a combined feature map, which is then utilized... The convolutional kernel performs dimensionality reduction and aggregation on the combined feature maps, and uses the Sigmoid activation function to map the values to the interval between 0 and 1, generating a spatially gated weight map. The final enhanced hybrid features Follow the rules of operation ,in This represents element-wise multiplication. Through this gated fusion mechanism, the model adaptively utilizes aligned template features to repair blurred or missing areas in handwriting, improving stroke integrity under complex conditions such as cursive and dry strokes.
[0023] Based on enhanced hybrid features The RPN slides anchor boxes at a predetermined ratio on the feature map, calculates the foreground confidence score for each anchor box, and uses non-maximum suppression to filter out redundant boxes with overlap exceeding a threshold. The remaining candidate regions are fed into a cascaded detector, which is a cascaded architecture containing three sequential detection stages. Each detection stage includes an independent classifier and regressor. In the first detection stage, a first intersection-union threshold of 0.5 is set to initially screen and correct the coordinates of candidate regions. Subsequent stages gradually increase the intersection-union threshold, for example, setting it to 0.6 and 0.7 respectively, and receive the detection boxes output from the previous stage as input. The samples are finely adjusted; this strategy of gradually increasing the threshold suppresses the interference of background noise on stroke edge determination, ensuring that the final output stroke segmentation mask achieves high confidence standards in both geometric accuracy and semantic category. To optimize the weight parameters of the above network, this method constructs a multi-task joint loss function including classification loss, bounding box regression loss, and mask segmentation loss, and trains the residual backbone network, offset prediction network, and cascaded detector end-to-end through the backpropagation algorithm. In terms of training data processing, the rotation angle of the handwritten Chinese character image to be tested is limited to a preset range, such as... Random rotation operations and Gaussian blur processing simulating ink diffusion are used to enhance the model's generalization adaptability to different writing styles and image qualities. The weight coefficients of each component in the multi-task joint loss function are determined using a dynamic balancing procedure based on gradient magnitude alignment, and the total loss function is set. Classification loss Bounding box regression loss and mask segmentation loss In the initial stage of network training, the weight coefficients of each component are set to a baseline value of 1.0. During the first five training cycles, the moving average magnitude of the loss value of each branch is monitored. When the average loss value of a certain branch is found to be more than 10 times higher than that of other branches, the weight coefficient of this branch is automatically adjusted to the reciprocal of the order of magnitude difference, i.e., 0.1. This forces the gradient contributions of each task branch during backpropagation to be of the same magnitude, maintaining the stability of the network parameter update values. The stroke segmentation mask and bounding box output are further used to analyze the geometric morphological features of the strokes, calculate the curvature distribution and aspect ratio parameters of the strokes, and compare these features with the preset standard evaluation indicators to generate objective quantitative evaluation data for the handwritten Chinese character.
[0024] Example 1: In industrial applications for high-precision calligraphy teaching evaluation, when processing images of handwritten Chinese characters in cursive script containing features such as dry brushstrokes, flying white strokes, and connected strokes, especially considering the discontinuous ink marks and geometric distortions caused by rapid brushstrokes, conventional linear interpolation upsampling suffers from high-frequency phase information loss due to inherent low-pass filtering effects, causing the weak ink mark signals in the dry brush area to become blurred or disappear in the feature space. To solve this problem, the present invention utilizes the sub-pixel convolution operator of the SPF module to perform upsampling. By periodically rearranging the channel depth information of the features extracted by the ResNet101 backbone network to the spatial plane, the handwritten features are preserved in the feature reconstruction space. The sharpness of the texture and phase detail at the edges of the dry brushstrokes, a high-fidelity handwriting feature. As a key anchoring reference, it is consistent with standard template features. They are all projected onto the same semantic space to compute the semantic difference tensor. The difference tensor The driving offset prediction network regresses the lateral components containing each feature point. With longitudinal component Spatial offset field Based on this offset field For standard template features Bilinear interpolation resampling is performed to drive the stroke topology of standard Chinese characters to undergo adaptive elastic distortion in the feature space, generating calibration template features that are geometrically aligned with the actual stroke flow of the handwritten characters. Calibration template features Leveraging its inherent complete topological prior, semantic completion is performed on the discontinuous handwritten signal preserved by the SPF module. Finally, the stroke segmentation mask is output by the Cascade R-CNN cascade detector. This mask fits the non-rigid twisted boundary of the handwritten character in terms of geometry and repairs the physical breaks caused by the dry strokes in terms of topological structure.
[0025] Example 2: This example aims to quantitatively verify the actual performance and stability of the proposed sub-pixel-level feature reconstruction and deformation-aware alignment synergy mechanism in handling complex handwritten Chinese character stroke extraction tasks by constructing a rigorously controlled comparative experimental system, and to demonstrate the synergistic effect between core technical features. The experimental platform is built on a high-performance computing workstation equipped with an NVIDIA RTX 4090 graphics processing unit to support large-scale parallel tensor operations. The software environment adopts the PyTorch deep learning framework. The publicly available CASIA-HWDB handwritten Chinese character database is selected as the basic data source, and an enhanced stress test set containing natural noise and artificial perturbation is constructed on this basis. This test set specifically introduces a blurred subset simulating a low-resolution scanning device (through Gaussian kernel). The experiment involved convolution processing and a noise subset of simulated ancient book fragments (with salt-and-pepper noise superimposed at a signal-to-noise ratio of 15dB) to realistically simulate non-ideal input conditions that may be encountered in real industrial applications. The core evaluation metrics of the experiment were selected as the pixel-level intersection-union ratio (mIoU) and the average accuracy of the bounding box (AP@0.5:0.95). To eliminate random interference, all experimental results were based on the average value after running the experiment 5 times on the test set.
[0026] To systematically demonstrate the non-obviousness and synergistic effect of the technical solution of this invention, the following comparative experimental groups with gradient changes were designed: Control Group A (Baseline): The standard Mask R-CNN architecture was adopted, and its feature upsampling stage used the conventional bilinear interpolation algorithm without introducing standard template features as prior guidance. This group aims to establish the performance benchmark of existing general technologies; Experimental Group B (SPF module only): Based on Control Group A, the bilinear interpolation upsampling was replaced with the sub-pixel fusion module (SPF) of this invention, and the sub-pixel convolution operator was used for feature reconstruction, but template features were not introduced. This group aims to verify the sub-pixel feature reconstruction separately. The ability to preserve high-frequency details; Experimental group C (SPF + rigid template splicing): Based on experimental group B, standard Chinese character template features are introduced, but the fusion is performed using a direct channel splicing (concatenation) method, that is, without the T-DFA deformation alignment mechanism of the present invention. This group aims to verify the performance when template information is introduced but spatial alignment mechanism is lacking, and to reveal the actual impact of semantic-spatial mismatch; Sample group D of the present invention (complete scheme): Integrates SPF module and T-DFA mechanism, uses the spatial offset field of offset prediction network regression to perform non-rigid resampling of template features, and then performs gated fusion with sub-pixel handwritten features.
[0027] The experimental records show that control group A performed reasonably well when processing regular strokes, but when dealing with dry brush or flying white features, due to the low-pass filtering characteristics of bilinear interpolation, weak ink pixels were over-smoothed in the feature map, resulting in broken stroke masks in the output. After introducing the SPF module, experimental group B showed improved response intensity in the high-frequency region of the feature map, preserved the texture sharpness of dry brush edges, and improved the mIoU index by approximately 4.2% compared to control group A, demonstrating the advantage of sub-pixel convolution in detail fidelity. However, when processing samples with severe ligatures or structural adhesion, texture features alone were still insufficient to distinguish stroke boundaries. After introducing a rigid template, experimental group C showed improved data output... Contrary to expectations, the accuracy improved slightly on some samples with standard writing, but on samples with large deformations, such as cursive script, the mIoU index was even lower than that of experimental group B. In-depth analysis of the intermediate feature map revealed that due to the nonlinear spatial misalignment between the handwriting and the template, direct splicing resulted in semantic conflicts between the handwritten strokes and the template background at the same coordinate point on the feature map. This noise interfered with the detector's judgment. Sample group D of this invention showed a decisive performance leap. After the T-DFA mechanism was introduced, the visualized feature difference map showed that the calibrated template features and handwritten features achieved a high degree of spatial overlap. The final test results are shown in Table 1 below.
[0028] Table 1: Performance Comparison of Different Test Groups on Enhanced Pressure Test Set
[0029] Referring to Table 1, the mIoU of sample group D in this invention reached 84.6%, an improvement of 16.3 percentage points compared to control group A. Furthermore, the rate of broken strokes dropped sharply from 28.5% to 3.4%. More importantly, comparing the data of experimental group C and sample group D (71.8% vs 84.6%) clearly demonstrates that the T-DFA mechanism is not merely an added bonus, but a key enabling technology that determines whether template features can truly function. It successfully eliminates spatial misalignment between modalities, allowing the topological prior of the standard template to accurately flow to the incomplete areas of the handwritten character, achieving deep synergy between feature fidelity and structure guidance. In addition, to verify the impact of convolutional kernel size on performance in the offset prediction network, hyperparameter sensitivity analysis was conducted. The results show that when the convolutional kernel size is set to... At this time, the model achieves the optimal balance between capturing local deformation details and computational efficiency; too small a convolution kernel ( The inability to effectively extract neighborhood gradient information leads to a decrease in alignment accuracy (mIoU drops to 78.2%), while excessively large convolutional kernels ( This introduces unnecessary computational overhead and does not bring any accuracy gain (mIoU is 84.7%, and inference time increases by 15%). In summary, the experimental data of this embodiment objectively proves that the high-fidelity feature space constructed by the SPF module and the dynamic topology alignment implemented by the T-DFA mechanism are logically mutually supportive and together constitute a stable feature extraction architecture that can effectively cope with the deformation and degradation of complex handwritten Chinese characters.
[0030] Example 3: This example combines Figures 1 to 3 This section describes a stroke extraction method that integrates template features, such as... Figure 1 As shown, the overall process of this stroke extraction method based on fused template features is as follows: The input end acquires a handwritten Chinese character image containing random rotation and Gaussian blur enhancement, and a standard Chinese character template image providing a priori standard topology. A ResNet101 residual backbone network with shared weights is used to extract handwritten feature tensors and template feature tensors respectively. The handwritten feature tensor is input to a sub-pixel fusion module (SPF) to perform sub-pixel convolution, eliminate artifacts, and preserve high-frequency details. Simultaneously, semantic projection and difference operations are used to project the handwritten feature tensor and template feature tensor onto the same channel to generate a difference feature tensor. This difference feature tensor drives an offset prediction network to regress and generate a feature tensor containing... and The spatial offset field drives non-rigid bilinear resampling of the template feature tensor to achieve geometric deformation and topological alignment in the feature space and generate calibration template features. Features are extracted through the spatial gated weight map calculation module and generated by Sigmoid activation. The calibration template features and SPF-processed handwritten features are combined in the channel fusion module Mix to generate enhanced hybrid features. Finally, the hybrid features are input into the Region Proposal Network (RPN) to generate candidate regions containing foreground confidence scores. The output of stroke segmentation masks and bounding boxes containing geometric morphological feature parsing is obtained through a cascade detector (Cascade R-CNN) that includes multi-stage IoU threshold enhancement and fine-tuning.
[0031] like Figure 2 As shown, the bar chart compares performance indicators under different experimental settings. The vertical axis represents percentages (%), and the legend above distinguishes between the stroke pixel-level intersection-over-union ratio and the average bounding box accuracy. The horizontal axis sequentially lists the four experimental subjects: control group A, experimental group B, experimental group C, and the present invention's sample group D. The chart shows that the present invention's sample group D has significantly higher values for both the stroke pixel-level intersection-over-union ratio and the average bounding box accuracy than control group A, experimental group B, and group C. Figure 3 As shown, the application architecture includes an optical acquisition terminal for acquiring raw handwritten image streams and transmitting them to the intelligent stroke computing center, i.e., the core workstation. At the same time, the standard resource library provides support to the computing center through template feature indexing. The intelligent stroke computing center deploys a deformation alignment and fusion engine and a cascaded detection service. After processing by the core workstation, the stroke mask and analysis data are output, and finally the data is transmitted to the interactive evaluation terminal for subsequent applications.
[0032] Example 4: This example aims to deeply verify the impact of the key design parameter, convolution kernel size, on the accuracy and computational efficiency of stroke deformation capture in the offset prediction network through quantitative hyperparameter sensitivity analysis. It establishes the optimal parameter configuration procedure by systematically adjusting the convolution kernel size while keeping other network structures unchanged, revealing the intrinsic relationship between it and model alignment performance. Based on the aforementioned enhanced stress test set, a set of handwritten Chinese character samples containing typical deformation features such as turns, intersections, and breaks are selected as verification objects. Four variants of the offset prediction network are constructed, with varying convolution kernel sizes. Set as , , and For each variant, end-to-end training was performed under the same hyperparameter settings, with a focus on monitoring two core metrics: the stroke segmentation intersection-union ratio (mIoU) on the validation set, which serves as an objective standard for measuring the final alignment accuracy; and the average inference latency per image, which serves as an indicator for evaluating the computational efficiency of the model.
[0033] Experimental results show that when the kernel size... Set as At that time, the mIoU metric was only 78.2%, and the visualized offset field showed a high-frequency noise distribution, indicating that the small receptive field could not effectively capture the neighborhood texture gradient, resulting in a lack of alignment consistency. Increase to At that time, mIoU jumped to 84.6%, and the offset field exhibited a smooth manifold characteristic highly consistent with the stroke trend, indicating that this size can effectively cover the typical local correlation domain of handwritten strokes in the feature space, achieving a sensitive response to edge deformation, and further... Increase to and At that time, although mIoU remained at a saturation level of around 84.7%, the average inference latency increased by 15% and 42% respectively, and the offset field began to show an excessive smoothing trend, weakening the ability to capture subtle stroke transitions. Based on this inverted U-shaped performance response curve and the comprehensive trade-off between computational efficiency, this invention determines... The optimal convolutional kernel size for this application scenario ensures high-precision feature alignment while maximizing the model's real-time processing capabilities.
[0034] Example 5: To avoid systematic errors in the calculation of differential feature tensors caused by font rendering differences or geometric centroid deviations in the standard Chinese character template library, and to establish a unified semantic benchmark, the system executes an offline standard template library construction and normalization procedure during the initialization phase. This procedure selects the standard KaiTi font library as the source data and uses a vector rasterization engine to render it to a resolution of [resolution missing]. The grayscale bitmap is used to calculate the geometric center of the character using a moment-based centroid alignment algorithm and translate the image to the center of the field of view to eliminate the global translation component. The stroke width is then standardized using morphological opening and closing operations to limit the variance of the stroke pixel width to a preset engineering threshold. Finally, a set of standard template feature tensors with high consistency in both geometric position and texture scale is generated as the absolute physical reference anchor for subsequent feature alignment using the T-DFA mechanism.
[0035] To address the engineering challenge of inconsistent grayscale distributions in input images due to differences in lighting conditions or sensor photosensitive characteristics among different handwriting acquisition terminals, which in turn affects the stability of feature extraction, an input domain adaptive calibration procedure is executed before on-site model deployment. This procedure statistically analyzes the pixel grayscale histogram of the handwritten Chinese character image to be tested and calculates its cumulative distribution function. Using a histogram specification algorithm, the grayscale distribution of the image to be tested is nonlinearly mapped to the statistical distribution domain of the standard template image. This eliminates unstructured background noise and contrast differences between modalities at the pixel level, ensuring that the handwritten character feature tensor of the input residual backbone network is consistent with the template feature tensor in terms of energy distribution. This prevents the offset prediction network from generating erroneous displacement vector regressions due to signal-to-noise ratio fluctuations and ensures the stability of the system under different hardware environments.
[0036] Example 6: To ensure the stability and reproducibility of feature extraction in actual industrial applications with different lighting, resolution, and noise levels, a standardized input data calibration and parameter initialization procedure needs to be performed before system deployment. Based on the lighting distribution of the environment to be deployed and the sensor characteristics of the acquisition equipment, a set of no fewer than 100 blank background handwritten paper images is collected. The statistical mean and variance of pixel grayscale are calculated, and the baseline parameters for brightness adjustment in the preprocessing module are set to ensure that the background grayscale mean of the input image is normalized to a preset intensity range. For the initialization of the offset prediction network in the T-DFA mechanism, a micro-perturbation cold start strategy is adopted. In the initial training phase, the weights of the last convolutional kernel of the offset prediction network are initialized to a mean of 0 and a standard deviation of 0. The Gaussian distribution is used, with all bias terms set to 0, to ensure the initial spatial offset field is generated correctly. Approaching a zero vector field, this strategy aims to degenerate the network into a rigid alignment pattern in the early stages of training, avoiding the collapse of the spatial structure caused by large initial random offsets, and gradually learning subtle local deformation features as training iterations progress.
[0037] Finally, to verify the system's stability under extreme conditions, a full-link stress test procedure was executed. This procedure continuously inputs a set of artificially synthesized test image sequences with superimposed Gaussian white noise and random perspective transformation at a signal-to-noise ratio of 10dB into the system and runs it continuously for no less than 24 hours. During the continuous operation, the peak fluctuation of the GPU memory usage rate is monitored to be no more than 5%, and the average intersection-union ratio (mIoU) of the stroke extraction is controlled within 1%. This is used as the pass standard for the system to be allowed to go online.
[0038] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0039] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A stroke extraction method integrating template features, characterized in that, The method includes: The handwritten Chinese character image to be tested and the standard Chinese character template image are obtained. The handwritten feature tensor and the template feature tensor are extracted respectively using a residual backbone network with shared weights. By using convolutional layers, the handwritten feature tensor and the template feature tensor are projected onto the same semantic channel dimension and element-level difference operations are performed to generate a difference feature tensor representing the misaligned distribution of semantic space. A spatial offset prediction network is driven by the differential feature tensor as input, and regression is used to generate a spatial offset field containing the horizontal and vertical sub-pixel displacement vectors of each feature point in the template feature tensor. Bilinear interpolation resampling is performed on the template feature tensor based on the spatial offset field. By performing non-rigid geometric deformation on the template feature tensor in the feature space, a calibration template feature that is topologically aligned with the handwritten feature tensor is generated. A spatially gated weight map representing the importance of feature points is calculated. The spatially gated weight map is used to weight and adjust the calibration template features and merge them with the handwritten feature tensor execution channel to generate enhanced hybrid features. Candidate regions are generated based on enhanced hybrid features, and stroke segmentation masks and bounding boxes are output through cascaded detectors.
2. The stroke extraction method based on fused template features according to claim 1, characterized in that, The steps for generating the handwritten feature tensor include a subpixel feature reconstruction process, obtaining a low-resolution feature map output by the residual backbone network, performing an upsampling operation on the low-resolution feature map using a subpixel convolution operator, rearranging the depth information of the low-resolution feature map in the channel dimension and mapping it to the planar information in the spatial dimension through a periodic filtering mechanism, thereby increasing the spatial resolution of the low-resolution feature map to a preset multiple, and using convolutional layers to smooth the rearranged feature map to eliminate checkerboard artifacts, generating a high-resolution handwritten feature tensor containing high-frequency texture details.
3. The stroke extraction method based on fused template features according to claim 1, characterized in that, The offset prediction network consists of cascaded feature extraction and regression layers. The regression generates a spatial offset field containing the horizontal and vertical sub-pixel displacement vectors of each feature point in the template feature tensor. This includes: extracting local gradient features of the differential feature tensor using a first convolutional layer and enhancing the semantic expressiveness of the local gradient features through a nonlinear activation function; mapping the local gradient features into a two-channel output tensor using a second convolutional layer, where the two channels of the output tensor correspond to the displacement components in the X-axis and Y-axis directions in the pixel coordinate system, respectively; and performing initialization constraints on the output tensor.
4. The stroke extraction method based on fused template features according to claim 1, characterized in that, The calculation of the spatial gating weight map representing the importance of feature points includes: concatenating the calibration template features and the handwritten feature tensor in the channel dimension to form a combined feature map; using convolution kernels to perform dimensionality reduction and aggregation on the combined feature map to extract features that reflect the local correlation between the calibration template features and the handwritten feature tensor after alignment; and using the Sigmoid activation function to map the feature values to the interval between 0 and 1 to generate the spatial gating weight map.
5. The stroke extraction method based on fused template features according to claim 4, characterized in that, The calibration template features are weighted and adjusted using a spatial gating weight map and then fused with the handwritten character feature tensor execution channel, following the following computational rules: ,in, For enhanced hybrid features, For handwritten character feature tensor, For spatial gating weight graph, This is for calibration template features.
6. The stroke extraction method based on fused template features according to claim 1, characterized in that, The method for generating candidate regions based on enhanced hybrid features includes: using a region proposal network to slide anchor boxes of a preset proportion on the enhanced hybrid features and calculating the foreground confidence score of each anchor box; performing non-maximum suppression processing on anchor boxes whose foreground confidence scores exceed a preset threshold to filter out redundant boxes with overlap exceeding the threshold; extracting the corresponding region features on the enhanced hybrid features based on the retained anchor boxes, and using a region of interest alignment layer to uniformly adjust the region features into a feature map of a fixed size.
7. The stroke extraction method based on fused template features according to claim 1, characterized in that, The method outputs stroke segmentation masks and bounding boxes through a cascaded detector, including: constructing a cascaded architecture containing multiple sequential detection stages, each of which contains an independent classifier and regressor; in the first detection stage, setting a first intersection-union threshold, using the classifier and regressor to perform preliminary screening and coordinate correction of candidate regions, and outputting the first-stage detection box; in subsequent detection stages, receiving the first-stage detection box output from the previous stage as input samples, setting a second intersection-union threshold higher than the first threshold, and using the corresponding classifier and regressor to fine-tune the first-stage detection box.
8. The stroke extraction method based on fused template features according to claim 1, characterized in that, The method also includes constructing a multi-task joint loss function to optimize network parameters, defining a classification loss function to measure the accuracy of stroke category prediction; defining a bounding box regression loss function to measure the accuracy of stroke bounding box localization; defining a mask segmentation loss function to measure pixel-level stroke classification accuracy; calculating the weighted sum of the classification loss function, bounding box regression loss function, and mask segmentation loss function, and updating the weight parameters of the residual backbone network, offset prediction network, and cascaded detector through the backpropagation algorithm.
9. The stroke extraction method based on fused template features according to claim 1, characterized in that, Acquire the handwritten Chinese character image to be tested and the standard Chinese character template image, including data augmentation processing: perform random rotation operation on the original handwritten Chinese character image with the rotation angle limited to a preset range; The original handwritten Chinese character image is subjected to Gaussian blur processing to simulate ink diffusion; the image after random rotation and Gaussian blur processing is used as a training sample input into the network.
10. The stroke extraction method based on fused template features according to claim 1, characterized in that, After outputting the stroke segmentation mask and bounding box, the process also includes: analyzing the geometric features of the stroke segmentation mask, calculating the curvature distribution and aspect ratio parameters of the strokes; comparing the geometric features with preset standard evaluation indicators to generate objective quantitative evaluation data for the handwritten Chinese character image to be tested.
Citation Information
Patent Citations
Stroke extraction method based on multi-level depth feature fusion
CN116994255A
