Hard pen kai script stroke quality evaluation method and system based on multi-dimensional feature fusion
Patent Information
- Application Number
- CN202611454249.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-18
- Publication Date
- 2026-10-23
AI Technical Summary
[0003]现有笔画评价方法主要存在以下问题:(1)评价指标单一,仅关注长度、角度等基础特征,未能充分反映笔画的形态、曲率、收笔等细节特点;(2)忽视不同笔画类型的书写特性差异,横、竖、撇、捺、点、提六类基本笔画具有各自独特的书写规范,但现有方法往往采用统一的评价标准;(3)各评价指标的误差数值量纲不同,难以进行横向对比和综合评价;(4)每次评分时都需要重复计算模板特征,计算效率低下
[0018]本发明针对不同笔画类型的书写特性构建差异化评价指标体系,横竖撇捺点提六类笔画各有专用指标,评价结果更符合书法教学规范和专家评判标准。
Smart Images

Figure CN122967290A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of character recognition technology, specifically relating to a method and system for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion. Background Technology
[0002] Regular script calligraphy with a pen is a fundamental component of calligraphy education for primary and secondary school students, and the quality of each stroke directly affects the aesthetics and standardization of the entire character. Traditional calligraphy teaching relies on manual evaluation by teachers, which is highly subjective and inefficient, making it difficult to meet the needs of large-scale personalized teaching. With the development of computer vision technology, automated stroke evaluation systems have gradually become a research hotspot.
[0003] The existing stroke evaluation methods have the following problems: (1) The evaluation indicators are singular, focusing only on basic features such as length and angle, and failing to fully reflect the details of stroke shape, curvature, and ending stroke; (2) They ignore the differences in writing characteristics of different stroke types. The six basic strokes of horizontal, vertical, left-falling, right-falling, dot, and rising strokes have their own unique writing norms, but the existing methods often adopt a unified evaluation standard; (3) The error values of each evaluation indicator are different, making it difficult to make horizontal comparisons and comprehensive evaluations; (4) The template features need to be repeatedly calculated each time a score is given, resulting in low calculation efficiency. Summary of the Invention
[0004] To address the aforementioned issues, this invention proposes a method and system for evaluating the quality of strokes in regular script calligraphy based on multi-dimensional feature fusion.
[0005] To achieve the above-mentioned technical objectives and effects, the present invention is implemented through the following technical solution:
[0006] In a first aspect, the present invention provides a method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion, including:
[0007] Obtain the binarized image and skeleton image of the stroke image to be evaluated;
[0008] An evaluation feature set is determined based on the stroke type of the target stroke in the stroke image to be evaluated. The evaluation feature set includes general evaluation features and special evaluation features corresponding to different stroke types.
[0009] Load the evaluation features of the template strokes corresponding to the target strokes in the image to be evaluated from the pre-built template feature sample library;
[0010] Based on the set of evaluation features, extract various evaluation features of the target stroke in the image of the stroke to be evaluated from the binarized image or skeleton image;
[0011] Based on the evaluation features of the template strokes and the evaluation features of the target strokes, the error of the evaluation features of the target strokes is calculated.
[0012] The error of each evaluation feature is standardized into a single score of 0-100 using a nonlinear mapping function;
[0013] The scores of each item are weighted and combined according to preset weights to obtain a comprehensive score and evaluation report.
[0014] Secondly, the present invention provides a quality evaluation system for hard-pen regular script strokes based on multi-dimensional feature fusion, including a storage medium and a processor;
[0015] The storage medium is used to store instructions;
[0016] The processor is configured to operate according to the instructions to perform the method according to any one of the first aspects.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0018] This invention constructs a differentiated evaluation index system based on the writing characteristics of different stroke types. Each of the six stroke types—horizontal, vertical, left-falling, right-falling, dot, and rising—has its own dedicated index, and the evaluation results are more in line with calligraphy teaching norms and expert judgment standards.
[0019] This invention introduces a multi-dimensional feature fusion mechanism, which comprehensively considers multiple features such as length, width, outer contour similarity, curvature, angle, position of the stroke, type of the ending stroke, degree of curvature, and fullness of form, to fully reflect the quality of the strokes and overcome the limitation of traditional methods with only one indicator.
[0020] In this invention, by scanning point by point and matching with the neighborhood, horizontal / vertical line segments and diagonal line segments are accurately distinguished, eliminating the influence of grid anisotropy on length measurement and more realistically reflecting the actual physical extension length of the stroke.
[0021] This invention uses a unified nonlinear mapping function to standardize various heterogeneous errors to a score of 0-100, ensuring horizontal comparability between different indicators, and producing similar scores for the same relative error, resulting in a fairer and more reasonable scoring result.
[0022] This invention improves scoring efficiency and supports large-scale real-time evaluation scenarios by pre-building a template feature sample library mechanism, where template features are directly loaded when the score is calculated only once.
[0023] This invention proposes a small hook detection mechanism that can automatically identify stroke writing defects. If a small hook is detected, it is an incorrect stroke and a score of 0 is returned directly, which effectively prevents incorrect writing from obtaining inflated scores and improves the robustness of the evaluation system.
[0024] The algorithm for determining the type of vertical stroke ending in this invention accurately distinguishes between two ending methods: hanging needle and drooping dew, based on the width sequence growth pattern and platform features, which meets the refined requirements for stroke ending standards in calligraphy teaching. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein:
[0026] Figure 1 This is a flowchart illustrating a method for evaluating the quality of strokes in regular script calligraphy based on multi-dimensional feature fusion, according to an embodiment of the present invention.
[0027] Figure 2 This is a schematic diagram of the width index extraction and scoring process according to an embodiment of the present invention;
[0028] Figure 3 This is one of the flowcharts for calculating the outer contour similarity according to an embodiment of the present invention;
[0029] Figure 4 This is a second flowchart of the outer contour similarity calculation according to an embodiment of the present invention;
[0030] Figure 5 This is a schematic diagram of a vertical stroke ending type determination algorithm according to an embodiment of the present invention;
[0031] Figure 6 This is a diagram showing the result of skeleton lengthening processing according to an embodiment of the present invention;
[0032] Figure 7 for Figure 6 Enlarged view of point A in the middle;
[0033] Figure 8 This is a diagram showing the results of existing skeleton extension methods.
[0034] Figure 9 for Figure 8 Enlarged diagram of point B in the middle. Detailed Implementation
[0035] 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 only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0036] Furthermore, if the embodiments of this invention involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by this invention.
[0037] Example 1
[0038] This invention provides a method for evaluating the quality of strokes in regular script calligraphy based on multi-dimensional feature fusion, such as... Figure 1 As shown, it includes the following steps:
[0039] (1) Obtain the binarized image and skeleton image of the stroke image to be evaluated;
[0040] (2) Determine the evaluation feature set based on the stroke type of the target stroke in the stroke image to be evaluated. The evaluation feature set includes general evaluation features and special evaluation features corresponding to different stroke types.
[0041] (3) Load the evaluation features of the template strokes corresponding to the target strokes in the image to be evaluated from the pre-constructed template feature sample library;
[0042] (4) Based on the set of evaluation features, extract the evaluation features of the target stroke in the image of the stroke to be evaluated from the binarized image or skeleton image;
[0043] (5) Based on the evaluation features of the template strokes and the evaluation features of the target strokes, calculate the error of the evaluation features of the target strokes;
[0044] (6) The error of each evaluation feature is standardized to a single score of 0-100 using a nonlinear mapping function;
[0045] (7) The scores of each item are weighted and integrated according to the preset weights to obtain a comprehensive score and evaluation report.
[0046] In one specific embodiment of the present invention, the method for evaluating the quality of strokes in regular script calligraphy further includes:
[0047] The skeleton image of the obtained stroke image to be evaluated is subjected to skeleton lengthening processing, which includes the following steps:
[0048] Find the pair of endpoints with the largest distance in the skeleton image, and perform a predetermined extension operation on both endpoints of the pair. The extension operation includes:
[0049] Repeat the following steps until... :
[0050] From the endpoint Start by finding the first neighboring point. From the first neighbor point Start by finding the second neighboring point. The second neighboring point Endpoint For points other than those mentioned above, calculate the extension direction. , In the formula, Endpoints With the second neighboring point Vectors between Endpoints With the second neighboring point The magnitude of the vector between them, with the negative sign indicating that the extension direction is opposite to the direction inside the skeleton;
[0051] Based on the direction of extension Determine the angle between the candidate point direction and the extension direction. and candidate points Distance value , , For background pixels, A collection of background pixels;
[0052] Consider all 8-neighborhood candidate points and find the optimal candidate point. , , , The set of 8-neighbor candidate points must satisfy the following requirements: It must be a foreground pixel, not a point that has already been extended, and not a point on the skeleton image;
[0053] endpoint Extend to the optimal candidate point ;
[0054] judge Is it 1? .
[0055] In the above scheme, endpoints are used. and its second neighboring point To calculate the extension direction. Compared to using only the first neighbor point. Use the second neighbor point It can skip potential local noise and capture directional trends over longer distances, thus obtaining a more stable extension direction. When the skeleton is too short to find a second neighboring point, it automatically reverts to using the first neighboring point. For example... Figures 6-9 As shown in the extended skeleton effect of the "horizontal" stroke, the present invention demonstrates better direction preservation and path stability compared to existing skeleton extension methods. The original skeleton of this stroke is approximately horizontal with a slight upward-right tilt. Therefore, a reasonable extension should continue to extend to the right along the original skeleton's end direction, maintaining straightness and smoothness as much as possible. The method in this invention can accurately capture the main direction of the stroke's end when extending the endpoints. The extended segment connects naturally with the original skeleton, and the overall trend is continuous without obvious bends or offsets. From the magnified view, it can be seen that the red extended portion is basically located in the center area of the stroke and extends outward along the original stroke direction, effectively restoring the shortened end length during the thinning process. In contrast, the extension results of existing skeleton extension methods show obvious directional offsets. The red extended segment bends downward in a local area, failing to strictly extend along the main direction of the original horizontal stroke's end, resulting in an unnatural connection between the extended path and the original skeleton. This indicates that judging the extension direction based solely on a limited number of candidate directions or local single-point neighborhoods is easily affected by pixel noise near the endpoints, skeleton jagged edges, or edge morphology changes, thus producing incorrect extension directions. Therefore, this figure illustrates that the present invention does not simply pursue a longer extension distance, but rather places greater emphasis on consistency with the original skeleton direction, the smoothness of the path, and the accuracy of the extension position during the extension process.
[0056] In one specific embodiment of the present invention, the general evaluation features include: length features, curvature features, width features, and outer contour similarity features;
[0057] The method for calculating the length feature includes:
[0058] Traverse the skeleton image, extract the coordinates of all foreground pixels, and construct a set of foreground coordinates;
[0059] For each foreground pixel in the foreground coordinate set, perform an 8-neighborhood search around it to find other foreground pixels belonging to the foreground coordinate set, and determine whether the connection relationship is orthogonal connection or diagonal connection based on the relative position of the neighboring foreground pixels.
[0060] Calculate the skeleton arc length of the target stroke in the image of the stroke to be evaluated. As a length feature In the formula, The skeletal arc length of the target stroke. Let be the number of orthogonally connected edges. This refers to the number of diagonally connected edges; in the specific implementation, when the neighbor is located at a foreground pixel... When the coordinates are in the four positive directions of up, down, left, and right (i.e., the coordinate difference is...), or It is determined to be an orthogonal connection. Add 1. When the neighbor is located at the foreground pixel. When the coordinates are in the four diagonal directions of upper left, upper right, lower left, and lower right (i.e., the coordinate difference is...), It is determined to be a diagonal connection. Add 1;
[0061] Calculate the length ratio , , The skeletal arc length of the template stroke;
[0062] Calculate the percentage of relative error in length. As an error in length characteristics, ;
[0063] Calculate length score As a single score for length features, .
[0064] In the above scheme, by scanning point by point and matching with the neighborhood, horizontal / vertical line segments and diagonal line segments are accurately distinguished, eliminating the influence of mesh anisotropy on length measurement and more realistically reflecting the actual physical extension length of the stroke. In practical implementation, because skeleton connections are bidirectional (e.g., when point A is connected to point B, the connection is counted once when traversing A and again when traversing B), the total number of connections counted in the above steps is twice the actual number of connected segments. Therefore, it is necessary to... , Make corrections: , .
[0065] In one specific embodiment of the present invention, such as Figure 2 As shown, the method for calculating the width feature includes:
[0066] Based on the foreground coordinate set, the axis-aligned bounding rectangle is determined; the method for determining the minimum bounding box is implemented using existing technology.
[0067] The dominant direction is determined by the aspect ratio of the axis-aligned bounding rectangle. If the width is greater than the height, it is determined to be a horizontal stroke, and column-by-column vertical scanning is used to obtain several connected components. If the height is greater than or equal to the width, it is determined to be a vertical stroke, and row-by-row horizontal scanning is used to obtain several connected components.
[0068] The scanned connected components are subjected to hook detection, including: sequentially scanning each row or column along the dominant direction and counting the number of connected components at each scan position; when the cumulative number of scan positions with two or more connected components reaches a preset threshold, it is determined that there is a hook structure deviating from the main body of the stroke, indicating a writing structure error; otherwise, the main connected component at each scan position is identified. For the first scan row or column containing foreground pixels, the connected component with the longest length in that scan row or column is selected as the initial main connected component; for subsequent scan rows or columns containing foreground pixels, the connected component with the smallest center distance between its center position and the center of the main connected component at the previous scan position is selected as the main connected component at the current scan position.
[0069] Based on the main connected components at each scanning position, a width sequence is constructed;
[0070] The width sequence is divided into a starting segment, a middle segment, and a ending segment according to a preset segmentation ratio. Let the segmentation ratio be: Where: For each segment, the width sequences of the target stroke and the template stroke are first resampled to the same length using interpolation, and the first stroke of the target stroke is calculated. The average width of each segment is used as the first width feature component;
[0071] Calculate the relative error of the first width feature component , In the formula, and The target stroke and the template stroke are respectively the first The average width of each segment;
[0072] The score of the first-width feature component is calculated using the exponential decay function. , ;
[0073] Calculate the target stroke number A segment width sequence gradient As the second width feature component;
[0074] Calculate the correlation coefficient between the rate of change of the target stroke and the template stroke width. , In the formula, For the target stroke number The first segment The rate of change of width at each location; For the template stroke number The first segment The rate of change of width at each location; For the target stroke number The average of the rate of change of segment width; For the template stroke number The average of the rate of change of segment width;
[0075] Calculate the error in the width variation of the second width feature component. , ;
[0076] Calculate the score of the second-width feature component. , In the formula, For the target stroke number The average value of the variation in width of each segment; For the template stroke number The average value of the variation in width of each segment;
[0077] The first width feature component and the second width feature component are used together as the width feature;
[0078] Calculate the individual scores for each segment. , ;
[0079] The scores of each segment are weighted and fused according to the segment ratio to obtain the individual score of the width feature. , , .
[0080] In the above scheme, by adaptively judging the dominant direction of the stroke and jointly modeling the average width, gradient change rate and their correlation of the segmented width sequence, it can simultaneously characterize the overall thickness features and local width change features of the stroke. Through segmented resampling and weighted fusion, the influence of different stroke lengths, writing directions and local noise on the width evaluation results can be effectively reduced, improving the stability, robustness and comparability with template strokes of the width feature extraction, thereby improving the accuracy and consistency of writing quality evaluation.
[0081] In one specific embodiment of the present invention, the outer contour similarity feature is used to evaluate the degree of similarity between the target stroke and the template stroke in terms of overall shape. The outer contour similarity feature includes two parts: aspect ratio similarity and contour boundary similarity. The aspect ratio similarity reflects the degree of similarity between the target stroke and the template stroke in terms of overall horizontal and vertical proportions, while the contour boundary similarity reflects the degree of similarity between the outer contour of the target stroke and the outer contour of the template stroke in terms of boundary shape.
[0082] The calculation method for the outer contour similarity feature includes:
[0083] Extract the coordinate sequence of the outer contour points of the target stroke and the template stroke;
[0084] The outer contours of the target stroke and the outer contours of the template stroke are normalized. The normalization process includes centroid translation normalization and may further include scale normalization. Centroid translation normalization is used to eliminate translation differences of strokes in the image, and scale normalization is used to eliminate the overall size difference between the target stroke and the template stroke.
[0085] Calculate aspect ratio similarity , In the formula, For aspect ratio similarity, and These are the aspect ratios of the target stroke and the template stroke, respectively. , , , These represent the width and height of the target stroke, respectively. , These represent the width and height of the template stroke, respectively. The aspect ratio similarity is used to characterize the degree of similarity between the target stroke and the template stroke in terms of overall horizontal and vertical proportions.
[0086] Calculate the contour boundary similarity, which is used to characterize the degree of similarity between the outer contour of the target stroke and the outer contour of the template stroke in terms of boundary shape;
[0087] The aspect ratio similarity and the contour boundary similarity are weighted and fused to obtain a single score for the outer contour similarity feature: ,in, The individual score represents the similarity feature of the outer contour. Indicates aspect ratio similarity. Indicates the similarity of contour boundaries. and The preset weights are used, and the following conditions are met: The contour boundary similarity is calculated using bidirectional nearest distance or arc length weighted optimal transmission distance.
[0088] like Figure 3 As shown, in one specific embodiment, the contour boundary similarity is calculated using bidirectional nearest distance, specifically including:
[0089] Calculate the one-way average nearest distance from the outer contour of the target stroke to the outer contour of the template stroke. Specifically, this includes: finding the nearest pixel in the outer contour of the template stroke for each pixel in the outer contour of the target stroke, and calculating the average distance. , , In the formula, This indicates the number of pixels in the outer contour of the target stroke. The first stroke in the outer contour of the target stroke 1 pixel The first stroke in the outer contour of the template stroke 1 pixel; This is the set of outer contour points of the template strokes after normalization. This refers to a point on the outer contour of the target stroke. The nearest distance to the nearest Euclidean distance point is searched within the template contour point set, which consists of all pixels corresponding to the outer contour of the template stroke. Similarly, the one-way average nearest distance from the outer contour of the template stroke to the outer contour of the target stroke is calculated. ;
[0090] Calculate the closest distance between two sides As a feature of outer contour similarity ;
[0091] Calculate relative profile error As an error in the outer contour similarity feature, , In the formula, This indicates the length of the diagonal of the rectangle circumscribed on the outer contour of the template stroke;
[0092] Calculate distance score , ;
[0093] The score of the outer contour similarity feature is calculated using weighted fusion. , .
[0094] While bidirectional nearest distance can measure the local fit of contour boundaries, using this metric alone in evaluating stroke outlines has three key limitations:
[0095] (1) Insufficient sensitivity to changes in overall proportion: the two-way closest distance mainly reflects the local proximity of the outline points and is not sensitive to global changes in stroke proportion.
[0096] (2) Instability of contour resampling: The effectiveness of bidirectional nearest distance depends on the uniformity of contour resampling. In reality, the contour curvature of different strokes is different, and the distribution between points may still be uneven after resampling with equal arc length; the special shapes of the beginning and end of strokes (pointed head, round head) are treated differently; when the contour distribution is uneven, the stability of the distance measurement decreases.
[0097] (3) Confusion between global and local judgments: In calligraphy teaching, the judgment of "whether the outer contour is similar" involves two levels of judgment: the global level (whether the stroke is wide or narrow, long or short, directly reflected by the width-to-height ratio) and the local level (the degree of roundness of the beginning stroke, the degree of outward extension of the ending stroke, and whether there is a bulge in the middle, reflected by the contour distance). Using the two-way closest distance alone cannot distinguish the contribution of these two levels.
[0098] Therefore, the above scheme introduces the aspect ratio similarity of the bounding box as a supplementary indicator of global shape similarity to achieve the following compensation effect:
[0099] (1) Global morphology detection: If | - A larger difference indicates a significant difference in the overall shape of the two strokes. Even if the outlines are close together, a difference in aspect ratio can reduce the overall similarity.
[0100] (2) Enhance the scoring differentiation: Strokes with large morphological differences but similar outline points will have their similarity reduced due to the width-to-height ratio compensation; only strokes that are good in both aspects can have a high overall similarity.
[0101] (3) In line with teaching practice: The teacher's evaluation process is as follows: ① Look at the whole picture - whether the width and height ratios correspond; ② Look at the details - whether the outlines are similar. Composite indicators simulate this natural evaluation process.
[0102] In practical implementation, α=0.35 and β=0.65 can be set. The meaning of the weight settings is: aspect ratio similarity (35%) ensures global shape constraints, while contour distance similarity (65%) focuses on local contour quality. This composite index design can simultaneously reflect the overall proportional consistency of strokes and the degree of local contour fit, and more accurately reflects the comprehensive judgment of "whether the outer contour is similar" than using any index alone.
[0103] like Figure 4 As shown, in another preferred embodiment, the contour boundary similarity is calculated using arc length weighted optimal transmission distance, specifically including:
[0104] Extract the coordinate sequence of the outer contour points of the target stroke and the template stroke, and retain the original outer contour points of the target stroke and the template stroke without performing equal-point resampling; let the outer contour point sequence of the target stroke be:
[0105] ,
[0106] The sequence of points on the outer contour of the template strokes is as follows:
[0107] ,
[0108] In the formula, For the target stroke outer contour point sequence, For the template stroke outer contour point sequence, and These represent the number of points on the outer contour of the target stroke and the number of points on the outer contour of the template stroke, respectively.
[0109] The outer contours of the target stroke and the template stroke are normalized. The normalization process includes centroid translation normalization and scale normalization. Centroid translation normalization is used to eliminate the positional difference between the target stroke and the template stroke in the image, and scale normalization is used to eliminate the overall size difference between the target stroke and the template stroke, so that the contour boundary similarity mainly reflects the boundary shape difference after scale alignment.
[0110] Based on the local arc length between adjacent points in the outer contour of the target stroke, assign arc length weights to each point in the outer contour of the target stroke; for the first point in the outer contour of the target stroke... The outer contour edge has the following side length:
[0111] ,
[0112] In the formula, The first stroke in the outer contour of the target line The side length of the outer contour edge, Indicates Euclidean distance;
[0113] Since the outer contour is a closed contour, therefore:
[0114] ,
[0115] The first of the outer contours of the target stroke The local arc length represented by each outer contour point is:
[0116] ,
[0117] In the formula, The first stroke in the outer contour of the target line The local arc length represented by each outer contour point, and They respectively represent the first The lengths of the preceding and following outer contour edges adjacent to each outer contour point;
[0118] Normalize the local arc length to obtain the first arc length of the target stroke's outer contour. Arc length weights for each outer contour point:
[0119] ,
[0120] In the formula, Draw the outer contour of the target stroke. Arc length weight of each contour point;
[0121] Similarly, based on the local arc lengths between adjacent outer contour points in the template stroke outer contour, arc length weights are assigned to each outer contour point in the template stroke outer contour to obtain the first outer contour point of the template stroke outer contour. Arc length weights for each outer contour point:
[0122] ,
[0123] In the formula, The first stroke of the template outline Arc length weight of each outer contour point;
[0124] Therefore, the outer contour of the target stroke and the outer contour of the template stroke are respectively represented as discrete probability measures weighted by arc length:
[0125] ,
[0126] ,
[0127] In the formula, For the discrete probability measure corresponding to the outer contour of the target stroke. This is the discrete probability measure corresponding to the outer contour of the template strokes. and These represent points located on the outer contour of the target stroke. and template stroke outer contour points Measurement at location;
[0128] Construct a cost matrix between the outer contour points of the target stroke and the outer contour points of the template stroke. The elements of the cost matrix are the squared Euclidean distances between the outer contour points of the target stroke and the outer contour points of the template stroke.
[0129] ,
[0130] In the formula, This indicates that the unit mass is transferred from the outer contour of the target stroke. The outline point is transported to the outer outline of the template stroke. The transmission cost required for each contour point;
[0131] Based on the discrete probability measure corresponding to the outer contour of the target stroke, the discrete probability measure corresponding to the outer contour of the template stroke, and the cost matrix, the optimal transfer matrix satisfying the edge distribution constraint is solved. ,in, Indicates the first stroke of the outer contour of the target stroke The outline point points to the template stroke outer outline. The mass of transported contour points is denoted by the arc length weight vector of the outer contour points of the target stroke. Let the arc length weight vector of the outer contour points of the template stroke be . And satisfy:
[0132] ,
[0133] ,
[0134] The set of transfer matrices that satisfy the marginal distribution constraint is defined as follows:
[0135] ,
[0136] In the formula, This represents the weight vector of the arc length of the outer contour points of the target stroke. And template stroke outer contour point arc length weight vector A set of transfer matrices constrained by edge distribution; This indicates that all elements are non-negative and have a size of . A set of matrices.
[0137] The optimal transmission matrix is solved using an entropy-regularized optimal transmission model. The entropy-regularized optimal transmission model is as follows: ,
[0138] In the formula, This represents the entropy regularization coefficient; the optimal transfer matrix is solved using the Sinkhorn iterative method.
[0139] Calculate the optimal total transmission cost based on the optimal transmission matrix and cost matrix:
[0140] ,
[0141] In the formula, Represents the elements in the optimal transfer matrix;
[0142] Calculate the optimal transmission distance based on the Wasserstein distance:
[0143] ,
[0144] In the formula, For optimal transmission distance;
[0145] The optimal transmission distance is normalized based on the diagonal length of the circumscribed rectangle of the template stroke outline to obtain the relative optimal transmission error:
[0146] ,
[0147] In the formula, For the relative optimal transmission error, This indicates the length of the diagonal of the rectangle circumscribed on the outer contour of the template stroke;
[0148] Calculate contour boundary similarity based on the relative optimal transmission error:
[0149] ,
[0150] In the formula, Indicates the similarity of contour boundaries. This represents the relative optimal transmission error. This is the preset adjustment coefficient.
[0151] The above-mentioned arc-length weighted optimal transmission method does not require the target stroke outer contour and the template stroke outer contour to have the same number of points, nor does it rely on a one-to-one correspondence of fixed point order. Instead, it establishes a global soft matching relationship between two closed contours through the transmission matrix. At the same time, the arc-length weight makes the contribution of each contour point to the difference in the outer contour match the length of the local boundary it represents. Therefore, it can evaluate the overall shape difference of the stroke outer contour more stably and more precisely.
[0152] This invention introduces an optional calculation mechanism for contour boundary similarity in the evaluation of outer contour similarity. It can achieve fast contour matching by using bidirectional nearest distance or achieve more refined global contour matching by using arc length weighted optimal transmission distance. Among them, the optimal transmission method does not require the target contour and the template contour to have the same number of points. It can characterize the contour boundary morphology differences through global soft matching, thereby improving the stability, precision and explanatory power of outer contour similarity evaluation.
[0153] In one specific embodiment of the present invention, the method for calculating the curvature feature includes:
[0154] First, calculate the span of the minimum axis-aligned circumscribed rectangle in both the horizontal and vertical directions. and , and In the formula, and The maximum and minimum x-coordinates are respectively. and These represent the maximum and minimum ordinates, respectively.
[0155] when If the stroke is horizontal, it is classified as a horizontal stroke; otherwise, it is classified as a vertical stroke.
[0156] For horizontal strokes, the outer contour is divided into an upper contour and a lower contour; for vertical strokes, the outer contour is divided into a left contour and a right contour.
[0157] Let the two profile curves after separation be respectively and For horizontal strokes, and These represent the upper and lower contours respectively; for vertical strokes... and These represent the left and right contours, respectively.
[0158] Divide each outline into three continuous segments along the dominant direction of the stroke: the starting segment, the middle segment, and the ending segment. Let the segmentation ratio be: Where: If the coordinate range along the segmented direction is denoted as: Then the coordinate boundaries of the three consecutive segments are defined as follows:
[0159] Opening paragraph: ;
[0160] Writing paragraph: ;
[0161] Concluding paragraph: ;
[0162] Therefore, each contour curve is represented as: ;
[0163] For the contour curves corresponding to each segment, the corresponding discrete curvature sequence is calculated.
[0164] After obtaining the curvature sequence, invalid values are first removed to obtain the effective curvature set; let the effective curvature set be: ;
[0165] Statistical features are extracted from the curvature sequence, and the formula for calculating the statistical features is as follows: , In the formula, This represents the mean of the effective curvature sequence. Indicates the first The effective curvature value at each point, The standard deviation of the effective curvature sequence is represented. Indicates the number of effective curvature values;
[0166] Perform 3σ outlier screening, remove extreme outliers, and retain curvature values that satisfy the following formula: In the formula, Indicates the process The curvature set after outlier filtering;
[0167] Calculate the mean curvature As a curvature feature , Indicates the number of elements in the curvature set after filtering;
[0168] Calculate the mean difference of curvature As an error in curvature characteristics, , Indicates the target stroke number Outline number The curvature values of each segment, Indicates the first stroke of the template Outline number The curvature values of each segment;
[0169] When the average curvature of the template segments is greater than the threshold When the template curvature mean is used, it is used as the normalization reference value; otherwise, a fixed reference value is used. Normalized curvature error is defined as:
[0170] ,
[0171] in, This represents the normalized curvature error, and its value range is... ;
[0172] Set a maximum deduction value for each segment. Then the first The curvature deduction of each segment is... , In the formula, Indicates the first The maximum deduction allowed per segment;
[0173] Calculate the first Outline number Curvature score of each segment , ;
[0174] The average score of corresponding segments in the two contours is used to obtain the average curvature score of the starting segment, the middle segment, and the ending segment. , ;
[0175] The maximum deduction value for each segment corresponding to different stroke types is:
[0176] ,
[0177] The average curvature scores of each segment are fused according to the weights corresponding to the stroke type to obtain the individual scores of the curvature features. , In the formula, , , All are weights.
[0178] The aforementioned curvature feature calculation scheme determines the dominant direction of strokes by aligning the bounding rectangle with the minimum axis and extracts the corresponding bilateral outer contours for horizontal and vertical strokes. This ensures that the curvature calculation matches the stroke extension direction, reducing curvature extraction deviations caused by uniform contour division. By dividing the contour into starting, middle, and ending segments along the dominant stroke direction and calculating the discrete curvature statistical features of each segment, the scheme can precisely depict the degree of contour curvature at different writing stages, avoiding the overall statistics from masking local curvature anomalies. Furthermore, by eliminating invalid curvature values and using 3σ outlier filtering, the scheme effectively reduces the impact of edge burrs, binarization noise, and contour discretization errors on curvature features, improving the robustness and stability of curvature features. By normalizing and comparing the mean curvature values of the target stroke and the template stroke on the corresponding contour and segment, and by setting the maximum deduction value and weight for each segment in combination with different stroke types, the curvature score can simultaneously reflect the smoothness of the stroke contour, the degree of curvature, and the differences in the shape of the beginning and ending strokes, thereby improving the accuracy, stability, and consistency with the results of human evaluation of writing quality.
[0179] In one specific embodiment of the present invention, when the stroke type is a horizontal stroke, the dedicated evaluation feature corresponding to different stroke types is an angle feature, and the calculation method of the angle feature includes:
[0180] Extract the first fitted straight line from the skeleton image;
[0181] The target horizontal line is calculated relative to the slope of the first fitted line. Angle in the positive direction of the axis , In the formula, The slope of the first fitted line;
[0182] Calculate the angle difference As an angular feature In the formula, For the template, draw horizontally relative to The angle between the positive axis and the axis;
[0183] The angle error mapping function is used to calculate the individual score of the angle feature. , ;
[0184] In one specific embodiment of the present invention, when the stroke type is vertical, the special evaluation features corresponding to different stroke types include verticality angle features and stroke ending type features.
[0185] The method for calculating the perpendicularity angle feature includes:
[0186] Extract the second fitted line from the skeleton image;
[0187] The target vertical stroke is calculated based on the slope of the second fitted line relative to... Deflection angle in the positive direction of the axis , , The slope of the second fitted line;
[0188] Calculate the angle difference of the target strokes As a feature of perpendicularity angle In the formula, Indicates the vertical stroke of the template relative to The angle of deflection in the positive direction of the axis;
[0189] The angle error mapping function is used to calculate the individual score of the perpendicularity angle feature. , ;
[0190] like Figure 5 As shown, the pen ending type feature includes the following steps:
[0191] Statistical analysis of stroke width sequence for foreground pixels by row , Then take the last stroke width sequence As the concluding analysis section, it is denoted as ;
[0192] exist In the middle, calculate the difference sequence of the widths of adjacent rows and count the number of times the width increases positively. ;
[0193] If satisfied If a platform feature is present, the platform feature refers to at least three consecutive lines of the same width, or a platform area with an increased width followed by a length greater than five lines. The platform area refers to a region with consecutive lines of equal width. If the platform feature is present, it is determined to be a hanging dew stroke. Otherwise, it is determined to be a suspended needle stroke. This yields the stroke type feature.
[0194] If the target vertical stroke and the template vertical stroke have the same stroke ending type characteristics and If they are consistent, then the individual score for the finishing stroke type feature is: If the types are inconsistent, the individual score for the finishing stroke type feature is: point.
[0195] In the above scheme, by analyzing the width change characteristics of the last 30% segment of the vertical stroke, the stroke ending type is automatically determined based on the number of positions where the width increases and the platform characteristics, laying the foundation for subsequent stroke ending quality evaluation.
[0196] In one specific embodiment of the present invention, when the stroke type is a left-falling stroke, the special evaluation features corresponding to different stroke types include tilt angle features and curvature features.
[0197] The method for extracting the tilt angle feature includes:
[0198] Extract the skeleton points of the target stroke and the template stroke, and detect the skeleton endpoints respectively. Select the skeleton endpoints that are farthest apart as the stroke start and end points, and construct the line connecting the start and end points of the target stroke and the template stroke.
[0199] Calculate the displacement of the line connecting the start and end points of the target stroke in both the horizontal and vertical directions. and , In the formula, , The x-coordinates of the starting and ending points of the target are respectively drawn. , Draw the starting and ending ordinates of the target points respectively;
[0200] Calculate the displacement of the line connecting the start and end points of the template stroke in both the horizontal and vertical directions. and , In the formula, , The x-coordinates of the starting and ending points of the template stroke are respectively. , These are the ordinates of the starting and ending points of the template stroke;
[0201] The tilt direction of the left-falling stroke is defined as the angle between it and the vertical line. The tilt angle of the target left-falling stroke is calculated. , ;
[0202] Calculate the difference between the target angle and the template angle. Error as a characteristic of tilt angle, , The angle of inclination for the template strokes;
[0203] The tilt angle feature is scored using an angle error mapping function. , ;
[0204] The method for calculating the curvature characteristic includes:
[0205] Extract the skeleton points of the target stroke and detect the skeleton endpoints respectively. Select the skeleton endpoints that are farthest apart as the start and end points of the stroke and construct the line connecting the start and end points of the target stroke.
[0206] Let the length of the line connecting the start and end points of the target stroke be... The length of the line connecting the start and end points of the template stroke is... For any point on the skeleton Calculate the perpendicular distance from it to the line connecting the start and end points. The 95th percentile of all distances is taken as the effective maximum deviation. The effective maximum deviations of the target stroke and the template stroke are denoted as follows: and Then the normalized effective curvature of the two is expressed as: and ;
[0207] Calculate the effective curvature difference between the target stroke and the template stroke. Error as a characteristic of curvature: ;
[0208] The individual scores of the curvature feature are calculated using a Gaussian similarity function. : .
[0209] In one specific embodiment of the present invention, when the stroke type is a downward stroke, the special evaluation features include tilt angle features and downward stroke position features;
[0210] The position of the stroke is determined by inputting the binary image and skeleton image of the target stroke, and extracting an ordered skeleton path based on the skeleton image.
[0211] Let the number of target stroke skeleton path points be... The tangent direction is calculated point by point along the skeleton path, and the stroke width of its normal direction in the binary image is taken to obtain the width distribution sequence of the target stroke.
[0212] The width distribution sequence is smoothed, and the peak width position is searched only in the second half of the skeleton. The skeleton point corresponding to the maximum width in the second half is used as the position feature of the stroke.
[0213] If the peak index of the target stroke width is The peak index of the template stroke width is Then, the target stroke position and the template stroke position are normalized and represented as follows: and , The number of skeletal path points for the template strokes;
[0214] Calculate the difference in the position of the stroke foot between the target stroke and the template stroke. As an error in the positional feature of the downward stroke, ;
[0215] The Gaussian similarity function is used to calculate the individual score of the positional feature of the stroke. , .
[0216] With the above stroke foot position feature calculation scheme, the stroke foot position can be determined according to the width variation rule of the right-falling stroke along the skeleton path, instead of simply relying on the stroke endpoint, the extreme point of the bounding box or the geometric end, so that the writing feature of the right-falling stroke that changes from thin to thick and forms a stroke foot at the rear section can be reflected more accurately. By calculating the normal direction width point by point along the skeleton path and only searching for the width peak in the second half of the skeleton in the smoothed width distribution sequence, the interference of starting stroke pause, local thickening in the middle section, edge burrs and end trailing on stroke foot positioning can be effectively avoided, and the stability and accuracy of stroke foot position detection can be improved. Further, by normalizing the stroke foot peak index to the relative position on the skeleton path, the influences caused by differences in writing sizes, stroke lengths and image resolutions can be eliminated, so that the target right-falling stroke and the template right-falling stroke can be compared on a unified scale. By calculating the normalized difference between the target stroke foot position and the template stroke foot position and using a Gaussian similarity function for scoring, the stroke foot position deviation can be smoothly reflected, scoring mutation can be avoided, thereby improving the precision, robustness of the special evaluation for right-falling strokes and the consistency with manual writing evaluation.
[0217] When the stroke type is a dot stroke, the dedicated evaluation features include an inclination angle feature and a form fullness feature;
[0218] The calculation method for the form fullness feature includes:
[0219] Counting the number of foreground pixels as the area , calculating the area of the minimum axis-aligned bounding rectangle , defining the fullness as , comparing the fullness ratio of the target stroke and the template stroke as an error;
[0220] Calculating the individual score of the form fullness feature using a linear mapping function , ;
[0221] When the stroke type is a rising stroke, the dedicated evaluation feature includes an angle feature.
[0222] In a specific implementation of the embodiment of the present invention, the template feature sample library adopts a two-level directory structure of character-stroke serial number, each character corresponds to a subfolder, and each stroke corresponds to a feature file in pkl format; the feature file includes a character name, a stroke serial number, a stroke type, a general evaluation feature and dedicated evaluation features corresponding to different stroke types.
[0223] In the above scheme, the features of the template strokes (width sequence, angle, outer contour, etc.) are fixed in actual scoring scenarios. Recalculating the template features for each scoring session would result in a large amount of redundant calculation, reducing system efficiency. Therefore, this invention proposes to pre-calculate and persistently store the evaluation features of all template strokes, which can then be directly loaded and used during scoring, achieving the following effects:
[0224] (1) Improve scoring efficiency: The evaluation features of template strokes are calculated only once and loaded directly during scoring, reducing the calculation time by more than 50%.
[0225] (2) Ensure scoring consistency: solidify template features to avoid scoring fluctuations caused by floating-point errors and changes in algorithm parameters.
[0226] (3) Easy system maintenance: When the template is updated, only the sample library needs to be rebuilt, without affecting the scoring code logic.
[0227] (4) Support for scale expansion: Supports batch addition of evaluation features for new characters and strokes.
[0228] In one specific embodiment of the present invention, the evaluation report includes a comprehensive score, detailed scores for each item, analysis of weaknesses, and suggestions for improvement.
[0229] Example 2
[0230] This invention provides a hard-pen regular script stroke quality evaluation system based on multi-dimensional feature fusion, including a storage medium and a processor;
[0231] The storage medium is used to store instructions;
[0232] The processor is configured to operate according to the instructions to execute the method according to any one of Embodiments 1.
[0233] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. 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.
[0234] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0235] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0236] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0237] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
[0238] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.
Claims
1. A method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion, characterized in that, include: Obtain the binarized image and skeleton image of the stroke image to be evaluated; An evaluation feature set is determined based on the stroke type of the target stroke in the stroke image to be evaluated. The evaluation feature set includes general evaluation features and special evaluation features corresponding to different stroke types. Load the evaluation features of the template strokes corresponding to the target strokes in the image to be evaluated from the pre-built template feature sample library; Based on the set of evaluation features, extract various evaluation features of the target stroke in the image of the stroke to be evaluated from the binarized image or skeleton image; Based on the evaluation features of the template strokes and the evaluation features of the target strokes, the error of the evaluation features of the target strokes is calculated. The error of each evaluation feature is standardized into a single score of 0-100 using a nonlinear mapping function; The scores of each item are weighted and combined according to preset weights to obtain a comprehensive score and evaluation report.
2. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 1, characterized in that, The method for evaluating the quality of strokes in hard-pen regular script also includes: The skeleton image of the obtained stroke image to be evaluated is subjected to skeleton lengthening processing, which includes the following steps: Find the pair of endpoints with the largest distance in the skeleton image, and perform a predetermined extension operation on both endpoints of the pair. The extension operation includes: Repeat the following steps until... : From the endpoint Start by finding the first neighboring point. From the first neighbor point Start by finding the second neighboring point. The second neighboring point Endpoint For points other than those mentioned above, calculate the extension direction. , In the formula, Endpoints With the second neighboring point Vectors between Indicates endpoint With the second neighboring point The magnitude of the vector between them; Based on the direction of extension Determine the angle between the candidate point direction and the extension direction. and candidate points Distance value , , For background pixels, A collection of background pixels; Consider all 8-neighborhood candidate points and find the optimal candidate point. , , , The set of 8-neighbor candidate points must satisfy the following requirements: It must be a foreground pixel, not a point that has already been extended, and not a point on the skeleton image; endpoint Extend to the optimal candidate point ; judge Is it 1? .
3. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 1, characterized in that: The general evaluation features include: length features, curvature features, width features, and outer contour similarity features; The method for calculating the length feature includes: Traverse the skeleton image, extract the coordinates of all foreground pixels, and construct a set of foreground coordinates; For each foreground pixel in the foreground coordinate set, perform an 8-neighborhood search around it to find other foreground pixels belonging to the foreground coordinate set, and determine whether the connection relationship is orthogonal connection or diagonal connection based on the relative position of the neighboring foreground pixels. Calculate the skeleton arc length of the target stroke in the image of the stroke to be evaluated. As a length feature In the formula, Let be the number of orthogonally connected edges. This represents the number of diagonally connected sides; Calculate the length ratio , , The skeletal arc length of the template stroke; Calculate the percentage of relative error in length. As an error in length characteristics, ; Calculate length score As a single score for length features, .
4. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 3, characterized in that: The method for calculating the width feature includes: Based on the foreground coordinate set, determine the axis-aligned circumscribed rectangle; The dominant direction is determined by the aspect ratio of the axis-aligned bounding rectangle. If the width is greater than the height, it is determined to be a horizontal stroke, and column-by-column vertical scanning is used to obtain several connected components. If the height is greater than or equal to the width, it is determined to be a vertical stroke, and row-by-row horizontal scanning is used to obtain several connected components. The scanned connected components are subjected to hook detection, including: sequentially scanning each row or column along the dominant direction and counting the number of connected components at each scan position; when the cumulative number of scan positions with two or more connected components reaches a preset threshold, it is determined that there is a hook structure deviating from the main body of the stroke, indicating a writing structure error; otherwise, the main connected component of each scan position is found. For the first scan row or column containing foreground pixels, the connected component with the longest length in that scan row or column is selected as the initial main connected component; for subsequent scan rows or columns containing foreground pixels, the connected component with the smallest center distance between its center position and the center of the main connected component of the previous scan position is selected as the main connected component of the current scan position. Based on the main connected components at each scanning position, a width sequence is constructed; The width sequence is divided into a starting segment, a middle segment, and a ending segment according to a preset segmentation ratio. Let the segmentation ratio be: Where: For each segment, the width sequences of the target stroke and the template stroke are first resampled to the same length using interpolation, and the first stroke of the target stroke is calculated. The average width of each segment is used as the first width feature component; Calculate the relative error of the first width feature component , In the formula, and The target stroke and the template stroke are respectively the first The average width of each segment; The score of the first-width feature component is calculated using the exponential decay function. , ; Calculate the target stroke number A segment width sequence gradient As the second width feature component; Calculate the correlation coefficient between the rate of change of the target stroke and the template stroke width. , In the formula, For the target stroke number The first segment The rate of change of width at each location; For the template stroke number The first segment The rate of change of width at each location; For the target stroke number The average of the rate of change of segment width; For the template stroke number The average of the rate of change of segment width, This represents the total number of positions. Calculate the error in the width variation of the second width feature component. , ; Calculate the score of the second-width feature component. , In the formula, For the target stroke number The average value of the variation in width of each segment; For the template stroke number The average value of the variation in width of each segment; The first width feature component and the second width feature component are used together as the width feature; Calculate the individual scores for each segment. , ; The scores of each segment are weighted and fused according to the segment ratio to obtain the individual score of the width feature. , , .
5. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 3, characterized in that: The calculation method for the outer contour similarity feature includes: Extract the coordinate sequence of the outer contour points of the target stroke and the template stroke, and perform normalization processing, the normalization processing including at least centroid translation normalization; Calculate aspect ratio similarity , In the formula, and These are the aspect ratios of the target stroke and the template stroke, respectively. , , , These represent the width and height of the target stroke, respectively. , These represent the width and height of the template stroke, respectively. The aspect ratio similarity is used to characterize the degree of similarity between the target stroke and the template stroke in terms of overall horizontal and vertical proportions. Calculate the contour boundary similarity, which is used to characterize the degree of similarity between the outer contour of the target stroke and the outer contour of the template stroke in terms of boundary shape; The aspect ratio similarity and the contour boundary similarity are weighted and fused to obtain a single score for the outer contour similarity feature: ,in, The individual score represents the similarity feature of the outer contour. Indicates the similarity of contour boundaries. and The preset weights are used, and the following conditions are met: The contour boundary similarity is calculated using bidirectional nearest distance or arc length weighted optimal transmission distance.
6. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 5, characterized in that: When the contour boundary similarity is calculated using bidirectional nearest distance, it includes: Perform contour point sequence standardization processing on the outer contour of the target stroke and the outer contour of the template stroke; Calculate the one-way average nearest distance from the outer contour of the target stroke to the outer contour of the template stroke. Specifically, this includes: finding the nearest pixel in the outer contour of the template stroke for each pixel in the outer contour of the target stroke, and calculating the average distance. , , In the formula, This indicates the number of pixels in the outer contour of the target stroke. The first stroke in the outer contour of the target stroke 1 pixel The first stroke in the outer contour of the template stroke 1 pixel; This is the set of outer contour points of the template strokes after normalization. This indicates the first stroke on the outer contour of the target stroke. 1 pixel The nearest distance to the contour point closest to the template stroke is searched within the contour point set of the template stroke, which consists of all pixels corresponding to the outer contour of the template stroke. Similarly, the one-way average nearest distance from the outer contour of the template stroke to the outer contour of the target stroke is calculated. ; Calculate the closest distance between two sides As a feature of outer contour similarity ; Calculate relative profile error As an error in the outer contour similarity feature, , In the formula, This indicates the length of the diagonal of the rectangle circumscribed on the outer contour of the template stroke; Calculate distance score , ; The score of the outer contour similarity feature is calculated using weighted fusion. , ; When the contour boundary similarity is calculated using arc length weighted optimal transmission distance, it includes: Extract the coordinate sequence of the outer contour points of the target stroke and the template stroke, and retain the original outer contour points of the target stroke and the template stroke without performing equal-point resampling; let the outer contour point sequence of the target stroke be: , The sequence of points on the outer contour of the template strokes is as follows: , In the formula, For the target stroke outer contour point sequence, For the template stroke outer contour point sequence, and These represent the number of points on the outer contour of the target stroke and the number of points on the outer contour of the template stroke, respectively. The outer contours of the target stroke and the template stroke are normalized. The normalization process includes centroid translation normalization and scale normalization. Centroid translation normalization is used to eliminate the positional difference between the target stroke and the template stroke in the image, and scale normalization is used to eliminate the overall size difference between the target stroke and the template stroke, so that the contour boundary similarity mainly reflects the boundary shape difference after scale alignment. Based on the local arc length between adjacent points in the outer contour of the target stroke, assign arc length weights to each point in the outer contour of the target stroke; for the first point in the outer contour of the target stroke... The outer contour edge has the following side length: , In the formula, The first stroke in the outer contour of the target line The side length of the outer contour edge, Indicates Euclidean distance; Since the outer contour is a closed contour, therefore: , The first of the outer contours of the target stroke The local arc length represented by each outer contour point is: , In the formula, The first stroke in the outer contour of the target line The local arc length represented by each outer contour point, and They respectively represent the first The lengths of the preceding and following outer contour edges adjacent to each outer contour point; Normalize the local arc length to obtain the first arc length of the target stroke's outer contour. Arc length weights for each outer contour point: , In the formula, Draw the outer contour of the target stroke. Arc length weight of each contour point; Similarly, based on the local arc lengths between adjacent outer contour points in the template stroke outer contour, arc length weights are assigned to each outer contour point in the template stroke outer contour to obtain the first outer contour point of the template stroke outer contour. Arc length weights for each outer contour point: , In the formula, The first stroke of the template outline Arc length weight of each outer contour point; Therefore, the outer contour of the target stroke and the outer contour of the template stroke are respectively represented as discrete probability measures weighted by arc length: , , In the formula, For the discrete probability measure corresponding to the outer contour of the target stroke. This is the discrete probability measure corresponding to the outer contour of the template strokes. and These represent points located on the outer contour of the target stroke. and template stroke outer contour points Measurement at location; Construct a cost matrix between the outer contour points of the target stroke and the outer contour points of the template stroke. The elements of the cost matrix are the squared Euclidean distances between the outer contour points of the target stroke and the outer contour points of the template stroke. , In the formula, This indicates that the unit mass is transferred from the outer contour of the target stroke. The outline point is transported to the outer outline of the template stroke. The transmission cost required for each contour point; Based on the discrete probability measure corresponding to the outer contour of the target stroke, the discrete probability measure corresponding to the outer contour of the template stroke, and the cost matrix, the optimal transfer matrix satisfying the edge distribution constraint is solved. ,in, Indicates the first stroke of the outer contour of the target stroke The outline point points to the template stroke outer outline. The mass of transported contour points is denoted by the arc length weight vector of the outer contour points of the target stroke. Let the arc length weight vector of the outer contour points of the template stroke be . And satisfy: , , The set of transfer matrices that satisfy the marginal distribution constraint is defined as follows: , In the formula, This represents the weight vector of the arc length of the outer contour points of the target stroke. And template stroke outer contour point arc length weight vector A set of transfer matrices constrained by edge distribution; This indicates that all elements are non-negative and have a size of . The set of matrices; The optimal transmission matrix is solved using an entropy-regularized optimal transmission model. The entropy-regularized optimal transmission model is as follows: , In the formula, This represents the entropy regularization coefficient; the optimal transfer matrix is solved using the Sinkhorn iterative method. Calculate the optimal total transmission cost based on the optimal transmission matrix and cost matrix: , In the formula, Represents the elements in the optimal transfer matrix; Calculate the optimal transmission distance based on the Wasserstein distance: , In the formula, For optimal transmission distance; The optimal transmission distance is normalized based on the diagonal length of the circumscribed rectangle of the template stroke outline to obtain the relative optimal transmission error: , In the formula, For the relative optimal transmission error, This indicates the length of the diagonal of the rectangle circumscribed on the outer contour of the template stroke; Calculate contour boundary similarity based on the relative optimal transmission error: , In the formula, Indicates the similarity of contour boundaries. This represents the relative optimal transmission error. This is the preset adjustment coefficient.
7. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 3, characterized in that: The method for calculating the curvature feature includes: First, calculate the span of the minimum axis-aligned circumscribed rectangle in both the horizontal and vertical directions. and , and In the formula, and The maximum and minimum x-coordinates are respectively. and These represent the maximum and minimum ordinates, respectively. when If the stroke is horizontal, it is classified as a horizontal stroke; otherwise, it is classified as a vertical stroke. For horizontal strokes, the outer contour is divided into an upper contour and a lower contour; for vertical strokes, the outer contour is divided into a left contour and a right contour. Let the two profile curves after separation be respectively and For horizontal strokes, and These represent the upper and lower contours respectively; for vertical strokes... and These represent the left and right contours, respectively. Divide each outline into three continuous segments along the dominant direction of the stroke: the starting segment, the middle segment, and the ending segment. Let the segmentation ratio be: Where: If the coordinate range along the segmented direction is denoted as: Then the coordinate boundaries of the three consecutive segments are defined as follows: Opening paragraph: ; Writing paragraph: ; Concluding paragraph: ; Therefore, each contour curve is represented as: ; For the contour curves corresponding to each segment, the corresponding discrete curvature sequence is calculated. After obtaining the curvature sequence, invalid values are first removed to obtain the effective curvature set; let the effective curvature set be: ; Statistical features are extracted from the curvature sequence, and the formula for calculating the statistical features is as follows: , In the formula, This represents the mean of the effective curvature sequence. Indicates the first The effective curvature value of each pixel. The standard deviation of the effective curvature sequence is represented. Indicates the number of effective curvature values; Perform 3σ outlier screening, remove extreme outliers, and retain curvature values that satisfy the following formula: In the formula, Indicates the process The curvature set after outlier filtering; Calculate the mean curvature As a curvature feature , Indicates the number of elements in the curvature set after filtering; Calculate the mean difference of curvature As an error in curvature characteristics, , Indicates the target stroke number Outline number The curvature values of each segment, Indicates the first stroke of the template Outline number The curvature values of each segment; When the average curvature of the template segments is greater than the threshold When the template curvature mean is used, it is used as the normalization reference value; otherwise, a fixed reference value is used. Normalized curvature error is defined as: , in, This represents the normalized curvature error, and its value range is... ; Set a maximum deduction value for each segment. Then the first The curvature deduction of each segment is... , ; Calculate the first Outline number Curvature score of each segment , ; The average score of corresponding segments in the two contours is used to obtain the average curvature score of the starting segment, the middle segment, and the ending segment. , ; The maximum deduction value for each segment corresponding to different stroke types is: , The average curvature scores of each segment are fused according to the weights corresponding to the stroke type to obtain the individual scores of the curvature features. , In the formula, , , All are weights.
8. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 1, characterized in that: When the stroke type is horizontal, the specific evaluation feature corresponding to different stroke types is an angle feature, and the calculation method of the angle feature includes: Extract the first fitted straight line from the skeleton image; The target horizontal line is calculated relative to the slope of the first fitted line. Angle in the positive direction of the axis , In the formula, The slope of the first fitted line; Calculate the angle difference As an angular feature In the formula, For the template, draw horizontally relative to The angle between the positive axis and the axis; The angle error mapping function is used to calculate the individual score of the angle feature. , ; When the stroke type is vertical, the special evaluation features corresponding to different stroke types include verticality angle features and stroke ending type features; The method for calculating the verticality angle feature includes: Extract the second fitted line from the skeleton image; The target vertical stroke is calculated based on the slope of the second fitted line relative to... Deflection angle in the positive direction of the axis As a feature of perpendicularity angle In the formula, The slope of the second fitted line; Calculate the angle difference of the target strokes As an error In the formula, Indicates the vertical stroke of the template relative to The angle of deflection in the positive direction of the axis; The angle error mapping function is used to calculate the individual score of the perpendicularity angle feature. , ; The stroke ending type feature includes the following steps: Statistical analysis of stroke width sequence for foreground pixels by row , Then take the last stroke width sequence As the concluding analysis section, it is denoted as ; exist In the middle, calculate the difference sequence of the widths of adjacent rows and count the number of times the width increases positively. ; If satisfied If a platform feature is present, the platform feature refers to at least three consecutive lines of the same width, or a platform area with an increased width followed by a length greater than five lines. The platform area refers to a region with consecutive lines of equal width. If the platform feature is present, it is determined to be a hanging dew stroke. Otherwise, it is determined to be a suspended needle stroke. This yields the stroke type feature. If the target vertical stroke and the template vertical stroke have the same stroke ending type characteristics and Consistency, indicating an error of 0, means the individual score for the ending stroke type feature is: If the types are inconsistent, the individual score for the finishing stroke type feature is: point; When the stroke type is a left-falling stroke, the special evaluation features corresponding to different stroke types include tilt angle features and curvature features; The method for extracting the tilt angle feature includes: Extract the skeleton points of the target stroke and the template stroke, and detect the skeleton endpoints respectively. Select the skeleton endpoints that are farthest apart as the stroke start and end points, and construct the line connecting the start and end points of the target stroke and the template stroke. Calculate the displacement of the line connecting the start and end points of the target stroke in both the horizontal and vertical directions. and , In the formula, , The x-coordinates of the starting and ending points of the target are respectively drawn. , Draw the starting and ending ordinates of the target points respectively; Calculate the displacement of the line connecting the start and end points of the template stroke in both the horizontal and vertical directions. and , In the formula, , The x-coordinates of the starting and ending points of the template stroke are respectively. , These are the ordinates of the starting and ending points of the template stroke; The tilt direction of the left-falling stroke is defined as the angle between it and the vertical line. The tilt angle of the target left-falling stroke is calculated. As a feature of tilt angle. ; Calculate the difference between the target angle and the template angle. Error as a characteristic of tilt angle, , The angle of inclination for the template strokes; The tilt angle feature is scored using an angle error mapping function. , ; The method for calculating the curvature characteristic includes: Extract the skeleton points of the target stroke and detect the skeleton endpoints respectively. Select the skeleton endpoints that are farthest apart as the start and end points of the stroke and construct the line connecting the start and end points of the target stroke. Let the length of the line connecting the start and end points of the target stroke be... The length of the line connecting the start and end points of the template stroke is... For any point on the skeleton Calculate the perpendicular distance from it to the line connecting the start and end points. The 95th percentile of all distances is taken as the effective maximum deviation. The effective maximum deviations of the target stroke and the template stroke are denoted as follows: and Then the normalized effective curvature of the two is expressed as: and ; Calculate the effective curvature difference between the target stroke and the template stroke. Error as a characteristic of curvature: ; The Gaussian similarity function is used to calculate the individual score of the curvature feature of the stroke. : ; When the stroke type is a downward stroke, the special evaluation features include tilt angle features and downward stroke position features; The position of the stroke is determined by inputting the binary image and skeleton image of the target stroke, and extracting an ordered skeleton path based on the skeleton image. Let the number of target stroke skeleton path points be... The tangent direction is calculated point by point along the skeleton path, and the stroke width of its normal direction in the binary image is taken to obtain the width distribution sequence of the target stroke. The width distribution sequence is smoothed, and the peak width position is searched only in the second half of the skeleton. The skeleton point corresponding to the maximum width in the second half is used as the position feature of the stroke. If the peak index of the target stroke width is The peak index of the template stroke width is Then, the target stroke position and the template stroke position are normalized and represented as follows: and , The number of skeletal path points for the template strokes; Calculate the difference in the position of the stroke foot between the target stroke and the template stroke. As an error in the positional feature of the downward stroke, ; The Gaussian similarity function is used to calculate the individual score of the positional feature of the stroke. , ; When the stroke type is dot stroke, the special evaluation features include tilt angle feature and shape fullness feature; The calculation method for the morphological fullness feature includes: The number of foreground pixels is used as the area. Calculate the area of the minimum axis-aligned circumscribed rectangle. , define fullness as Compare the fullness ratio of the target stroke and the template stroke. As for error; The individual score of the morphological fullness feature is calculated using a linear mapping function. , ; When the stroke type is lifting stroke, the special evaluation features include angle features.
9. The method for evaluating the quality of strokes in hard-pen regular script based on multi-dimensional feature fusion according to claim 1, characterized in that: The template feature sample library adopts a two-level directory structure of character-stroke sequence number, with each character corresponding to a subfolder and each stroke corresponding to a feature file in pkl format; the feature file includes character name, stroke sequence number, stroke type, general evaluation features and special evaluation features corresponding to different stroke types.
10. A system for evaluating the quality of strokes in regular script calligraphy based on multi-dimensional feature fusion, characterized in that, Including storage media and processor; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to perform the method according to any one of claims 1-9.