A method and system for evaluating individual Chinese characters based on structural features
Patent Information
- Application Number
- CN202611452477.2
- 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
[0006]本发明所要解决的技术问题是克服现有技术的缺陷,提供一种基于结构特征的独体字书法评价方法及系统,用以解决现有书法自动评价技术缺乏独体字针对性评价体系、整字与笔画指标割裂、评价结果缺乏书法美学语义映射的技术问题
[0082]本发明的有益效果是:本发明通过建立专门针对独体字单部件结构的多层级评价体系,将整字层级指标与笔画层级指标有机融合,解决了现有技术对独体字评价粒度粗糙的问题;通过多候选轴竞争法提升了手写变形场景下对称轴定位的鲁棒性。本发明可直接服务于中小学书法教学场景。
Smart Images

Figure CN122967279A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image evaluation technology, and in particular to a method and system for evaluating single-character calligraphy based on structural features. Background Technology
[0002] The evaluation of Chinese character handwriting quality is an important research direction in computer-assisted calligraphy education. For computers, the information contained in an image is composed of all its pixels. It is difficult for computers to distinguish which pixels in a penmanship image represent strokes, and which represent features such as turns and starting points during writing. These features are crucial for judging the quality of penmanship. Existing intelligent calligraphy evaluation research typically extracts visual features from character shapes and combines them with deep learning or rule analysis methods to achieve automatic scoring and guidance for calligraphy works. However, current technologies are still largely geared towards the overall evaluation of general calligraphy works. In terms of standardized evaluation of single-component characters, there are still problems such as insufficient structural specificity, unclear indicator systems, and weak evaluation interpretability.
[0003] Chinese characters are classified by structure into single-component characters, top-bottom structure characters, top-middle-bottom structure characters, left-right structure characters, left-middle-right structure characters, semi-enclosed structure characters, fully enclosed structure characters, and triangular structure characters. Single-component characters refer to characters that consist of only a single form, not composed of two or more forms. These characters are mostly simple pictographs and ideographs. Because these characters evolved from pictures, each character is a complete unit. Due to their single-component structure, the evaluation criteria for single-component characters differ significantly from those for compound characters: the evaluation of compound characters focuses on the proportion, position, and interweaving relationships between components, while the evaluation of single-component characters focuses on the symmetry of the overall character shape, the compactness of the strokes, and the topological relationships.
[0004] Existing automatic calligraphy evaluation technologies have the following shortcomings: First, there is a lack of a specialized evaluation system for single-component characters. Existing methods are mostly designed for compound characters, and simply applying the evaluation framework for compound characters to single-component characters results in coarse evaluation granularity. Second, the whole-character level indicators and stroke level indicators are separated, failing to establish a complete evaluation chain from macroscopic form to microscopic strokes. Third, the evaluation results lack an effective mapping with the concept of calligraphy aesthetics, and the feedback information is difficult for teachers and students in calligraphy teaching scenarios to understand. Fourth, the method of symmetry axis positioning in symmetry evaluation is simplistic and cannot adapt to the problem of axis offset caused by handwriting deformation.
[0005] Therefore, how to construct an automatic evaluation method that is specifically designed for single-component structures of characters, integrates two-level evaluation indicators of whole characters and strokes, and has the ability to map semantics of calligraphy aesthetics has become a technical problem that urgently needs to be solved in the field of calligraphy education informatization. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to overcome the defects of the prior art and provide a method and system for evaluating single-component calligraphy based on structural features, so as to solve the technical problems of existing automatic calligraphy evaluation technology lacking a targeted evaluation system for single-component characters, separating whole character and stroke indicators, and lacking semantic mapping of calligraphy aesthetics in the evaluation results.
[0007] To achieve the above objectives, the main technical solutions adopted by the present invention include:
[0008] This invention provides a method for evaluating the calligraphy of single-component characters based on structural features, comprising:
[0009] Obtain the calligraphy image of the single-component character to be evaluated and the corresponding template character image; the single-component character refers to a Chinese character with only one single form, and the template character is written by a calligraphy expert; the single-component character to be evaluated is handwritten by the person being evaluated who imitates the template character.
[0010] The single-character calligraphy image and the template character image are preprocessed respectively;
[0011] The preprocessed single-character calligraphy image and the template character image are compared and calculated based on the whole-character level index to obtain the whole-character level index difference value and the whole-character level index score. The whole-character level index includes uniformity index, symmetry index, length-width ratio index and tilt index.
[0012] The preprocessed single-character calligraphy image and the template character image are compared and calculated based on the stroke level index to obtain the stroke level index difference value and the stroke level index score. The stroke level index includes the stroke compactness index, the stroke topological relationship index and the stroke relative position index.
[0013] The comprehensive score for the calligraphy of the single-component character is obtained by weighting and summing the scores of the whole character level index and the stroke level index.
[0014] Preferably, the preprocessing includes grayscale conversion, binarization, color inversion, centroid alignment, and scaling normalization to obtain a normalized binary image.
[0015] Preferably, the calculation of the difference value and score of the uniformity index includes:
[0016] The normalized binary image is divided into... For each grid, the stroke pixel density is calculated. The stroke pixel density of the grid is calculated using the pixel mean of the image after color inversion. Define the stroke pixel density difference between the template font and the corresponding grid of the handwritten font. for: ,in, Grid for template fonts Stroke pixel density, Grid for handwritten characters Stroke pixel density;
[0017] based on Calculate the average deviation, standard deviation, and entropy difference between the template characters and the handwritten characters, and normalize them to obtain the normalized uniformity composite difference, expressed as:
[0018] ,in, The difference in uniformity after normalization. The normalized mean deviation, The normalized standard deviation The normalized entropy difference, As weight;
[0019] Normalized evenness index score The calculation is as follows: .
[0020] Preferably, the calculation of the difference value and index score of the symmetry index includes:
[0021] Five types of candidate symmetry axes are generated: traditional median axis, centroidal vertical axis, maximum symmetry axis, density-weighted centroidal axis, and fine-optimized symmetry axis.
[0022] The optimal axis of symmetry was determined through ablation experiments;
[0023] The comprehensive difference in distribution characteristics between template characters and handwritten characters was calculated based on the optimal axis of symmetry. Difference in offset distance between center and centroid Differences in the position of the central axis and differences in left and right balance And calculate the symmetry comprehensive gap. , is represented as: ,in, As weight;
[0024] Calculate the symmetry index score , is represented as: ,in, This is the attenuation coefficient for symmetry scoring.
[0025] Preferably, the calculation of the difference value and score of the aspect ratio index includes:
[0026] Extract the smallest bounding rectangle of the foreground region of the whole character and calculate the aspect ratio;
[0027] Based on the aspect ratio of the template font and the handwritten font, the absolute difference in the length-to-width ratio is calculated. Relative proportion difference Difference in squareness And calculate the overall difference in aspect ratio. , is represented as: ,in, As weight;
[0028] Calculate the aspect ratio score , is represented as: ,in, This is the aspect ratio score attenuation coefficient.
[0029] Preferably, the calculation of the difference value and index score of the tilt index includes:
[0030] Calculate the overall principal axis angle, multi-layer centerline fitting angle, and left and right boundary tilt angles for both handwritten and template characters. Also, calculate the difference in the overall principal axis angle between the handwritten and template characters. Multi-layer centerline fitting angle difference value Difference value between left and right boundary tilt angles ;
[0031] Based on the overall principal axis angle difference value Multi-layer centerline fitting angle difference value Difference value between left and right boundary tilt angles The tilt type is identified, including basically stable, overall tilt, local anomaly, boundary skew, and mixed uncertainty.
[0032] Based on the overall principal axis angle difference value Calculate the overall principal axis deflection deduction based on the tilt type:
[0033] ,
[0034] ,
[0035] ,
[0036] in, Deduct points for overall spindle deflection. This is the corrected spindle deflection ratio. This is the correction factor for the main axis term, set according to the tilt type. This represents the original spindle deflection ratio. The overall main axis angle of the template text;
[0037] Based on the multi-layered centerline fitting angle difference value Calculate the deviation deduction for the fitted angle of the multi-layer centerline:
[0038] ,
[0039] ,
[0040] ,
[0041] ,
[0042] in, Deductions are made for deviations in the fitting angle of the multi-layer centerline. The corrected deviation ratio of the multi-layered centerline. This represents the original multi-layered centerline deviation ratio. This is the direction correction factor. The fitting angle for the multi-layer centerline of the template character. Fitting angles for the multi-layered central axis of handwritten characters;
[0043] Calculation of absolute tilt deduction for multi-layer central axis based on the fitting angle of the multi-layer central axis of handwritten characters:
[0044] ,
[0045] ,
[0046] in, Deductions will be made for the absolute tilt of the multi-layered central axis. The absolute value of the fitted angle for the multi-layered central axis of the handwritten character;
[0047] Based on the difference in the tilt angles of the left and right boundaries Calculate the deduction for tilt deviation of the left and right boundaries based on the tilt type:
[0048] ,
[0049] ,
[0050] ,
[0051] in, Points will be deducted for tilting or deviating from the left and right boundaries. The corrected boundary deviation ratio. The deviation ratio of the original boundary. The boundary term correction factor is set according to the tilt type. The tilt angle of the left and right boundaries of the template text;
[0052] Calculate the deduction for consistency in tilt direction: Define the deduction for consistency in tilt direction as... If the effective tilt angles among the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle are less than two or their directions are inconsistent, then If two of the following have the same direction: the fitting angle of the multi-layer centerline, the tilt angles of the left and right boundaries, and the overall principal axis angle, then If the indices in the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle all tilt in the same direction, then If the indices in the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle are all consistent and the centerline tilt exceeds [a certain value], then [the following conditions apply]. ,but The effective tilt angle refers to , , The value is not 0;
[0053] Calculate the cumulative deduction points , is represented as: ;
[0054] Calculate the tilt index score , is represented as: .
[0055] Preferably, the index difference value and index score of the stroke compactness index are calculated as follows:
[0056] Calculate the overall proximity, average starting stroke distance, and average ending stroke distance for both handwritten and template characters.
[0057] The difference in indicators is calculated based on the overall proximity of the handwritten characters and the template characters, the average starting distance, and the average ending distance, including: overall proximity deviation, starting distance deviation, and ending distance deviation.
[0058] The overall deviation of stroke compactness is calculated based on the difference values of the aforementioned indicators and is expressed as follows: ;
[0059] The stroke compactness index score is calculated and expressed as follows: ;
[0060] in, The overall deviation is due to the compactness of the strokes. Scoring is given based on the stroke compactness index. For the overall proximity deviation, This is due to the deviation in the starting distance. Due to deviation in the distance of the stroke ending, , and All are weights. This is the comprehensive deviation deduction coefficient.
[0061] Preferably, the index difference value and index score of the stroke topology relationship index are calculated as follows:
[0062] For both handwritten and template characters, calculate the minimum distance between the bounding boxes of any two strokes. If the distance is less than or equal to a preset threshold, it is determined that there is a topological relationship, and the two strokes are selected as candidate stroke pairs.
[0063] Calculate the actual number of overlapping pixels of the candidate stroke pairs within the local verification region. The overlap rate of the stroke overlap area of the candidate stroke pair relative to the overall overlap rate of the joint region. The maximum coverage of the overlapping area of candidate stroke pairs relative to the area of a single stroke. Number of pixels in contact at the stroke boundary of candidate stroke pairs The number of adjacent pixels of candidate stroke pairs after neighborhood dilation The joint region refers to the union or extended union region of the two bounding boxes of the candidate stroke pair;
[0064] based on , , , and Determine the stroke topological relationship of the candidate stroke pairs, if and Then the stroke topological relationship is intersection; if and Satisfy any one of them, and Then the stroke topological relationship is connected; if and and If the stroke topological relationship is , then the stroke topological relationship is adjacent; where, Threshold for determining intersection relationship and These are the weight parameters for overlap ratio and coverage ratio, respectively;
[0065] The stroke topology matrix is obtained by traversing the candidate stroke pairs.
[0066] Using 0 for adjacent characters, 1 for connected characters, and 2 for intersection characters, calculate the difference in stroke topological relationships between handwritten characters and template characters, represented as follows: ,in Candidate stroke pairs for handwritten and template characters and Differences in the topological relationships of strokes. Candidate stroke pairs for template characters and The stroke topological relationship values, Candidate stroke pairs for handwritten characters and The stroke topological relationship values;
[0067] The stroke topological relationship index score is obtained by combining weights and a Gaussian function:
[0068] ;
[0069] Introduce a penalty term: ,
[0070] The stroke topological relationship index score with the inclusion of a penalty term is expressed as: ;
[0071] in, Scoring of stroke topological relationship indicators. To introduce a penalized scoring method for the stroke topology relationship index, The number of strokes. As weight, To adjust the parameters, As a penalty item, The penalty coefficient for a single serious error. The number of critical errors. This is the maximum penalty value.
[0072] Preferably, the index difference value and index score of the stroke relative position index are calculated as follows:
[0073] The center cohesion, stroke organization, stroke ending organization, and stroke beginning and ending correspondence are calculated for both handwritten and template characters. Differences in center cohesion, stroke organization, stroke ending organization, and stroke beginning and ending correspondence between handwritten and template characters are also calculated. The center cohesion refers to the distance from the centroid to the character center for each stroke, statistically analyzed across all strokes to obtain the center cohesion at the whole-character level. The stroke beginning organization is calculated as follows: ,in, Indicates the degree of organization at the beginning of the stroke. and They represent the first The starting point and the first stroke of a line The unit direction vector of the starting point of a stroke relative to the center of the character. The number of strokes. , Indicates the first The starting point of a stroke. Indicates the core of the entire character; the calculation of the ending stroke organization degree is as follows: ,in, Indicates the degree of organization at the end of the stroke. and They represent the first The ending point of a stroke and the first The unit direction vector of the ending point of a stroke relative to the center of the character. , Indicates the first The ending point of a stroke; the calculation of the beginning and ending stroke correspondence is as follows: ,in, Indicates the degree of correspondence between the beginning and end of a stroke. and They represent the first Strokes and the first A single stroke is a unit direction vector from the starting point to the ending point. ;
[0074] Based on the differences in center cohesion, starting stroke organization, ending stroke organization, and starting and ending stroke correspondence between the handwritten and template characters, the comprehensive difference in the relative positions of the strokes is calculated. , represented as: ,in, Indicates the difference in central aggregation degree. This indicates differences in the organization of the initial strokes. This indicates differences in the organization of the strokes at the end. This indicates a difference in the degree of correspondence between the beginning and end of a stroke. As weight;
[0075] Calculate the relative position index score of strokes , represented as: ,in, The scoring coefficient is the relative position of the strokes.
[0076] This invention also provides a structural feature-based evaluation system for single-component character calligraphy, used to implement the above-mentioned structural feature-based evaluation method for single-component character calligraphy. The system includes:
[0077] The image acquisition module is used to acquire the calligraphy image of the single-component character to be evaluated and the corresponding template character image; the single-component character refers to a Chinese character with only one single form, and the template character is written by a calligraphy expert; the single-component character to be evaluated is handwritten by the person being evaluated by copying the template character.
[0078] The preprocessing module is used to preprocess the single-character calligraphy image and the template character image respectively;
[0079] The whole character level evaluation module is used to compare and calculate the preprocessed single-character calligraphy image and the template character image based on the whole character level index to obtain the whole character level index difference value and the whole character level index score. The whole character level index includes uniformity index, symmetry index, length-width ratio index and tilt index.
[0080] The stroke level evaluation module is used to compare and calculate the preprocessed single-character calligraphy image and the template character image based on the stroke level index, and obtain the stroke level index difference value and the stroke level index score. The stroke level index includes the stroke compactness index, the stroke topological relationship index and the stroke relative position index.
[0081] The comprehensive evaluation module is used to perform a weighted summation of the whole character level index score and the stroke level index score to obtain the comprehensive score of the single-component calligraphy to be evaluated.
[0082] The beneficial effects of this invention are as follows: By establishing a multi-level evaluation system specifically for single-component structures of single-character words, this invention organically integrates whole-character level indicators with stroke level indicators, thus solving the problem of coarse granularity in the evaluation of single-character words in existing technologies; and by improving the robustness of symmetry axis positioning in handwriting deformation scenarios through a multi-candidate axis competition method. This invention can directly serve the calligraphy teaching scenarios in primary and secondary schools. Attached Figure Description
[0083] Figure 1 A flowchart illustrating a method for evaluating single-component calligraphy based on structural features, provided in one embodiment of the present invention;
[0084] Figure 2 This is a flowchart of the preprocessing process in one embodiment of the present invention;
[0085] Figure 3 This is a schematic diagram of 5×5 grid density division and density matrix calculation in one embodiment of the present invention;
[0086] Figure 4 This is a schematic diagram illustrating the classification of stroke topological relationships in one embodiment of the present invention. Detailed Implementation
[0087] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.
[0088] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.
[0089] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.
[0090] It should also be noted that, unless otherwise specified, the term "connection" in this article can refer not only to a direct connection, but also to an indirect connection involving an intermediary.
[0091] In the following description, embodiments of the invention will be illustrated with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar parts, or the same or similar steps.
[0092] It should be emphasized here that the step markers mentioned below are not a limitation on the order of the steps, but should be understood as meaning that the steps can be executed in the order mentioned in the embodiments, or in a different order than in the embodiments, or several steps can be executed simultaneously.
[0093] This invention provides a method for evaluating the calligraphy of single-component characters based on structural features, such as... Figure 1 As shown, it includes the following steps:
[0094] Step S1: Obtain the calligraphy image of the single-component character to be evaluated and the corresponding template character image;
[0095] Step S2 involves preprocessing the single-character calligraphy image and the template character image, including grayscale conversion, binarization, color inversion, centroid alignment, and scaling normalization.
[0096] Step S3: Based on the whole character level index, compare and calculate the preprocessed single-character calligraphy image and the template character image to obtain the whole character level index difference value and the whole character level index score. The whole character level index includes uniformity index, symmetry index, length-width ratio index and tilt index.
[0097] Step S4: Based on the stroke level index, the preprocessed single-character calligraphy image and the template character image are compared and calculated to obtain the stroke level index difference value and the stroke level index score. The stroke level index includes the stroke compactness index, the stroke topology index and the stroke relative position index.
[0098] Step S5: Calculate the comprehensive score based on the whole character level index score and the stroke level index score, and generate evaluation feedback information based on the threshold diagnosis rule.
[0099] The following are Figure 1 The specific implementation of each step in the illustrated embodiment is described in detail below:
[0100] In step S1, the calligraphy image of the single-component character to be evaluated and the corresponding template character image are obtained.
[0101] In this embodiment, a single-component Chinese character refers to a Chinese character that has only a single integrated form, and is not composed of two or more separate forms. The form evolved from ancient pictures, mainly including two categories: pictographs (such as "ri" (sun) and "shan" (mountain)) and self-explanatory characters (such as "shang" (up) and "xia" (down)), which have an indivisible integrity. Since a single-component Chinese character has a single-component structure, the indicators for evaluating the single-component Chinese character are divided into only two levels: the whole character and strokes. The template character images are written by calligraphy experts and stored in a template library. The single-component Chinese character to be evaluated is a handwritten character obtained by the evaluated person copying and writing the template character.
[0102] In step S2, preprocessing is performed on the single-component Chinese character calligraphy image and the template character image respectively.
[0103] Figure 2 is a schematic diagram of a preprocessing process in an embodiment of the present invention. As shown in Figure 2 , the preprocessing specifically includes the following steps:
[0104] In step S21, grayscale processing is performed on the image to convert the color image into a single-channel grayscale image.
[0105] In step S22, binarization processing is performed on the grayscale image. This embodiment adopts a method of calculating a threshold separately for each image. The specific process is to count the grayscale values of each Chinese character image to form a grayscale histogram. The histogram generally presents two peaks: one peak is concentrated on the main background color, and the other peak is concentrated on the stroke color. The median value of the two peaks is taken as the threshold for binarization processing. The pixel value of the pixel point greater than the threshold is set to 255, and the pixel value of the pixel point less than the threshold is set to 0, so as to obtain a binary image.
[0106] In step S23, color inversion processing is performed on the binary image. The original image is a handwritten image with black characters on a white background. In the grayscale image ranging from 0 to 255, the pixel value of black strokes is close to 0, and the pixel value of the white background is close to 255. To facilitate subsequent mean / standard deviation calculation and stroke density calculation, it is desirable that the value of the stroke area is as large as possible and the value of the background area is as small as possible. Therefore, color inversion processing is performed on the original character. The value after color inversion is equal to 255 minus the original value. In this way, the original black strokes (0) become white (255), and the original white background (255) becomes black (0). When calculating the density of each grid, the calculation can be directly performed using the mean function without additional processing.
[0107] In step S24, the centroid coordinates of the foreground pixel set are calculated and centroid alignment is performed.
[0108] The centroid coordinates are defined as: ,
[0109] wherein, and are the centroid coordinates, and The x and y coordinates of the foreground pixel position of the handwritten text. Foreground pixel set The total number of pixels. When In this context, the centroid is taken from the center of the image. "Handwritten characters" refers to single-component characters to be evaluated.
[0110] In step S25, scaling normalization is performed. The scaling ratio is calculated. ,in , For the template font width and height, , This sets the width and height for handwritten characters. A scaling factor is used. Scaling of handwritten text. Through scaling transformations and translation compensation, the effects of layout and font size are eliminated.
[0111] In step S3, the preprocessed single-character calligraphy image and the template character image are compared and calculated based on the whole-character level index to obtain the difference value of the whole-character level index, and then the scores of each index of the whole-character level are obtained.
[0112] In this embodiment, the whole-character level indicators include four items: uniformity, symmetry, aspect ratio, and tilt. After calculating each indicator, the difference value of each indicator is obtained by subtracting the calculation result of the handwritten character from the calculation result of the template character.
[0113] S31, Figure 3 This is a schematic diagram illustrating the 5×5 grid density division and density matrix calculation in one embodiment of the present invention. Figure 3 As shown, the calculation of the uniformity index specifically includes:
[0114] set up If the grid is divided into orders, then the whole character image is divided into... For regions of approximately equal size, denoted as the corresponding density distribution or measure of difference. The normalized binary image is divided into... The grid is divided into several parts, preferably a 5×5 grid in this embodiment. The grid boundary is calculated based on the grid row and column numbers, with a remainder of 1 pixel allocated to the last row / column. The stroke pixel density of each grid is calculated. The stroke pixel density is defined as: , It is the inverted binary image in The position value is used to construct the grid density matrix. .
[0115] Define the difference in stroke pixel density between the grid corresponding to the template font and the handwritten font as: ,in, Grid for template fonts Stroke pixel density, Grid for handwritten characters The stroke pixel density is calculated by comparing the density matrices of handwritten characters and template characters, and determining the following three dimensions:
[0116] Average Deviation: Average deviation is used to measure the average density difference between handwritten and template characters across the entire grid. The average deviation is defined as follows: for ,in, The smaller the value, the closer the handwritten character is to the template character in terms of overall density distribution;
[0117] Standard deviation: The standard deviation is used to measure the dispersion of the density differences among grid cells. Standard deviation Defined as , The smaller the value, the more evenly the density deviation between the handwritten characters and the template characters is distributed in each grid; if the value is large, it indicates that the deviation is significant in some local areas, and there are local over-density or under-density phenomena.
[0118] Entropy difference: The entropy difference is used to measure the difference in overall density distribution complexity between two things, and is defined as follows: ,in, , , , , The entropy difference The entropy value of the handwritten character. The entropy value of the template font;
[0119] The smaller the value, the closer the handwritten characters and template characters are in terms of overall density distribution complexity; the larger the value, the more obvious the difference between the two in terms of overall density distribution complexity.
[0120] Ultimately, the overall uniformity difference It can be represented as ,in, Let each component have a weight, and satisfy the following conditions: .when The smaller the size, the closer the handwritten characters are to the template characters in terms of overall density distribution, local fluctuations, and spatial organization; when A larger value indicates that the handwritten characters have problems such as excessive density in some areas, excessive sparseness in others, overall dispersion, or overall clustering. The system can then output a uniformity score and diagnostic feedback such as "local crowding," "overall looseness," and "imbalance in density."
[0121] The uniformity index score is defined as follows: .
[0122] To eliminate the impact of differences in the magnitude of various sub-indicators, the differences are further normalized. Let the normalized results of the mean deviation, standard deviation, and entropy difference be respectively... , and The normalized uniformity difference is then... Defined as ,in, The smaller the value, the higher the uniformity between the handwritten characters and the template characters. Correspondingly, the normalized uniformity index score... Can be defined as .
[0123] To determine the optimal grid partitioning, this embodiment analyzes it from three aspects: information entropy, time complexity, and relative efficiency. Taking 3×3 to 8×8 grids as examples, the theoretical maximum entropy of a 5×5 grid is 4.6439 bits, the template word entropy is 2.9964 bits, the average handwritten word entropy is 2.7458 bits, the mutual information is 1.4102 bits, the information loss rate (ILR) is 52.93%, and the relative efficiency is 36%, achieving the best balance between information quality and computational efficiency.
[0124] S32. The symmetry index is calculated using a multi-candidate axis competition method, specifically including:
[0125] Generate five types of candidate symmetry axes:
[0126] (1) Traditional median axis: determined based on the median of the column coordinates of all stroke pixels;
[0127] (2) Centroidal vertical axis: The horizontal centroid coordinates are calculated using column density as the weight;
[0128] (3) Maximum symmetry axis: The symmetry axis is searched within the centroid ±25% width range with a step size of 2. The comprehensive score is calculated based on the Pearson correlation coefficient, normalized difference value and stroke coverage. The one with the highest score is the best;
[0129] (4) Density-weighted centroidal axis: The position of the weighted average is calculated by performing a second weighting on the column density;
[0130] (5) Fine optimization of symmetry axis: Search for the symmetry axis with a step size of 1 within the width range of ±20% of the centroid, and use SSIM to replace the correlation coefficient to calculate the score. The one with the highest score is the best.
[0131] In one embodiment, through ablation experiments on 150 samples for each of the four categories of single-component characters "Xi", "Me", "Ri", and "Yan", it is determined that the fine optimization axis exhibits the best performance in cross-glyph adaptability and is the optimal symmetry axis. Its average score is 89.0347, and the standard deviation is 5.2569, which can effectively distinguish the structural differences between different handwritten samples.
[0132] After determining the optimal symmetry axis, the symmetry gap between the handwritten character and the template character is quantified from the following three dimensions.
[0133] Dimension one, comprehensive distribution feature gap , which is used to describe the differences in stroke density, standard deviation and local structure between the left and right mirror regions. A smaller value indicates that the left and right distribution is closer to the template.
[0134] Dimension two, the difference in the offset distance between the center of the circle and the centroid. Let the center of the character contour be , and the stroke centroid be , then the offset distance between the center of the circle and the centroid is: . Wherein, represents the offset distance between the center of the circle and the centroid, is the coordinate of the contour center, is the coordinate of the stroke centroid. The offset difference between the template character and the handwritten character is: . Wherein, represents the difference in the offset distance between the center of the circle and the centroid, represents the offset distance between the center of the circle and the centroid of the handwritten character, represents the offset distance between the center of the circle and the centroid of the template character.
[0135] Dimension three, mid-axis position difference , wherein, represents the deviation degree of the optimal symmetry axis of the handwritten character relative to the optimal symmetry axis of the template character, is the position of the optimal symmetry axis of the handwritten character, is the position of the optimal symmetry axis of the template character.
[0136] For single-component characters with a high degree of symmetry such as "Ri" and "Yan", an optional fourth dimension is additionally set, that is, the left-right balance difference. Let the total number of stroke pixels in the left and right regions be and respectively, then the left-right balance is: , represents a very small constant for preventing the denominator from being zero, and the left-right balance difference between the template character and the handwritten character is: , is the left-right balance difference of the handwritten character, is the left-right balance difference of the template character.
[0137] Finally, the comprehensive symmetry gap can be expressed as: .in, This indicates the overall difference in symmetry between handwritten characters and template characters; Let each component have a weight, and satisfy the following conditions: .when The smaller the size, the closer the handwritten character is to the template character in terms of left-right mirror image, overall center of gravity, spatial balance, and central axis position; when A large value indicates significant left-right imbalance, central axis shift, or local structural deformation. Based on this, the system can output a symmetry score and diagnostic feedback such as "left-right imbalance," "central axis shift," and "center of gravity deviation." The final symmetry index score is defined as follows: ,in, This is the symmetry score decay coefficient, used to control the rate at which scores decrease as the gap increases.
[0138] S33, the aspect ratio is calculated as follows:
[0139] Let the minimum bounding rectangle width of the foreground region of a certain Chinese character be... The height is The aspect ratio of the character is then defined as: .in, Indicates the aspect ratio of the whole character. Indicates the width of the circumscribed rectangle. Indicates the height of the bounding rectangle. This represents a minimal constant to prevent the denominator from being zero. When When, it indicates that the character shape is relatively wide; when When, it indicates that the character shape is relatively high or narrow; when At that time, it indicates that the overall shape of the character is relatively square.
[0140] The aspect ratios of the template text and the handwritten text are denoted as follows: , .in, Indicates the aspect ratio of the template text. Indicates the aspect ratio of handwritten characters. These represent the width and height of the bounding rectangle of the template text, respectively. These represent the width and height of the bounding rectangle of the handwritten text, respectively.
[0141] To describe the proportional deviation between handwritten and template text, the aspect ratio is based on the following three dimensions:
[0142] Dimension 1: Absolute difference in aspect ratio The smaller the value, the closer the overall proportion of the handwritten characters is to the template.
[0143] Dimension two, relative proportion difference, can eliminate the influence of different character scale proportions, defined as... It is used to measure the degree of deviation of handwritten characters from the proportion of template characters.
[0144] Dimension 3, Squareness Difference This is used to determine the deviation of the character shape from the square. Let the squareness be: .in, This indicates the degree to which the character deviates from a square shape. Among them... Indicates the squareness of handwritten characters. Indicates the squareness of the template text.
[0145] Ultimately, the overall difference in aspect ratio can be obtained by weighting multiple aspect ratio differences. .in, This represents the weighting coefficient for each component. A smaller value indicates a more harmonious proportion to the handwritten characters; a larger value indicates a more pronounced imbalance in the character proportions. Based on this, the system can determine whether the character shape is "proportion close to the template," "slightly wide," "significantly wide and flat," "slightly narrow," or "significantly narrow and tall." The final length-to-width ratio score is defined as follows: ,in, This is the aspect ratio score decay coefficient, used to control the rate at which the score decreases when the gap increases.
[0146] S34. The tilt index extracts attitude features from three core dimensions:
[0147] Dimension 1: Overall principal axis tilt reflects the overall deflection of the character relative to the vertical or horizontal reference direction. This is achieved by calculating the eigenvector corresponding to the largest eigenvalue of the covariance matrix of the foreground points of the handwritten and template characters, thus obtaining the overall principal axis angle of the handwritten and template characters. Let the overall principal axis angle of the template character be... The overall principal axis angle of handwritten characters is The difference in the overall principal axis angle between the handwritten characters and the template characters is then calculated. At the same time, when When the overall principal axis angle is defined as the positive direction, that is, the handwritten characters are more to the right than the template characters; when When the overall principal axis angle is defined as negative, that is, the handwritten characters are more to the left than the template characters; when When this occurs, the overall principal axis angle is defined as an invalid tilt angle.
[0148] Dimension Two: Multi-layered central axis tilt, with the outer frame of the character set as... ,in , These represent the leftmost and rightmost x-coordinates of the bounding box, respectively. , These represent the top and bottom ordinates of the bounding box, respectively. The bounding boxes of the handwritten and template characters are divided vertically into 12 horizontal strip regions. The median of the foreground pixel's x-coordinate in each layer is extracted as the center point, and a straight line is fitted to obtain... ,in, Indicates the first The ordinate of the center point of the layer, Indicates the first The x-coordinate of the layer center point This represents the slope of the fitted line. The intercept is represented by the fitted angle of the median, which is defined as follows: Let the fitted angle of the multi-layered central axis of the handwritten character be... The fitted angle of the multi-layered centerline of the template character is The difference in the fitted angle of the multi-layer central axis between the handwritten characters and the template characters is then calculated as follows: .when When the tilt angle of the multi-layered central axis is defined as the positive direction, that is, the handwritten characters are tilted to the right compared to the template characters; when When the tilt angle of the multi-layered central axis is defined as negative, that is, the handwritten characters are tilted to the left compared to the template characters; when When this is the case, the tilt angle of the multi-layer centerline is defined as an invalid tilt angle.
[0149] Dimension 3: Left and right boundary tilt. Similarly, the outer frame of the handwritten and template characters is divided into 12 horizontal strip regions along the vertical direction. The 10th and 90th percentiles of the foreground horizontal coordinate of each layer are taken as the left and right boundary points, and the left boundary angle is obtained by fitting. and right boundary angle Take the average Let the combined tilt angle of the left and right boundaries be . Let the combined tilt angle of the left and right boundaries of the template text be . The combined tilt angle of the left and right edges of the handwritten characters is Obtain the difference in tilt angle between the left and right boundaries. At the same time, when When the left and right boundary tilt angles are defined as positive, that is, the handwritten characters are tilted to the right compared to the template characters; when When the left and right boundary tilt angles are defined as negative, that is, the handwritten character is tilted to the left compared to the template character; when When this occurs, the tilt angles of the left and right boundaries are defined as invalid tilt angles.
[0150] Tilt type identification is performed based on three-dimensional posture features, including five types: basically stable, overall tilt, local anomaly, boundary deviation, and mixed uncertainty. Different deduction strategies are adopted for different types.
[0151] The numerical determinations for the five types of tilt are as follows:
[0152] Basically stable: when The character is considered basically stable at this point. This indicates that the overall shape of the character is upright.
[0153] Overall tilt: when , , If all three conditions are met simultaneously, it is considered an overall tilt. This indicates that the central axis, boundaries, and principal axes are all significantly tilted.
[0154] Local anomalies: when , ,but This is judged as a local anomaly. It indicates that the central axis and boundaries are stable, and the anomaly of the main axis may be caused by local strokes.
[0155] Boundary skew: when ,and This indicates a boundary deviation. It means the central axis is relatively stable, but the outer contour is significantly skewed.
[0156] Mixed uncertainty: If it does not meet any of the above explicit types, it is classified into this category, indicating that the sources of the tilt are mixed and cannot be clearly classified.
[0157] The tilt index uses a deduction system.
[0158] The overall principal axis deflection deduction is used to evaluate whether the principal direction of the overall stroke pixel distribution of the character being evaluated has deflected relative to the template. The overall principal axis angle difference value is... The overall main axis angle of the template text is The original spindle deflection ratio is A principal axis correction factor is introduced based on the tilt type. When the overall tilt is determined to be tilted, the penalty for spindle deflection is increased. When an anomaly is identified as local, it is believed that the main axis anomaly may be caused by interference from local strokes, thus the deduction is significantly reduced. In other cases, the points deduction should be appropriately reduced. The corrected spindle deflection ratio is: Overall spindle deflection deduction according to Segmentation determination .
[0159] The fitted angles of the multi-layered central axis are used for relative template consistency evaluation and absolute verticality evaluation, respectively. The relative template consistency evaluation is used to determine the angular difference between the central axis of the handwritten character and the central axis of the template, while the absolute verticality evaluation is used to determine the degree to which the central axis of the handwritten character deviates from the vertical direction. The two are included in the total deduction as deduction items of different dimensions.
[0160] The multi-layer centerline fitting angle deviation score is used to evaluate the degree of deviation of the central axis trend of the character being evaluated from the central axis trend of the template character. The multi-layer centerline fitting angle difference value is... The fitted angle of the multi-layered centerline of the template character is Original multi-layer centerline deviation ratio An orientation correction factor is introduced based on whether the handwritten characters are closer to the vertical direction than the template characters. When the handwritten characters are closer to the vertical direction than the template characters, the penalty is reduced; when the handwritten characters deviate more from the vertical direction than the template characters, the penalty is increased; when the verticality of the two is roughly equal, no correction is made. The corrected deviation ratio of the multi-layered center line is... Deduction for deviation of the fitted angle of the multi-layer centerline. according to Segmentation determination .
[0161] The absolute tilt deduction for the multi-layered centerline is used to evaluate whether the centerline of the character being evaluated deviates from the vertical direction, and is no longer compared with the template difference. The absolute value of the fitting angle of the multi-layered centerline of the handwritten character is... Deductions for absolute tilt of the multi-layered central axis Determined according to the following rules In other words, the further the center line of the character being evaluated deviates from the vertical direction, the higher the deduction score.
[0162] The left and right boundary tilt deviation deduction is used to evaluate the tilt difference between the left and right outer contour boundaries of the character being evaluated and the template character. The absolute difference value of the left and right boundary tilt angle. The original boundary deviation ratio is A boundary term correction factor is introduced based on the tilt type. When the tilt type is overall tilt or boundary skew, When the tilt type is local noise, When other types of tilt occur, The corrected boundary deviation ratio is Points will be deducted for tilting or deviating from the left and right boundaries. according to Segmentation determination .
[0163] The tilt direction consistency deduction is used to determine whether multiple tilt features of the character being evaluated tilt in the same direction. The tilt direction consistency deduction is defined as follows: If there are fewer than two effective tilt angles among the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle, or if their directions are inconsistent, then... If two of the following have the same direction: the fitting angle of the multi-layer centerline, the tilt angles of the left and right boundaries, and the overall principal axis angle, then If multiple indicators among the multi-layer centerline fitting angle, left and right boundary tilt angle, and overall principal axis angle tilt in the same direction simultaneously, it indicates that the character being evaluated has an overall tilting trend, and therefore additional points will be deducted. If all three directional indicators are consistent and the slope of the centerline exceeds [a certain value], then [the situation is as follows]. The overall tilt is considered more pronounced. Increased to 8 points.
[0164] According to the segmented deduction rules, the cumulative deduction points are obtained. : The final tilt index score is obtained. .
[0165] In step S4, the preprocessed single-character calligraphy image and the template character image are compared and calculated based on the stroke level index to obtain the stroke level difference value, and then the scores of each stroke level index are obtained.
[0166] In this embodiment, the stroke hierarchy index includes the stroke compactness index, the stroke topology index, and the stroke relative position index. After calculating each index, the difference value of each index is obtained by subtracting the calculation result of the handwritten character from the calculation result of the template character.
[0167] S41. The stroke compactness index is calculated as follows:
[0168] Let a single-component character have a total of Strokes, number The strokes are recorded as , The number of strokes;
[0169] Stroke compactness mainly includes three dimensions:
[0170] Overall Proximity Dimension: Overall proximity is used to characterize the overall closeness between strokes within the entire character. For any two different strokes... and Its proximity is denoted as To reflect the different impacts of different stroke relationships on the overall character structure, a weighting of strokes is introduced. The weights satisfy The overall proximity is defined as... When handwritten When the characters are significantly higher than the template characters, it indicates that the strokes are closer together overall, possibly indicating a tighter writing style; when handwritten characters... When the strokes are significantly lower than the template characters, it indicates that the strokes are more dispersed overall, and may be too loose.
[0171] Starting distance dimension: The starting distance index is used to characterize the spatial distribution between the starting points of each stroke. Let the first... The starting point of the stroke is , No. The starting point of the stroke is The distance between the starting points of two strokes is defined as follows: To eliminate the influence of differences in character size, the starting stroke distance is normalized. ,in, This represents the diagonal length of the outer frame of the entire character. The average starting stroke distance is defined as: When handwritten When the size is larger than the template character, it indicates that the starting points are scattered; when the handwritten character... When the size is smaller than the template character, it indicates that the starting points are distributed too densely.
[0172] Ending stroke distance dimension: The ending stroke distance index is used to characterize the spatial distribution between the ending points of each stroke. Let the first... The ending point of the stroke is , No. The ending point of the stroke is The distance between the ending points of two strokes is defined as follows: Normalize the distance at the end of the stroke. ,in This is the length of the diagonal of the character's outer frame. The average stroke ending distance is defined as... When handwritten When the strokes are larger than the template characters, it indicates that the ending points are scattered and the character's overall form is not sufficiently concentrated; when handwritten characters... When the size is smaller than the template character, it indicates that the distribution of the ending points is too dense, and there may be a crowded ending point.
[0173] Overall deviation of stroke compactness: Let the three indicators corresponding to the template character be as follows: , , The three indicators corresponding to handwriting are as follows: , , The overall proximity deviation, starting distance deviation, and ending distance deviation are respectively defined as follows: , , The overall deviation of stroke compactness is defined as follows: Each weight satisfies .
[0174] Based on the overall deviation of stroke compactness The stroke compactness index score is obtained. : ,in, This represents the overall deviation deduction coefficient.
[0175] S42. The stroke topological relationship index is calculated as follows:
[0176] Figure 4 This is a schematic diagram illustrating the classification of stroke topological relationships in one embodiment of the present invention. For example... Figure 4 As shown, stroke topology is used to describe the spatial connection state between any two strokes. Figure 4The left-hand diagram illustrates the three states of intersection, connection, and adjacency, corresponding to the three stroke intersection, connection, and adjacency states on the right. The numbers 1, 2, 3, and 4 in the right-hand diagram represent the order of the corresponding strokes. To improve the accuracy and computational efficiency of topological relationship determination, this invention employs a layered calculation method of "bounding box coarse screening—local pixel verification" to construct a stroke topological relationship matrix. This indicator primarily reflects the correctness of stroke structural relationships and is used to distinguish the differences in stroke connection methods between handwritten characters and template characters.
[0177] Outer frame coarse screening section: Let the first... The foreground pixel set of the stroke is Its outer frame is For any two strokes, first calculate the minimum distance between their bounding boxes: If the following conditions are met: If the two strokes are clearly separated and have no topological relationship, then it is considered that the two strokes are clearly separated and have no topological relationship. This is the adjacency distance threshold. If If the stroke pair is deemed to have the potential to intersect or be adjacent, it is considered a candidate stroke pair. Local pixel verification is then performed within the union or extended union region of the two bounding boxes. Overlap detection, minimum boundary distance detection, or contact detection are performed on the foreground pixel sets of the two candidate strokes to determine whether the stroke pair belongs to an adjacent, connected, or intersecting relationship. The extended union region refers to the local region obtained by expanding the union region outwards by a preset pixel boundary.
[0178] The topological relationships of strokes are divided into three categories: intersection, connection, and adjacency. Indicates the stroke number of the two relationships to be determined, and , Indicates the first The strokes and the first The actual number of overlapping pixels of the strokes within the local verification area. Indicates the first The strokes and the first The overlap rate of the overlapping areas of individual strokes relative to the overall overlap of the joined areas is used to reflect the degree of overlap between the two sides. This indicates the maximum coverage of the overlapping area of strokes relative to the area of a single stroke, reflecting the degree to which one stroke covers another on one side. Indicates the first The strokes and the first Number of pixels at the boundary of a stroke. Indicates the first The strokes and the first The number of pixels close to or adjacent to a stroke after neighborhood expansion;
[0179] Intersection: Two strokes intersect in a localized area, or one stroke clearly covers another, satisfying the following conditions: and ;
[0180] Contact: Two strokes have boundary contact, end overlap, or slight local overlap, but the overlap intensity does not reach the threshold for "intersection." This is to accommodate situations in natural writing where strokes do not extend beyond the line but still visually form a connection, satisfying the requirement of... and Satisfy any one of them, and ;
[0181] Adjacency: Two strokes that do not overlap in pixels, but are close to each other after neighborhood expansion, satisfying the condition... and and .
[0182] in, Threshold for determining intersection relationship and These are the weight parameters for overlap ratio and coverage ratio, respectively.
[0183] By traversing the candidate stroke pairs, the stroke topology relation matrix can be obtained. The topology relation type of each stroke pair is determined, and the template character topology relation matrix is constructed. Topological relationship matrix with handwritten characters The relation type is encoded as follows: 0 for adjacent, 1 for connected, and 2 for intersection. For any pair of strokes... The difference in their stroke topological relationships is defined as follows: , For matrix The elements in For matrix The elements in the matrix. During scoring, the stroke topology relationship matrices of the template characters and the handwritten characters are compared. Differences are calculated based on the consistency of the relationships, and a stroke topology relationship score is obtained by combining weights and a Gaussian function. ,in Differences in stroke topology. To adjust the parameters, weights The importance of strokes in the character structure can be set according to their relative importance, or a uniform weight can be used.
[0184] To enhance the constraints on critical structural errors, additional statistics are compiled on serious errors such as missing critical intersection relationships, abnormally added intersection relationships, and structural relationship offsets. The number of serious errors is defined as follows: Then the penalty term can be written as ,in The penalty coefficient for a single serious error.
[0185] Constructing penalty terms , The final stroke topology relationship index score is defined as the maximum penalty value: .
[0186] If a critical intersection relationship is missing, an abnormally added intersection relationship occurs, or a structural relationship is shifted, a penalty term will be added. : .
[0187] S43. The relative position index of strokes is calculated as follows:
[0188] The relative position index of strokes is used to characterize the layout and organization of each stroke within a Chinese character in the overall character space. By extracting features such as the geometric center, starting point, and ending point of each stroke, the organizational characteristics of each stroke relative to the center of the entire character are constructed, and based on this, the differences in stroke layout coordination between the handwritten character under test and the template character are quantified. Suppose a Chinese character contains multiple strokes; for each stroke, its pixel region is extracted. The centroid of a stroke can be represented as The starting point is represented as The ending point is represented as The centroid of all strokes in the entire character is calculated and used as the character's center. This center serves as the unified reference center for the relative positional relationships of all strokes. The entire character's center can be represented as... .
[0189] The relative position index of strokes includes the following four dimensions:
[0190] Central aggregation degree: The central aggregation relationship describes the distribution of the centroids of each stroke around the center of the entire character. For each stroke, the distance from its centroid to the center of the character is calculated, and the central aggregation degree at the whole-character level is obtained by statistically analyzing all strokes. After calculating the corresponding central aggregation features of the handwritten character to be tested and the template character, the difference between the two is taken to obtain the central aggregation difference. Let... This represents the central aggregation feature of the handwritten character under test. The central aggregation feature of the template characters, and the difference in central aggregation degree can be expressed as: ;
[0191] Starting Stroke Organization: Starting stroke organization describes the spatial organization of the starting positions of each stroke within the entire character. The starting stroke organization is defined as... ,in In the formula, Indicates the first The starting point of a stroke. Indicates the core of the whole character. and They represent the first The starting point and the first stroke of a line The unit direction vector of the starting point of each stroke relative to the center of the character. The starting point organization reflects the consistency of the starting direction of each stroke. A larger value indicates a more unified spatial organization of the starting positions of each stroke; a smaller value indicates a more dispersed distribution of starting points. Let... This indicates the degree of organization of the starting strokes of the handwritten character being tested. This indicates the degree of organization of the starting strokes in the template characters. Differences in the degree of organization of starting strokes can be expressed as... ;
[0192] Stroke ending organization: Stroke ending organization describes the spatial organization of the ending positions of each stroke within the entire character. The stroke ending organization is defined as... ,in In the formula, Indicates the first The ending point of a stroke. Indicates the core of the whole character. and They represent the first The ending point of a stroke and the first The unit direction vector of the stroke's ending point relative to the character's center. Stroke ending organization reflects the consistency of the ending directions of each stroke. A larger value indicates a more unified and convergent ending characteristic for each stroke; a smaller value indicates a more dispersed distribution of endings, resulting in a weaker overall character ending. Let... This indicates the degree of organization at the end of the strokes in the handwritten character being tested. This indicates the degree of organization at the end of a character's strokes. Differences in the degree of organization at the end of a stroke can be expressed as... ;
[0193] Beginning and ending stroke correspondence: The correspondence between beginning and ending strokes describes the consistency between the starting and ending trends of each stroke itself, as well as the overall trend between multiple strokes, reflecting whether the strokes of the whole character are continuous and whether the structure is natural. The beginning and ending stroke correspondence is defined as... ,in In the formula, and They represent the first Strokes and the first A stroke is a unit direction vector pointing from its starting point to its ending point. The start-end correspondence reflects the consistency of the starting and ending trends of each stroke. A larger value indicates more harmonious trends among the strokes and a stronger overall correspondence; a smaller value indicates greater differences in the trends of the strokes and insufficient overall continuity. Let... This indicates the degree of correspondence between the beginning and end strokes of the handwritten character being tested. This indicates the degree of correspondence between the starting and ending strokes of the template characters. The difference in the degree of correspondence between the starting and ending strokes can be expressed as... ;
[0194] Ultimately, the combined difference in the relative positions of the strokes can be expressed as: .in, This indicates the overall difference in the relative positions of strokes between handwritten characters and template characters; Let each component have a weight, and satisfy the following conditions: The final stroke relative position index score is defined as follows: ,in, The scoring coefficient is the relative position of the strokes.
[0195] In step S5, based on the whole character level difference value and the stroke level difference value, combined with the preset weight configuration, a comprehensive score is calculated, and evaluation feedback information is generated based on the threshold diagnosis rule. This specifically includes the following sub-steps:
[0196] S51, Template Library Construction and Caching Mechanism
[0197] The template's feature vector components are defined as follows: grid density matrix, symmetry index vector, aspect ratio index vector, slant index vector, stroke compactness index vector, stroke topology matrix, and stroke relative position index vector. When a user uploads handwritten characters and specifies a template character, the template library is first queried. If the template exists, it is directly deserialized, skipping all preprocessing and feature extraction calculations. If the template is not found, the complete calculation process is executed, and the result is written to the template library.
[0198] S52, Overall Scoring Formula
[0199] Define the overall scoring formula as follows: ,in, Indicates the first The scores corresponding to each evaluation indicator , , , , , , ; The weights of each indicator can be configured by the user and satisfy the following conditions: ,when A higher value indicates that the handwritten character is closer to the template character in terms of overall structure, spatial distribution, and stroke organization; when A low score indicates that the handwritten character deviates significantly from the template character in multiple dimensions. Based on this, the system can output a total score for the Chinese character and provide targeted diagnostic feedback based on the scores of each sub-item.
[0200] Furthermore, a user-defined weight configuration mechanism is set up, allowing users to manually adjust various weights through a slider interface.
[0201] S53, Threshold Diagnosis Rules and Their Mapping with Calligraphic Aesthetics
[0202] Establish threshold diagnostic rules for each indicator:
[0203] Uniformity index: This triggers diagnoses such as overall density abnormalities, overall looseness, and overall crowding. This triggers a diagnosis of severe density fluctuations;
[0204] Symmetry index: The strokes are judged to be unbalanced, with the center of gravity of the strokes clearly shifting to one side, resulting in structural instability. The determination of local effective symmetry indicates that the differences in distribution characteristics between the left and right regions are within an acceptable range. (Pixels) triggers a central axis offset, meaning the symmetry axis of the handwritten character deviates from the template axis. and The primary cause of the problem is mirror image differences, meaning there are significant differences in the statistical values of the left and right pixels, but the overall center of gravity remains unchanged, and the issues are mostly localized stroke deformations. and The main cause of the judgment is the shift in the center of gravity, that is, the distribution of pixels on the left and right is similar, but the overall center of gravity is drifted, which is mostly triggered by the skewing of the characters.
[0205] Aspect ratio: The proportions are well-coordinated, the characters are square and neat, and the aspect ratio matches the template height. The proportions are generally harmonious, with only slight deviations that do not affect the overall aesthetic appeal. The proportions are generally not well-coordinated, with significant deviations that require adjustment. The proportions are not well-coordinated and the shape is severely distorted, so it is necessary to re-understand the rules of character formation.
[0206] The character is clearly too wide and flat, with its horizontal shape excessively extended, giving it a flattened appearance. The character width is slightly too wide and the shape is somewhat flat; the horizontal width could be appropriately tightened. The proportions are close to the template, and the aspect ratio is within a reasonable range. The character is slightly narrow and thin; the horizontal width could be increased appropriately. The character is clearly too narrow and too tall, with excessive vertical extension, giving it an elongated appearance.
[0207] Inclination index: when When the time is determined to be basically stable, it means that the overall shape of the character is upright. , , When all three conditions are met, an overall tilt is determined, indicating that the central axis, boundary, and principal axis are all significantly tilted. , ,but When a local anomaly is identified, it indicates that the central axis and boundaries are stable. Anomalies in the main axis may be caused by local strokes. ,and If the boundary is determined to be skewed, it indicates that the central axis is relatively stable, but the outer contour is obviously skewed.
[0208] Stroke compactness index: The overall structure is deemed too loose, with excessively large average distances between strokes and scattered internal space within the characters. The overall strokes are too tight, with the average distance between strokes being too small, posing a risk of them sticking together. The initial strokes were deemed too scattered. The initial strokes were deemed too dense. The strokes were judged to be too scattered at the end. The conclusion was that the strokes were crowded at the end.
[0209] Stroke topological relationship index: Topological relationship type is coded as follows: adjacent is 0, connected is 1, and intersecting is 2. For any stroke pair The difference in their stroke topological relationships is defined as follows: , Strokes With strokes The relationship is correct and consistent with the template. Strokes With strokes Relationships are misaligned; for example, "intersection" should be "connection" but it is actually "adjacent," or "connection" should be "adjacent" but it is actually "adjacent." Strokes With strokes The relationships are incorrect; the concepts of "intersection" and "adjacency" are confused, and the structural relationships are severely deviated from their intended basis. The actual situation is determined to be either a missing key "intersection" or an abnormally added "intersection".
[0210] Stroke relative position index: The judgment center is scattered, the centroids are distributed and dispersed around the character center, and the whole lacks cohesion. The judgment is that the strokes are disordered, the starting directions are scattered, and there is a lack of unified stroke momentum at the beginning. The character's overall form is judged to be scattered at the end of strokes, with inconsistent stroke directions, and an inability to control the flow of the character. The strokes are deemed broken, lacking connection between their starting and ending directions, and the writing process is disjointed.
[0211] Furthermore, a mapping model of calligraphy concepts and computational indicators is established: density corresponds to "white space", symmetry corresponds to "symmetry", proportion corresponds to "character structure", slant corresponds to "uprightness", compactness corresponds to "interweaving", topology corresponds to "connection", and position corresponds to "echoing".
[0212] In this invention, the comprehensive scoring provides an overall score for handwritten characters, while the threshold diagnosis provides a detailed evaluation of handwritten characters and directions for optimization.
[0213] S54, Visual Feedback
[0214] Four visual outputs are generated through the visual interface:
[0215] Density heatmap overlay: The density matrices of handwritten text and template text are overlaid in the form of a semi-transparent heatmap. The red area indicates that the handwritten text is relatively too dense, the blue area indicates that it is relatively too sparse, and the green area indicates that the match is good.
[0216] Symmetry axis deviation annotation: Draw the centerline of the template character and the centerline of the handwritten character on the image, and annotate the horizontal offset pixel value;
[0217] Problematic stroke highlighting: Mark each problematic stroke on the image and suggest modifications;
[0218] Improved directional arrows: Based on the relative position index of strokes, calculate the vector that the centroid of each stroke should be adjusted toward the template, and mark the suggested movement direction and relative distance on the image with arrows.
[0219] In summary, the single-character calligraphy evaluation system based on structural features provided in this invention can solve the technical problems of existing automatic calligraphy evaluation technologies, such as the lack of a targeted evaluation system for single-characters, the separation of whole-character and stroke indicators, and the lack of semantic mapping of calligraphy aesthetics in the evaluation results. It enables professional and objective evaluation of the writing quality of single-characters by computer, and has the following advantages:
[0220] 1) A two-level evaluation system specifically designed for single-component characters is adopted, which organically integrates whole-character level indicators with stroke level indicators, forming a complete evaluation chain from macro-form to micro-strokes, and has a good evaluation accuracy for single-component characters with different numbers of strokes.
[0221] 2) The multi-candidate axis competition method generates diverse candidate central axes and selects the optimal solution, which breaks through the limitations of traditional central axis positioning methods and significantly improves the robustness of symmetry evaluation in handwritten deformation scenarios.
[0222] 3) Based on the summary and generalization of the evaluation criteria for single-character calligraphy, a two-way mapping model of calligraphy concept-calculation index is established to make the evaluation feedback both scientific and cultural, and can be directly understood by teachers and students in calligraphy teaching scenarios, thus extending the advantages of image processing to the field of calligraphy education.
[0223] 4) The template library caching mechanism significantly reduces the average time for single-character evaluation, and the efficiency improvement is even more significant in batch evaluation scenarios, making it more suitable for real-time calligraphy teaching system applications.
[0224] Based on the above-mentioned inventive concept, the present invention also provides a single-component character calligraphy evaluation system based on structural features, used to implement the above-mentioned single-component character calligraphy evaluation method based on structural features. The system includes:
[0225] The image acquisition module is used to acquire the calligraphy image of the single-component character to be evaluated and the corresponding template character image; the single-component character refers to a Chinese character with only one single form, and the template character is written by a calligraphy expert; the single-component character to be evaluated is handwritten by the person being evaluated by copying the template character.
[0226] The preprocessing module is used to preprocess the single-character calligraphy image and the template character image respectively;
[0227] The whole character level evaluation module is used to compare and calculate the preprocessed single-character calligraphy image and the template character image based on the whole character level index to obtain the whole character level index difference value and the whole character level index score. The whole character level index includes uniformity index, symmetry index, length-width ratio index and tilt index.
[0228] The stroke level evaluation module is used to compare and calculate the preprocessed single-character calligraphy image and the template character image based on the stroke level index, and obtain the stroke level index difference value and the stroke level index score. The stroke level index includes the stroke compactness index, the stroke topological relationship index and the stroke relative position index.
[0229] The comprehensive evaluation module is used to perform a weighted summation of the whole character level index score and the stroke level index score to obtain the comprehensive score of the single-component calligraphy to be evaluated.
[0230] It is worth noting that the system embodiment corresponds to the above method embodiment. The implementation methods of the above method embodiments are all applicable to the system embodiment and can achieve the same or similar technical effects, so they will not be described in detail here.
[0231] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application 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.
[0232] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. 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... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0233] 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.
[0234] 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.
[0235] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for evaluating the calligraphy of single-component characters based on structural features, characterized in that, include: Obtain the calligraphy images of the single-component characters to be evaluated and their corresponding template character images; The term "single-component character" refers to a Chinese character that has only one single form, and the template characters are written by calligraphy experts. The single-component characters to be evaluated are handwritten by the person being evaluated, who copies the template characters. The single-character calligraphy image and the template character image are preprocessed respectively; The preprocessed single-character calligraphy image and the template character image are compared and calculated based on the whole-character level index to obtain the whole-character level index difference value and the whole-character level index score. The whole-character level index includes uniformity index, symmetry index, length-width ratio index and tilt index. The preprocessed single-character calligraphy image and the template character image are compared and calculated based on the stroke level index to obtain the stroke level index difference value and the stroke level index score. The stroke level index includes the stroke compactness index, the stroke topological relationship index and the stroke relative position index. The comprehensive score for the calligraphy of the single-component character is obtained by weighting and summing the scores of the whole character level index and the stroke level index.
2. The method for evaluating single-component calligraphy based on structural features according to claim 1, characterized in that: The preprocessing includes grayscale conversion, binarization, color inversion, centroid alignment, and scaling normalization to obtain a normalized binary image.
3. The method for evaluating single-component calligraphy based on structural features according to claim 2, characterized in that: The calculation of the difference value and index score of the uniformity index includes: The normalized binary image is divided into... For each grid, the stroke pixel density is calculated. The stroke pixel density of the grid is calculated using the pixel mean of the image after color inversion. Define the stroke pixel density difference between the template font and the corresponding grid of the handwritten font. for: ,in, Grid for template fonts Stroke pixel density, Grid for handwritten characters Stroke pixel density; based on Calculate the average deviation, standard deviation, and entropy difference between the template characters and the handwritten characters, and normalize them to obtain the normalized uniformity composite difference, expressed as: ,in, The difference in uniformity after normalization. The normalized mean deviation, The normalized standard deviation The normalized entropy difference, As weight; Normalized evenness index score The calculation is as follows: .
4. The method for evaluating single-component calligraphy based on structural features according to claim 2, characterized in that: The calculation of the difference value and index score of the symmetry index includes: Five types of candidate symmetry axes are generated: traditional median axis, centroidal vertical axis, maximum symmetry axis, density-weighted centroidal axis, and fine-optimized symmetry axis. The optimal axis of symmetry was determined through ablation experiments; The comprehensive difference in distribution characteristics between template characters and handwritten characters was calculated based on the optimal axis of symmetry. Difference in offset distance between center and centroid Differences in the position of the central axis and differences in left and right balance And calculate the symmetry comprehensive gap. , represented as: ,in, As weight; Calculate the symmetry index score , represented as: ,in, This is the attenuation coefficient for symmetry scoring.
5. The method for evaluating single-component calligraphy based on structural features as described in claim 2, characterized in that: The difference value and score calculation of the aspect ratio index include: Extract the smallest bounding rectangle of the foreground region of the whole character and calculate the aspect ratio; Based on the aspect ratio of the template font and the handwritten font, the absolute difference in the length-to-width ratio is calculated. Relative proportion difference Difference in squareness And calculate the overall difference in aspect ratio. , represented as: ,in, As weight; Calculate the aspect ratio score , represented as: ,in, This is the aspect ratio score attenuation coefficient.
6. The method for evaluating single-component calligraphy based on structural features as described in claim 2, characterized in that: The calculation of the difference value and index score of the tilt index includes: Calculate the overall principal axis angle, multi-layer centerline fitting angle, and left and right boundary tilt angles for both handwritten and template characters. Also, calculate the difference in the overall principal axis angle between the handwritten and template characters. Multi-layer centerline fitting angle difference value Difference value between left and right boundary tilt angles ; Based on the overall principal axis angle difference value Multi-layer centerline fitting angle difference value Difference value between left and right boundary tilt angles The tilt type is identified, including basically stable, overall tilt, local anomaly, boundary skew, and mixed uncertainty. Based on the overall principal axis angle difference value Calculate the overall principal axis deflection deduction based on the tilt type: , , , in, Deduct points for overall spindle deflection. This is the corrected spindle deflection ratio. This is the correction factor for the main axis term, set according to the tilt type. This represents the original spindle deflection ratio. The overall main axis angle of the template text; Based on the multi-layered centerline fitting angle difference value Calculate the deviation deduction for the fitted angle of the multi-layer centerline: , , , , in, Deductions are made for deviations in the fitting angle of the multi-layer centerline. The corrected deviation ratio of the multi-layered centerline. This represents the original multi-layered centerline deviation ratio. This is the direction correction factor. The fitting angle for the multi-layer centerline of the template character. Fitting angles for the multi-layered central axis of handwritten characters; Calculation of absolute tilt deduction for multi-layer central axis based on the fitting angle of the multi-layer central axis of handwritten characters: , , in, Deductions will be made for the absolute tilt of the multi-layered central axis. The absolute value of the fitted angle for the multi-layered central axis of the handwritten character; Based on the difference in the tilt angles of the left and right boundaries Calculate the deduction for tilt deviation of the left and right boundaries based on the tilt type: , , , in, Points will be deducted for tilting or deviating from the left and right boundaries. The corrected boundary deviation ratio. The deviation ratio of the original boundary. The boundary term correction factor is set according to the tilt type. The tilt angle of the left and right boundaries of the template text; Calculate the deduction for consistency in tilt direction: Define the deduction for consistency in tilt direction as... If the effective tilt angles among the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle are less than two or their directions are inconsistent, then If two of the following have the same direction: the fitting angle of the multi-layer centerline, the tilt angles of the left and right boundaries, and the overall principal axis angle, then If the indices in the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle all tilt in the same direction, then If the indices in the multi-layer centerline fitting angle, left and right boundary tilt angles, and overall principal axis angle are all consistent and the centerline tilt exceeds [a certain value], then [the following conditions apply]. ,but The effective tilt angle refers to , , The value is not 0; Calculate the cumulative deduction points , represented as: ; Calculate the tilt index score , represented as: .
7. The method for evaluating single-component calligraphy based on structural features according to claim 2, characterized in that: The difference value and score of the stroke compactness index are calculated as follows: Calculate the overall proximity, average starting stroke distance, and average ending stroke distance for both handwritten and template characters. The difference in indicators is calculated based on the overall proximity of the handwritten characters and the template characters, the average starting distance, and the average ending distance, including: overall proximity deviation, starting distance deviation, and ending distance deviation. The overall deviation of stroke compactness is calculated based on the difference values of the aforementioned indicators and is expressed as follows: ; The stroke compactness index score is calculated and expressed as follows: ; in, The overall deviation is due to the compactness of the strokes. Scoring is given based on the stroke compactness index. For overall proximity deviation, This is due to the deviation in the starting distance. Due to deviation in the distance at the end of the stroke, , and All are weights. This is the comprehensive deviation deduction coefficient.
8. The method for evaluating single-component calligraphy based on structural features according to claim 2, characterized in that: The index difference value and index score of the stroke topology relationship index are calculated as follows: For both handwritten and template characters, calculate the minimum distance between the bounding boxes of any two strokes. If the distance is less than or equal to a preset threshold, it is determined that there is a topological relationship, and the two strokes are selected as candidate stroke pairs. Calculate the actual number of overlapping pixels of the candidate stroke pairs within the local verification region. The overlap rate of the stroke overlap area of the candidate stroke pair relative to the overall overlap rate of the joint region. The maximum coverage of the overlapping area of candidate stroke pairs relative to the area of a single stroke. Number of pixels in contact at the stroke boundary of candidate stroke pairs The number of adjacent pixels of candidate stroke pairs after neighborhood dilation The joint region refers to the union or extended union region of the two bounding boxes of the candidate stroke pair; based on , , , and Determine the stroke topological relationship of the candidate stroke pairs, if and Then the stroke topological relationship is intersection; if and Satisfy any one of them, and Then the stroke topological relationship is connected; if and and If the stroke topological relationship is , then the stroke topological relationship is adjacent; where, Threshold for determining intersection relationship, and These are the weight parameters for overlap ratio and coverage ratio, respectively. The stroke topology matrix is obtained by traversing the candidate stroke pairs. Using 0 for adjacent characters, 1 for connected characters, and 2 for intersection characters, calculate the difference in stroke topological relationships between handwritten characters and template characters, represented as follows: ,in Candidate stroke pairs for handwritten and template characters and Differences in the topological relationships of strokes. Candidate stroke pairs for template characters and The stroke topological relationship values, Candidate stroke pairs for handwritten characters and The stroke topological relationship values; The stroke topological relationship index score is obtained by combining weights and a Gaussian function: ; Introduce a penalty term: , The stroke topological relationship index score with the inclusion of a penalty term is expressed as: ; in, Scoring of stroke topological relationship indicators. To introduce a penalized scoring method for the stroke topology relationship index, The number of strokes. As weight, To adjust the parameters, As a penalty item, The penalty coefficient for a single serious error. The number of critical errors. This is the maximum penalty value.
9. The method for evaluating single-component calligraphy based on structural features according to claim 2, characterized in that: The difference value and score of the relative position index of the strokes are calculated as follows: The center cohesion, stroke organization, stroke ending organization, and stroke beginning and ending correspondence are calculated for both handwritten and template characters. Differences in center cohesion, stroke organization, stroke ending organization, and stroke beginning and ending correspondence between handwritten and template characters are also calculated. The center cohesion refers to the distance from the centroid to the character center for each stroke, statistically analyzed across all strokes to obtain the center cohesion at the whole-character level. The stroke beginning organization is calculated as follows: ,in, Indicates the degree of organization at the beginning of the stroke. and They represent the first The starting point and the first stroke of a line The unit direction vector of the starting point of a stroke relative to the center of the character. The number of strokes. , Indicates the first The starting point of a stroke. Indicates the core of the entire character; the calculation of the ending stroke organization degree is as follows: ,in, Indicates the degree of organization at the end of the stroke. and They represent the first The ending point of a stroke and the first The unit direction vector of the ending point of a stroke relative to the center of the character. , Indicates the first The ending point of a stroke; the calculation of the beginning and ending stroke correspondence is as follows: ,in, Indicates the degree of correspondence between the beginning and end of a stroke. and They represent the first Strokes and the first A single stroke is a unit direction vector from the starting point to the ending point. ; Based on the differences in center cohesion, starting stroke organization, ending stroke organization, and starting and ending stroke correspondence between the handwritten and template characters, the comprehensive difference in the relative positions of the strokes is calculated. , represented as: ,in, Indicates the difference in central aggregation degree. This indicates differences in the organization of the initial strokes. Indicates differences in the organization of the strokes at the end. This indicates a difference in the degree of correspondence between the beginning and end of a stroke. As weight; Calculate the relative position index score of strokes , represented as: ,in, The scoring coefficient is the relative position of the strokes.
10. A single-component character calligraphy evaluation system based on structural features, characterized in that, The system for implementing the structural feature-based single-character calligraphy evaluation method according to any one of claims 1 to 9, the system comprising: The image acquisition module is used to acquire the calligraphy image of the single-component character to be evaluated and the corresponding template character image; the single-component character refers to a Chinese character with only one single form, and the template character is written by a calligraphy expert; the single-component character to be evaluated is handwritten by the person being evaluated by copying the template character. The preprocessing module is used to preprocess the single-character calligraphy image and the template character image respectively; The whole character level evaluation module is used to compare and calculate the preprocessed single-character calligraphy image and the template character image based on the whole character level index to obtain the whole character level index difference value and the whole character level index score. The whole character level index includes uniformity index, symmetry index, length-width ratio index and tilt index. The stroke level evaluation module is used to compare and calculate the preprocessed single-character calligraphy image and the template character image based on the stroke level index, and obtain the stroke level index difference value and the stroke level index score. The stroke level index includes the stroke compactness index, the stroke topological relationship index and the stroke relative position index. The comprehensive evaluation module is used to perform a weighted summation of the whole character level index score and the stroke level index score to obtain the comprehensive score of the single-component calligraphy to be evaluated.