A method for extracting key contour points of Chinese characters based on key skeleton points and stroke width

By extracting key contour points of Chinese characters based on key skeleton points and stroke width, the problem of noise and redundant contour points being difficult to remove in existing technologies is solved, thereby improving the quality of Chinese character vectorization and reducing storage space.

CN116978023BActive Publication Date: 2026-03-31NANKAI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-19
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively remove noise and redundant contour points during Chinese character vectorization, resulting in poor vectorization quality.

Method used

The method based on key skeleton points and stroke width is used to extract key contour points of Chinese characters. The skeleton and key skeleton points of Chinese characters are obtained through skeleton extraction algorithm. The stroke width is combined to determine whether the contour point is a key contour point, and noise and redundant contour points are removed.

Benefits of technology

It improves the quality of Chinese character vectorization, effectively removes noisy and redundant contour points, and reduces the storage space of vectorized Chinese characters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116978023B_ABST
    Figure CN116978023B_ABST
Patent Text Reader

Abstract

A method for extracting key contour points of Chinese characters based on key skeleton points and stroke width belongs to the field of computer and Chinese character vectorization, which comprises the following steps: inputting a single Chinese character picture, performing pretreatment to generate a binary image; extracting the skeleton of the Chinese character by using a skeleton extraction algorithm; further extracting key skeleton points of the Chinese character; obtaining the stroke width at each key skeleton point of the Chinese character; obtaining the contour points of the Chinese character by using a contour extraction algorithm; sequentially traversing all contour points of the Chinese character, calculating the distance from the current contour point to the nearest key skeleton point, calculating the distance threshold of the current nearest key skeleton point, judging whether the current contour point is a key contour point by comparing the distance from the current contour point to the nearest key skeleton point with the distance threshold, and recording the current contour point as a key contour point if the distance is less than the distance threshold. The application effectively improves the quality of Chinese character vectorization, maintains all detail features, effectively removes noise contour points and redundant contour points, and reduces the storage space size of the vectorized Chinese characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer science and Chinese character vectorization, and mainly focuses on improving the quality of Chinese character vectorization and effectively removing noise contour points and redundant contour points. Background Technology

[0002] To improve the quality of Chinese character vectorization and effectively remove noisy and redundant contour points, the problem of extracting key contour points of Chinese characters is introduced. These key contour points are selected from the existing contour points of the Chinese character. They contain the contour points that represent the true variations in the character, eliminating the vast majority of redundant and noisy contour points.

[0003] Research on key contour points of Chinese characters is still limited. Most current methods for extracting key contour points rely on the difference in the image before and after deleting those points to determine whether to delete them. However, the decision to delete contour points cannot solely depend on their impact on the image quality. Many contour points that are essential for preserving character features may change only slightly, while the changes in contour points from noise can be significant. Specifically:

[0004] [1] Li Xinjie, Jiang Ziao, & Wang Cunrui. (2021). An improved Chinese character vectorization algorithm. Journal of Dalian Minzu University, 23(3), 7.

[0005] Reference [1] uses the angle discrimination method and calculates the deletion cost to delete redundant points to obtain the final key contour point set. The judgment of whether it is a redundant point is only based on the difference between the final fitted image and the original image. However, some details of Chinese characters are very small, so some small features of Chinese characters can be easily deleted by mistake. In addition, this article does not propose how to delete the contour points of the Chinese character image itself that are noisy.

[0006] [2]Pan, W., Lian, Z., Tang, Y., & Xiao, J. (2014). Skeleton-guidedvectorization of Chinese calligraphy images. 2014 IEEE 16th International Workshop on Multimedia Signal Processing (MMSP), 1-6.

[0007] In [2], the redundant contour points are removed by the deletion cost method at first. However, the deletion cost method only judges whether to delete the contour points according to the influence on the fitting result after deletion, and it is easy to delete the contour points of the fine features of Chinese characters. In addition, [2] also adopts the method of classifying contour points, but the key skeleton points used only include endpoints, intersection points and turning points. After such extraction, the contour points are likely to lose the bending parts of strokes such as "left-falling stroke" and "right-falling stroke", as well as the places where the stroke width changes. Summary of the Invention

[0008] The object of the present invention is to overcome the above-mentioned deficiencies existing in the prior art. In order to improve the quality effect of Chinese character vectorization and effectively remove noise contour points and redundant contour points, the present invention provides a method for extracting key contour points of Chinese characters based on key skeleton points and stroke width.

[0009] For the input single Chinese character picture, the present invention preprocesses it to generate a binary image; adopts a skeleton extraction algorithm to extract the skeleton of the Chinese character; further extracts the key skeleton points of the Chinese character based on a multi-scale algorithm; obtains the stroke width at each key skeleton point of the Chinese character; adopts a contour extraction algorithm to obtain the contour points of the Chinese character; traverses all the contour points of the Chinese character in turn, calculates the distance from the current contour point to the nearest key skeleton point, calculates the distance threshold of the current nearest key skeleton point, and judges whether the current contour point is a key contour point by comparing the distance from the current point to the nearest key skeleton point with the distance threshold. If the distance from the current point to the nearest key skeleton point is less than the distance threshold, record the current contour point as a key contour point; output all the key contour points of the Chinese character.

[0010] The technical solution of the present invention:

[0011] A method for extracting key contour points of Chinese characters based on key skeleton points and stroke width, the method includes the following specific steps:

[0012] Step 1: Input a single Chinese character picture;

[0013] Step 2: For the Chinese character picture in Step 1, preprocess it to generate a binary image;

[0014] Step 3: For the binary image in Step 2, adopt a skeleton extraction algorithm to extract the skeleton of the Chinese character;

[0015] Step 4: For the skeleton in Step 3, further extract the key skeleton points of the Chinese character. The key skeleton points should include endpoints, intersection points, folding points, bending points, and width-changing points;

[0016] 5. For the binary image in step 2 and the key skeleton points extracted in step 4, obtain the stroke width at each key skeleton point of the Chinese character. The stroke width refers to the stroke width at the specified point, which is the width of the stroke cross-section formed by the points on the two edges of the character, starting from a specified point on the edge of the character and exploring in a direction perpendicular to the edge until a point on another edge parallel to it is found.

[0017] 6. For the binary image in step 2, use a contour extraction algorithm to obtain the contour points of the Chinese characters;

[0018] 7. For the Chinese character outline points obtained in step 6, traverse all outline points of the Chinese character in turn and calculate the distance from the current outline point to the nearest key skeleton point.

[0019] 8. Calculate the distance threshold of the nearest key skeleton point for the Chinese character key skeleton points extracted in step 4 and the stroke width at the key skeleton points obtained in step 5.

[0020] 9. Compare the distance calculated in step 7 with the distance threshold obtained in step 8, and compare the distance from the current contour point to the nearest key skeleton point with the distance threshold to determine whether the current contour point is a key contour point.

[0021] Step 10: If all contour points have been traversed, proceed to step 11; otherwise, proceed to step 7.

[0022] Step 11: Output all key outline points of the Chinese character, and the program will end.

[0023] Furthermore, in step 3, "extracting the skeleton of Chinese characters using a skeleton extraction algorithm," the skeleton of a Chinese character refers to its basic shape, generally the central axis of the character image. The process of extracting the skeleton involves peeling away layers of the original character, removing some pixels while preserving its original shape, until the skeleton of the image is obtained. The skeleton extraction algorithm can be as follows:

[0024] Step 3.1: For the binary image of the Chinese character, iterate through all the pixels (i,j) in sequence, where 0=< i=<(width of the Chinese character image - 1) and 0=< j=<(length of the Chinese character image - 1). For pixel (i,j), i.e. P1, execute step 1.2.

[0025] Step 3.2: Construct the following 3*3 matrix for P1, i.e., pixel (i,j), as shown in the table below. The matrix contains the eight neighborhoods of pixel P1. A value of 1 indicates a foreground pixel, and a value of 0 indicates a background pixel.

[0026]

[0027] Step 3.3: Perform a raster scan and mark all pixels that meet the following 5 conditions. Pixel P1 that meets the following conditions is marked for deletion:

[0028] (1) This is a foreground pixel (1);

[0029] (2) When viewing P2, P3, ..., P9, P2 clockwise, the number of changes from 0 to 1 is only 1;

[0030] (3) The number of foreground pixels in P2, P3, ..., P9 is more than 2 and less than 6;

[0031] (4) At least one of P2, P4, and P6 is 0 (background pixel);

[0032] (5) At least one of P4, P6, and P8 is 0 (background pixel);

[0033] Mark all pixels that meet the conditions as 0 (background pixels).

[0034] Step 3.4: Perform a raster scan and mark all pixels that meet the following 5 conditions. Pixel P1 that meets the following conditions is marked for deletion:

[0035] (1) This is a foreground pixel (1);

[0036] (2) When viewing P2, P3, ..., P9, P2 clockwise, the number of changes from 0 to 1 is only 1;

[0037] (3) The number of foreground pixels in P2, P3, ..., P9 is more than 2 and less than 6;

[0038] (4) At least one of P2, P4, and P8 is 0 (background pixel);

[0039] (5) At least one of P2, P6, and P8 is 0 (background pixel);

[0040] Step 3.5: If all pixels have been traversed, proceed to step 1.6; otherwise, proceed to step 1.1.

[0041] Step 3.6: Delete all pixels marked "delete" in the binary image of Chinese characters. The remaining output is the skeleton of the binary image.

[0042] Furthermore, step 4, "extracting key skeleton points of Chinese characters," refers to first extracting all endpoints and intersections of the skeleton based on clustering degree; then, using a small-scale filtering method to extract all inflection points and a large-scale filtering method to extract all curvature points; finally, extracting all widening points of the average stroke width variation. The final extracted key skeleton points include: endpoints, intersections, inflection points, curvature points, and widening points of the skeleton. The specific steps are as follows:

[0043] Step 4.1: Extract the endpoints and intersections of the skeleton based on clustering degree.

[0044] The key skeleton points, namely endpoints and intersections, are obtained by calculating the clustering degree of a given skeleton pixel region and comparing the clustering degree with a threshold. The skeleton pixel region is a square area enclosed by the given pixel as the center point and with a given side length. The side length of the region can be 2*radius, where the radius is (max(width of Chinese character image, length of Chinese character image)*0.1) / 2. The threshold includes a maximum threshold and a minimum threshold. The maximum threshold can be 9 and the minimum threshold can be 6.

[0045] Step 4.1.1: Iterate through all skeleton pixels (i,j) in sequence, where 0=< i ==(width of Chinese character image - 1), 0=< j ==(length of Chinese character image - 1), and execute step 4.1.2 for the current skeleton pixel (i,j);

[0046] Step 4.1.2: Calculate the degree of clustering of the current skeleton pixel (i,j) using formulas (1) and (2). i,j , where i is the width coordinate of the current skeleton pixel, j is the length coordinate of the current skeleton pixel, k is all possible values ​​in the range of (i-radius, i+radius), and l is all possible values ​​in the range of (j-radius, j+radius).

[0047] (1)

[0048] Where, p k,l It is the value at pixel (k,l). If pixel (k,l) is the foreground, then p k,l If p is 1, then p is 0 otherwise. k,l The values ​​are as shown in formula (2):

[0049] (2)

[0050] Step 4.1.3: Compare the degree of clustering of pixel points (i,j). i,j The relationship between the maximum and minimum thresholds:

[0051] If the degree of clustering of pixel (i,j) is... i,j If the maximum threshold is reached, then pixel (i,j) is an intersection point, and this pixel (i,j) is recorded as an intersection point.

[0052] Otherwise, if the degree of clustering of pixel (i,j) is... i,j If the threshold is less than the minimum threshold, then this pixel (i,j) is an endpoint, and the pixel (i,j) is recorded as an endpoint;

[0053] Otherwise, this pixel (i,j) is neither an endpoint nor an intersection point, and does not need to be recorded;

[0054] Step 4.1.4: If all skeleton pixels have been traversed, proceed to step 4.1.5; otherwise, proceed to step 4.1.1.

[0055] Step 4.1.5: All endpoints and intersections of the skeleton have been obtained. All endpoints and intersections of the skeleton are key skeleton points.

[0056] Step 4.2: Extract all inflection points of the skeleton using a small-scale filtering method.

[0057] Step 4.2.1: Iterate through all skeleton pixels (i,j) in sequence, where 0=< i=<(width of Chinese character image - 1), 0=< j=<(length of Chinese character image - 1), and execute step 4.2.2 for the current skeleton pixel (i,j);

[0058] Step 4.2.2: Calculate the "small region" of the current skeleton pixel (i,j), such as... Figure 2 As shown, a corresponding "small region" is expanded with the current skeleton pixel (i,j) as the center. The width and length of the "small region" are 0.1 times the width and length of the Chinese character image, respectively.

[0059] Step 4.2.3: Calculate all the "connected components" of the key skeleton points in the "small region" of step 4.2.2. Each "connected component" refers to an array of skeleton pixels composed of several continuous skeleton pixels in the Chinese character skeleton. Further, put each "connected component" into an array point[N], where N is the number of skeleton pixels in the "connected component". Further calculate the number of "connected components" point[N] close to the boundary of the "small region". If the number close to the boundary of the "small region" is equal to 2, record the two boundary skeleton pixels as the start and end points of this "connected component". Use these two start and end points as the two endpoints of the line and use formulas (4), (5) and (6) to obtain the equation of the line w. Further use formula (7) to calculate the distance from all skeleton pixels in this "connected component" to the line w. Put the result into an array dist[N], where N is the number of skeleton pixels in the "connected component".

[0060] The equation of line w is ,in:

[0061] (4)

[0062] (5)

[0063] (6)

[0064] The distance from pixel point[i] to line w is , where 0 <= i <N:

[0065] (7)

[0066] Step 4.2.4: Obtain the array index z of the maximum value in dist[N], i.e., dist[z] is the maximum value, where N is the number of skeleton pixels in this "connected component"; further compare the size relationship between dist[z] and the "distance threshold". If dist[z] > distance threshold, then the skeleton pixel point[z] corresponding to dist[z] is a vertex. Record the skeleton pixel point[z] as a vertex. The distance threshold can be max("small region" width, "small region" length) * 0.1. In this step, all vertices in the current "small region" have been extracted.

[0067] Step 4.2.5: Move the "small region" from step 4.2.2 by a given step size, which is one-quarter of the width and height of the "small region". If all skeleton pixels have been traversed, proceed to step 4.2.6; otherwise, proceed to step 4.2.2.

[0068] Step 4.2.6: All the vertices of the skeleton have been obtained. All the vertices of the skeleton are key skeleton points.

[0069] Step 4.3: Extract all bends of the skeleton using a large-scale filtering method.

[0070] Step 4.3.1: Iterate through all skeleton pixels (i,j) in sequence, where 0=< i ==(width of Chinese character image - 1), 0=< j ==(length of Chinese character image - 1), and execute step 4.3.2 for the current skeleton pixel (i,j);

[0071] Step 4.3.2: Calculate the "large region" of the current skeleton pixel (i,j), such as... Figure 3 As shown, a corresponding "large region" is expanded with the current skeleton pixel (i,j) as the center. The width and length of the "large region" are 0.2 times the width and length of the Chinese character image, respectively.

[0072] Step 4.3.3: Calculate all the "connected components" of the key skeleton points in the "large region" of step 4.3.2, and put each "connected component" into an array point[N], where N is the number of skeleton pixels in the "connected component"; calculate the number of "connected components" point[N] close to the boundary of the "large region". If the number of "connected components" point[N] close to the boundary of the "large region" is equal to 2, then record the two boundary skeleton pixels as the start and end points of this connected component. Take these two start and end points as the two endpoints of the line, and use formulas (4), (5) and (6) to obtain the equation of the line w; further use formula (7) to calculate the distance from all skeleton pixels in this connected component to the line w, and put the result into an array dist[N], where N is the number of skeleton pixels in the "connected component";

[0073] Step 4.3.4: Obtain the array index t of the maximum value in dist[N], i.e., dist[t] is the maximum value, where N is the number of skeleton pixels in the "connected component"; further compare the size of dist[t] with the "distance threshold". If dist[t] > distance threshold, then the skeleton pixel point[t] corresponding to dist[t] is a bend point. Record that the skeleton pixel point[t] is a bend point. The distance threshold can be max("large region" width, "large region" length) * 0.1. This step has extracted all bend points in the current "large region".

[0074] Step 4.3.5: Move the "large region" from step 4.3.2 according to the given step size, which is one-quarter of the width and height of the "large region"; if all skeleton pixels have been traversed, then execute step 4.3.6; otherwise, execute step 4.3.2.

[0075] Step 4.3.6: All the curves of the skeleton have been obtained. All the curves of the skeleton are key skeleton points.

[0076] Step 4.4: Extract all widening points of the average stroke width variation.

[0077] Based on formula (8), extract the key skeleton points, i.e., the widening points, where the change in the average width of strokes in the surrounding area is greater than the width threshold t, where SW is the set of stroke widths in the given area. nxt Given a region, avg() represents the set of stroke widths of adjacent regions, where avg() is the average stroke width. The specific method for obtaining the widening point of the skeleton is as follows:

[0078] (8)

[0079] Step 4.4.1: Calculate the corresponding Chinese character stroke width image for the binary image of the Chinese character in Step 2. The Chinese character stroke width image is an image of the same size as the original image, but the value of each pixel is the size of the stroke width at this point, and the value of the pixels in the background is -1.

[0080] Step 4.4.2: Based on the Chinese character stroke width map in Step 4.4.1, obtain the stroke width at all skeleton pixels;

[0081] Step 4.4.3: Iterate through all the skeleton pixels (i,j) of the Chinese character skeleton in step 3, where 0=< i=<(width of Chinese character image-1), 0=< j=<(length of Chinese character image-1), and execute step 4.4.4 for the current skeleton pixel (i,j).

[0082] Step 4.4.4: Calculate the region of the current skeleton pixel (i,j). The width and length of the region are 0.1 times the width and length of the Chinese character image, respectively.

[0083] Step 4.4.5: In the region defined in Step 4.4.4, calculate the stroke width of the original image at each skeleton pixel within that region. Based on the stroke widths at each skeleton pixel within that region, calculate the average stroke width avg(SW) of that region. Further compare this average stroke width avg(SW) with the average stroke widths of adjacent regions. nxt The difference between the two regions; if it is greater than the width threshold, the critical skeleton pixel in the middle of the two regions is considered to be the widening point, where the width threshold can be taken as 0.2 times the stroke width at this point;

[0084] Step 4.4.6: If all skeleton pixels have been traversed, proceed to step 4.4.7; otherwise, proceed to step 4.4.3.

[0085] Step 4.4.7: All widening points of the skeleton have been obtained. All widening points of the skeleton are key skeleton points.

[0086] Furthermore, step 5, "obtaining the stroke width at each key skeleton point of the Chinese character," refers to calculating and generating a stroke width map using the binary image described in step 2. The stroke width map is an image of the same size as the original Chinese character image, but the value of each pixel is the size of the stroke width at that location, and the pixels of the background part are -1. Iterate through all the key skeleton points obtained in step 4, and obtain the value of the stroke width map at the corresponding position based on the position of the current key skeleton point, which is used as the stroke width at the current key skeleton point.

[0087] Furthermore, step 6, "using a contour extraction algorithm to obtain the contour points of Chinese characters," refers to obtaining the points at the edges of the Chinese characters and arranging them counterclockwise or clockwise along the contour line. The contour extraction algorithm used in this invention is a part of the Potrace algorithm. The specific method for obtaining the contour points of Chinese characters is as follows:

[0088] Step 6.1, Path Decomposition: Construct a directed graph G from the binary graph obtained in Step 2. The goal of path decomposition is to decompose graph G into closed paths, that is, to find a set of closed paths such that each edge of G appears only once. The specific decomposition method is as follows:

[0089] We start with a pair of adjacent pixels of different colors, for example, by selecting the leftmost black pixel in a row. The two selected pixels meet on an edge, and we change the orientation of this edge so that the black pixel is on the left and the white pixel is on the right. This edge is defined as a path of length 1. We continue to expand this path so that each new edge has a black pixel on its left and a white pixel on its right. We continue until we return to our starting point. Each time we find a closed graph, we remove it from the graph by inverting the colors of all its pixels. This defines a new bitmap, and we recursively apply this algorithm to this new bitmap until no black pixels remain.

[0090] Step 6.2: Obtain the optimal polygon set. The vertices of the optimal polygon set represent the contour points of the Chinese characters. Using the closed path set obtained in Step 6.1, polygons are constructed through a straight-line path approximation method. However, many different polygons may be found; the optimal polygon is selected. The main criterion for "optimal" is the number of segments: a polygon with fewer segments is considered better than one with more segments. Among polygons with the same number of segments, polygons with smaller segment penalties are better. After this step, the optimal polygon set is generated, and the vertices of these polygons can be considered the contour points of the Chinese characters, thus obtaining the contour points of the Chinese characters.

[0091] Furthermore, the "traversing all contour points of the Chinese character in sequence and calculating the distance from the current contour point to the nearest key skeleton point" mentioned in step 7 refers to traversing all contour points of the Chinese character extracted in step 6 in sequence. For the current contour point m(x1,y1), the distance from the current contour point m(x1,y1) to all key skeleton points i(x2,y2) is calculated using formula (9). By filtering the minimum distance, the distance from the current contour point to the nearest key skeleton point is selected. The key skeleton point is the key skeleton point of the Chinese character obtained in step 4. The key skeleton point includes the endpoints, intersections, inflection points, bends, and widening points of the skeleton. The nearest key skeleton point is the key skeleton point that is closest to the current contour point among the key skeleton points mentioned in step 4.

[0092] (9).

[0093] Furthermore, the "calculation of the distance threshold of the current nearest key skeleton point" mentioned in step 8 is to dynamically obtain the "distance threshold" size based on the stroke width at each key skeleton point of the Chinese character in step 5. The "distance threshold" size is "k * stroke width at the current key skeleton point", where the default value of k is 1.

[0094] Furthermore, step 9, "determining whether the current contour point is a key contour point," refers to determining whether the current contour point is a key contour point by comparing the distance from the current contour point obtained in step 7 to the nearest key skeleton point with the distance threshold of the current nearest key skeleton point obtained in step 8.

[0095] If the distance from the current contour point to the nearest key skeleton point is less than the "distance threshold", it proves that the current contour point is close to the key skeleton point and belongs to the contour point of the real stroke change. Then, the current contour point is recorded as the key contour point of the Chinese character.

[0096] Otherwise, if it is proven that the current contour point is not close to any key skeleton point, and belongs to the contour point of the jitter noise change or the redundant contour point, then the current contour point is not recorded as the key contour point of the Chinese character.

[0097] Among them, the key contour points finally extracted are those that contain the actual changes in Chinese characters, eliminating most of the redundant and noisy contour points.

[0098] The specific content involved in this invention and the meaning of the terms used are as follows:

[0099] (1) Chinese character skeleton: The skeleton of Chinese characters refers to the basic shape of Chinese characters, generally referring to the central axis of the Chinese character image. The process of extracting the skeleton of Chinese characters is to peel off layers of the original Chinese characters, removing some pixels while maintaining the original shape, until the skeleton of the image is obtained.

[0100] (2) A pixel point is a pixel, and they have the same meaning. A skeleton pixel point is a skeleton point, and they have the same meaning.

[0101] (3) Key skeleton points of Chinese characters: The key skeleton points of Chinese characters refer to the skeleton points that contain all the changing parts of Chinese characters. The key skeleton points extracted in existing articles are: end points, intersection points, and inflection points. The key skeleton points of Chinese characters extracted in this invention based on the type and width of Chinese character strokes include: end points, intersection points, bending points, folding points, and average stroke width change points, i.e., width change points, of the skeleton.

[0102] (4) An end point is the point where each stroke starts and ends.

[0103] (5) An intersection point is the place where several strokes intersect.

[0104] (6) A folding point refers to a place where the angle at the turning point is relatively sharp, such as the folding part of strokes like "zhe" and "gou".

[0105] (7) A bending point refers to a place where the turning is not so sharp, such as the bending part of strokes like "pie" and "na".

[0106] (8) A width change point means that if the average stroke width in the current area changes significantly compared with the average stroke width in the adjacent area, the critical skeleton point between the two areas is considered a width change point.

[0107] (9) Stroke width: It refers to starting from a specified point on the edge of the text, exploring in the direction perpendicular to the edge until finding a point on another parallel edge. The points on these two edges form a stroke cross-section, and the width of this stroke cross-section is the stroke width at the specified point.

[0108] (10) The stroke width map is an image with the same size as the original Chinese character image, but the value of each pixel is the size of the stroke width here, and the pixels in the background part are -1.

[0109] (11) Outline points of Chinese characters: They refer to the points at the edge of Chinese characters arranged counterclockwise or clockwise along the outline line. The outline points of Chinese characters can be used to represent the geometric shape of Chinese characters.

[0110] (12) Key outline points of Chinese characters: They refer to the key outline points of Chinese characters selected based on the outline points of Chinese characters. The key outline points of Chinese characters are the outline points that contain the real changing parts of Chinese characters, excluding most of the redundant outline points and noise outline points.

[0111] (13) Distance threshold: It refers to the threshold for calculating the distance between the current outline point and the nearest key skeleton point, used to determine whether the current outline point is a key outline point. The size of the distance threshold is dynamically determined by the stroke width at the nearest key skeleton point.

[0112] Advantages and positive effects of the present invention:

[0113] The present invention can effectively improve the quality of Chinese character vectorization, effectively remove noise contour points and redundant contour points, and reduce the storage space size of vectorized Chinese characters.

[0114] The present invention extracts key contour points of Chinese characters based on key skeleton points and stroke widths. The key skeleton points used in the present invention include endpoint, intersection point, bend point, fold point, and width change point, that is, all the changing points of Chinese character strokes are included. First, obtain the key skeleton points of the Chinese character and the stroke widths of the Chinese character at the key skeleton points. Then, obtain the contour points of the Chinese character. Next, screen the contour points of the Chinese character through the key skeleton points of the Chinese character and the stroke widths at the key skeleton points, and extract all the key contour points of the Chinese character. Finally, form a vectorized Chinese character by sequentially connecting the key contour points of the Chinese character. This method can effectively remove noise contour points and redundant contour points in the Chinese character contour points.

[0115] The present invention can be applied to fields such as the manufacturability of text in industrial systems and the automatic generation of personalized font libraries. Brief Description of the Drawings

[0116] Figure 1 is a flowchart of the method for extracting key contour points of Chinese characters based on key skeleton points and stroke widths in the present invention.

[0117] Figure 2 is a schematic diagram of the "small area" of the given skeleton pixel points in the present invention.

[0118] Figure 3 is a schematic diagram of the "large area" of the given skeleton pixel points in the present invention.

[0119] Figure 4 is a binary image of the Chinese character "Lv" in the present invention.

[0120] Figure 5 is a schematic diagram of the skeleton points of the Chinese character "Lv" in the present invention, where the white point set in the figure is the Chinese character skeleton.

[0121] Figure 6 is a schematic diagram of the key skeleton points of the Chinese character "Lv" in the present invention, where the white points in the figure are the key skeleton points.

[0122] Figure 7 is a schematic diagram of the stroke width of the key skeleton points in the present invention, where the stroke width at the key skeleton point i(x,y) in the figure is SW.

[0123] Figure 8 is a schematic diagram of all the contour points of the Chinese character "Lv" in the present invention, where the white points in the figure are the contour points.

[0124] Figure 9It is a schematic diagram of the key contour points of the Chinese character "Lv" in the present invention, where the white points in the figure are the key contour points.

[0125] Figure 10 It is a diagram for screening key contour points in the present invention. In the figure, the current contour point is m(x1, y1), the nearest key skeleton point of the current contour point is i(x2, y2), the distance from the current contour point to the nearest key skeleton point is ddist, the distance threshold of the current nearest key skeleton point is the stroke width SW at this key skeleton point, and the distance ddist from the current contour point m(x1, y1) to the nearest key skeleton point i(x2, y2) is less than the distance threshold SW, so the current contour point m(x1, y1) is recorded as a key contour point. Specific implementation manner

[0126] The present invention proposes a method for extracting key contour points of Chinese characters based on key skeleton points and stroke width. The specific steps of the method are as follows:

[0127] Step 1: Input a single Chinese character picture;

[0128] Step 2: For the Chinese character picture in Step 1, perform preprocessing to generate a binary image;

[0129] Step 3: For the binary image in Step 2, use a skeleton extraction algorithm to extract the skeleton of the Chinese character;

[0130] Step 4: For the skeleton in Step 3, further extract the key skeleton points of the Chinese character. The key skeleton points should include endpoints, intersection points, turning points, bending points, and width-changing points;

[0131] Step 5: For the binary image in Step 2 and the key skeleton points extracted in Step 4, obtain the stroke width at each key skeleton point of the Chinese character. The stroke width refers to starting from a specified point on the edge of the text, exploring in a direction perpendicular to the edge until finding a point on another parallel edge, and the width of the stroke cross-section formed by the points on these two edges is the stroke width at the specified point;

[0132] Step 6: For the binary image in Step 2, use a contour extraction algorithm to obtain the contour points of the Chinese character;

[0133] Step 7: For the Chinese character contour points obtained in Step 6, sequentially traverse all the contour points of the Chinese character and calculate the distance from the current contour point to the nearest key skeleton point;

[0134] Step 8: For the key skeleton points of the Chinese character extracted in Step 4 and the stroke width at the key skeleton points obtained in Step 5, calculate the distance threshold of the current nearest key skeleton point;

[0135] Step 9: Compare the distance calculated in Step 7 with the distance threshold obtained in Step 8 to determine whether the current contour point is a key contour point by comparing the distance from the current contour point to the nearest key skeleton point with the distance threshold;

[0136] Step 10: If all contour points have been traversed, execute Step 11; otherwise, execute Step 7;

[0137] Step 11: Output all key contour points of the Chinese character, and the program runs to completion.

[0138] To further understand the technical content, features and effects of the present invention, the following application examples are listed and described in detail with the accompanying drawings as follows:

[0139] A method for extracting key contour points of Chinese characters based on key skeleton points and stroke width, as Figure 1 shown, the method includes the following specific steps:

[0140] Step 1: Input a single Chinese character image;

[0141] Step 2: Preprocess the Chinese character image in Step 1 to generate a binary image;

[0142] Input the original image of the Chinese character "Lv". Use the cvtColor library function in OpenCV to convert the original image to a grayscale image, further perform non-local denoising on the grayscale image, and then use the threshold library function in OpenCV to binarize the denoised image to generate a binary image of the image, as Figure 4 shown.

[0143] Step 3: For the binary image in Step 2, use a skeleton extraction algorithm to extract the skeleton of the Chinese character;

[0144] As Figure 5 shown, generate a skeleton image of the Chinese character "Lv" according to the binary image of the Chinese character "Lv", where Figure 5 the white line segment in is the skeleton of the Chinese character.

[0145] Step 4: For the skeleton in Step 3, further extract the key skeleton points of the Chinese character. The key skeleton points should include endpoints, intersection points, folding points, bending points, and width-changing points;

[0146] As Figure 6 shown, the key skeleton points extracted from the skeleton of the Chinese character "Lv".

[0147] Step 5: For the binary image in Step 2 and the key skeleton points extracted in Step 4, obtain the stroke width at each key skeleton point of the Chinese character. The stroke width refers to starting from a specified point on the edge of the text, exploring in the direction perpendicular to the edge until finding a point on another parallel edge. The points on these two edges form a stroke cross-section, and the width of this stroke cross-section is the stroke width at the specified point.

[0148] As Figure 7 shown, the stroke width at the current key skeleton point i(x, y) is SW.

[0149] Step 6: For the binary image in Step 2, use a contour extraction algorithm to obtain the contour points of the Chinese character.

[0150] As Figure 8 shown, all the contour points extracted from the Chinese character "Lv".

[0151] Step 7: For the Chinese character contour points obtained in Step 6, sequentially traverse all the contour points of the Chinese character and calculate the distance from the current contour point to the nearest key skeleton point.

[0152] As Figure 10 shown, ddist is the distance from the current contour point m(x1, y1) to the nearest key skeleton point i(x2, y2).

[0153] Step 8: For the key skeleton points of the Chinese character extracted in Step 4 and the stroke width at the key skeleton points obtained in Step 5, calculate the distance threshold of the current nearest key skeleton point.

[0154] As Figure 10 shown, the distance threshold of the current nearest key skeleton point m(x1, y1) is SW.

[0155] Step 9: For the distance calculated in Step 7 and the distance threshold obtained in Step 8, compare the distance from the current contour point to the nearest key skeleton point with the distance threshold to determine whether the current contour point is a key contour point.

[0156] As Figure 10 shown, the distance ddist from the current contour point m(x1, y1) to the nearest key skeleton point i(x2, y2) is less than the distance threshold SW, so the current contour point m(x1, y1) is recorded as a key contour point.

[0157] Step 10: If all the contour points have been traversed, execute Step 11; otherwise, execute Step 7.

[0158] As Figure 9 shown, all the key contour points extracted from the Chinese character "Lv".

[0159] Step 11: Output all key outline points of the Chinese character, and the program will end.

[0160] According to the method provided by this invention, in step 3, "extracting the skeleton of Chinese characters using a skeleton extraction algorithm," the skeleton of a Chinese character refers to its basic shape, generally the central axis of the character image. The process of extracting the skeleton involves peeling away layers, removing some pixels from the original character while maintaining its original shape, until the skeleton of the image is obtained. The skeleton extraction algorithm can be as follows:

[0161] Step 3.1: For the binary image of the Chinese character, iterate through all the pixels (i,j) in sequence, where 0=< i=<(width of the Chinese character image - 1) and 0=< j=<(length of the Chinese character image - 1). For pixel (i,j), i.e. P1, execute step 1.2.

[0162] Step 3.2: Construct the following 3*3 matrix for P1, i.e., pixel (i,j), as shown in Table 1 below. The matrix contains the eight neighborhoods of pixel P1. A value of 1 indicates a foreground pixel, and a value of 0 indicates a background pixel.

[0163] Table 1

[0164]

[0165] For example, Table 2 and Table 3 are 3x3 matrices representing different pixel points:

[0166] Table 2

[0167] 0 0 1 0 1 1 0 0 0

[0168] Table 3

[0169] 0 0 1 0 1 1 1 0 0

[0170] Step 3.3: Perform a raster scan and mark all pixels that meet the following 5 conditions. Pixel P1 that meets the following conditions is marked for deletion:

[0171] (1) This is a foreground pixel (1);

[0172] (2) When viewing P2, P3, ..., P9, P2 clockwise, the number of changes from 0 to 1 is only 1;

[0173] (3) The number of foreground pixels in P2, P3, ..., P9 is more than 2 and less than 6;

[0174] (4) At least one of P2, P4, and P6 is 0 (background pixel);

[0175] (5) At least one of P4, P6, and P8 is 0 (background pixel);

[0176] Mark all pixels that meet the conditions as 0 (background pixels).

[0177] Step 3.4: Perform a raster scan and mark all pixels that meet the following 5 conditions. Pixel P1 that meets the following conditions is marked for deletion:

[0178] (1) This is a foreground pixel (1);

[0179] (2) When viewing P2, P3, ..., P9, P2 clockwise, the number of changes from 0 to 1 is only 1;

[0180] (3) The number of foreground pixels in P2, P3, ..., P9 is more than 2 and less than 6;

[0181] (4) At least one of P2, P4, and P8 is 0 (background pixel);

[0182] (5) At least one of P2, P6, and P8 is 0 (background pixel);

[0183] Step 3.5: If all pixels have been traversed, proceed to step 1.6; otherwise, proceed to step 1.1.

[0184] Step 3.6: Delete all pixels marked "delete" in the binary image of Chinese characters. The remaining output is the skeleton of the binary image.

[0185] For Tables 2 and 3 above, if the pixel at position P1 in Table 2 satisfies 1.3 or 1.4, it will be marked for deletion; if the pixel at position P1 in Table 3 does not satisfy either 1.3 or 1.4, it will not be marked for deletion.

[0186] According to the method provided by this invention, step 4, "extracting key skeleton points of Chinese characters," refers to first extracting all endpoints and intersections of the skeleton based on clustering degree; then, using a small-scale filtering method to extract all inflection points and a large-scale filtering method to extract all curvature points; finally, extracting all widening points of the average stroke width variation. The final extracted key skeleton points include: endpoints, intersections, inflection points, curvature points, and widening points of the skeleton. The specific steps are as follows:

[0187] Step 4.1: Extract the endpoints and intersections of the skeleton based on clustering degree.

[0188] The key skeleton points, namely endpoints and intersections, are obtained by calculating the clustering degree of a given skeleton pixel region and comparing the clustering degree with a threshold. The skeleton pixel region is a square area enclosed by the given pixel as the center point and with a given side length. The side length of the region can be 2*radius, where the radius is (max(width of Chinese character image, length of Chinese character image)*0.1) / 2. The threshold includes a maximum threshold and a minimum threshold. The maximum threshold can be 9 and the minimum threshold can be 6.

[0189] Step 4.1.1: Iterate through all skeleton pixels (i,j) in sequence, where 0=< i ==(width of Chinese character image - 1), 0=< j ==(length of Chinese character image - 1), and execute step 4.1.2 for the current skeleton pixel (i,j);

[0190] Step 4.1.2: Calculate the degree of clustering of the current skeleton pixel (i,j) using formulas (1) and (2). i,j , where i is the width coordinate of the current skeleton pixel, j is the length coordinate of the current skeleton pixel, k is all possible values ​​in the range of (i-radius, i+radius), and l is all possible values ​​in the range of (j-radius, j+radius).

[0191] (1)

[0192] Where, p k,l It is the value at pixel (k,l). If pixel (k,l) is the foreground, then p k,l If p is 1, then p is 0 otherwise. k,l The values ​​are as shown in formula (2):

[0193] (2)

[0194] Step 4.1.3: Compare the degree of clustering of pixel points (i,j). i,j The relationship between the maximum and minimum thresholds:

[0195] If the degree of clustering of pixel (i,j) is... i,j If the maximum threshold is reached, then pixel (i,j) is an intersection point, and this pixel (i,j) is recorded as an intersection point.

[0196] Otherwise, if the degree of clustering of pixel (i,j) is... i,j If the threshold is less than the minimum threshold, then this pixel (i,j) is an endpoint, and the pixel (i,j) is recorded as an endpoint;

[0197] Otherwise, this pixel (i,j) is neither an endpoint nor an intersection point, and does not need to be recorded;

[0198] Step 4.1.4: If all skeleton pixels have been traversed, proceed to step 4.1.5; otherwise, proceed to step 4.1.1.

[0199] Step 4.1.5: All endpoints and intersections of the skeleton have been obtained. All endpoints and intersections of the skeleton are key skeleton points.

[0200] Step 4.2: Extract all inflection points of the skeleton using a small-scale filtering method.

[0201] Step 4.2.1: Iterate through all skeleton pixels (i,j) in sequence, where 0=< i=<(width of Chinese character image - 1), 0=< j=<(length of Chinese character image - 1), and execute step 4.2.2 for the current skeleton pixel (i,j);

[0202] Step 4.2.2: Calculate the "small region" of the current skeleton pixel (i,j), such as... Figure 2 As shown, a corresponding "small region" is expanded with the current skeleton pixel (i,j) as the center. The width and length of the "small region" are 0.1 times the width and length of the Chinese character image, respectively.

[0203] Step 4.2.3: Calculate all the "connected components" of the key skeleton points in the "small region" of step 4.2.2. Each "connected component" refers to an array of skeleton pixels composed of several continuous skeleton pixels in the Chinese character skeleton. Further, put each "connected component" into an array point[N], where N is the number of skeleton pixels in the "connected component". Further calculate the number of "connected components" point[N] close to the boundary of the "small region". If the number close to the boundary of the "small region" is equal to 2, record the two boundary skeleton pixels as the start and end points of this "connected component". Use these two start and end points as the two endpoints of the line and use formulas (4), (5) and (6) to obtain the equation of the line w. Further use formula (7) to calculate the distance from all skeleton pixels in this "connected component" to the line w. Put the result into an array dist[N], where N is the number of skeleton pixels in the "connected component".

[0204] The equation of line w is ,in:

[0205] (4)

[0206] (5)

[0207] (6)

[0208] The distance from pixel point[i] to line w is , where 0 <= i <N:

[0209] (7)

[0210] Step 4.2.4: Obtain the array index z of the maximum value in dist[N], i.e., dist[z] is the maximum value, where N is the number of skeleton pixels in this "connected component"; further compare the size relationship between dist[z] and the "distance threshold". If dist[z] > distance threshold, then the skeleton pixel point[z] corresponding to dist[z] is a vertex. Record the skeleton pixel point[z] as a vertex. The distance threshold can be max("small region" width, "small region" length) * 0.1. In this step, all vertices in the current "small region" have been extracted.

[0211] Step 4.2.5: Move the "small region" from step 4.2.2 by a given step size, which is one-quarter of the width and height of the "small region". If all skeleton pixels have been traversed, proceed to step 4.2.6; otherwise, proceed to step 4.2.2.

[0212] Step 4.2.6: All the vertices of the skeleton have been obtained. All the vertices of the skeleton are key skeleton points.

[0213] Step 4.3: Extract all bends of the skeleton using a large-scale filtering method.

[0214] Step 4.3.1: Iterate through all skeleton pixels (i,j) in sequence, where 0=< i ==(width of Chinese character image - 1), 0=< j ==(length of Chinese character image - 1), and execute step 4.3.2 for the current skeleton pixel (i,j);

[0215] Step 4.3.2: Calculate the "large region" of the current skeleton pixel (i,j), such as... Figure 3 As shown, a corresponding "large region" is expanded with the current skeleton pixel (i,j) as the center. The width and length of the "large region" are 0.2 times the width and length of the Chinese character image, respectively.

[0216] Step 4.3.3: Calculate all the "connected components" of the key skeleton points in the "large region" of step 4.3.2, and put each "connected component" into an array point[N], where N is the number of skeleton pixels in the "connected component"; calculate the number of "connected components" point[N] close to the boundary of the "large region". If the number of "connected components" point[N] close to the boundary of the "large region" is equal to 2, then record the two boundary skeleton pixels as the start and end points of this connected component. Take these two start and end points as the two endpoints of the line, and use formulas (4), (5) and (6) to obtain the equation of the line w; further use formula (7) to calculate the distance from all skeleton pixels in this connected component to the line w, and put the result into an array dist[N], where N is the number of skeleton pixels in the "connected component";

[0217] Step 4.3.4: Obtain the array index t of the maximum value in dist[N], i.e., dist[t] is the maximum value, where N is the number of skeleton pixels in the "connected component"; further compare the size of dist[t] with the "distance threshold". If dist[t] > distance threshold, then the skeleton pixel point[t] corresponding to dist[t] is a bend point. Record that the skeleton pixel point[t] is a bend point. The distance threshold can be max("large region" width, "large region" length) * 0.1. This step has extracted all bend points in the current "large region".

[0218] Step 4.3.5: Move the "large region" from step 4.3.2 according to the given step size, which is one-quarter of the width and height of the "large region"; if all skeleton pixels have been traversed, then execute step 4.3.6; otherwise, execute step 4.3.2.

[0219] Step 4.3.6: All the curves of the skeleton have been obtained. All the curves of the skeleton are key skeleton points.

[0220] Step 4.4: Extract all widening points of the average stroke width variation.

[0221] Based on formula (8), extract the key skeleton points, i.e., the widening points, where the change in the average width of strokes in the surrounding area is greater than the width threshold t, where SW is the set of stroke widths in the given area. nxt Given a region, avg() represents the set of stroke widths of adjacent regions, where avg() is the average stroke width. The specific method for obtaining the widening point of the skeleton is as follows:

[0222] (8)

[0223] Step 4.4.1: Calculate the corresponding Chinese character stroke width map for the binary map of Chinese characters in Step 2. The Chinese character stroke width map is an image with the same size as the original image, but the value of each pixel is the size of the stroke width here, and the value of the pixel in the background part is -1;

[0224] Step 4.4.2: Obtain the stroke widths at all skeleton pixel points according to the Chinese character stroke width map in Step 4.4.1;

[0225] Step 4.4.3: Traverse all the skeleton pixel points (i, j) of the Chinese character skeleton in Step 3 in sequence, where 0 <= i <= (width of the Chinese character image - 1), 0 <= j <= (length of the Chinese character image - 1), and execute Step 4.4.4 for the current skeleton pixel point (i, j);

[0226] Step 4.4.4: Calculate the area of the current skeleton pixel point (i, j). The width and length of the area are 0.1 times the width and length of the Chinese character image respectively;

[0227] Step 4.4.5: In the area in Step 4.4.4, calculate the stroke widths of the original image corresponding to each skeleton pixel point in this area, calculate the average stroke width avg(SW) of this area according to the stroke widths of each skeleton pixel point in this area, and further compare the difference between it and the average stroke width avg(SW nxt ) of the adjacent area; if it is greater than the width threshold, the critical skeleton pixel point in the middle of the two areas is considered a width-varying point, where the width threshold can be taken as 0.2 times the stroke width here;

[0228] Step 4.4.6: If all the skeleton pixel points are traversed, execute Step 4.4.7; otherwise, execute Step 4.4.3;

[0229] Step 4.4.7: All the width-varying points of the skeleton are obtained, and all the width-varying points of the skeleton are key skeleton points.

[0230] As Figure 6 shown, the key skeleton points extracted from the skeleton of the Chinese character "Lv" are shown. The white points in the figure are the key skeleton points of "Lv".

[0231] According to the establishment method provided by the present invention, for the "obtaining the stroke width at each key skeleton point of the Chinese character" described in Step 5, it means calculating and generating a stroke width map through the binary map described in Step 2, where the stroke width map is an image with the same size as the original Chinese character image, but the value of each pixel is the size of the stroke width here, and the pixels in the background part are -1; traverse all the key skeleton points obtained in Step 4 in sequence, and obtain the value in the stroke width map at the corresponding position according to the position of the current key skeleton point, and use it as the stroke width at the current key skeleton point.

[0232] As shown Figure 7 in the figure, the current key skeleton point is i(x, y), and the stroke width at i(x, y) is the distance SW between contour points parallel in two directions.

[0233] According to the establishment method provided by the present invention, in the sixth step, "obtaining the contour points of Chinese characters by using a contour extraction algorithm" refers to obtaining the points at the edge of Chinese characters and arranging them counterclockwise or clockwise along the contour line. The contour extraction algorithm used in the present invention is a partial algorithm in the Potrace algorithm. The specific method for obtaining the contour points of Chinese characters is as follows:

[0234] Step 6.1, path decomposition: Construct a directed graph G for the binary image obtained in step 2. The goal of path decomposition is to decompose graph G into closed paths, that is, to find a set of closed paths such that each edge of G appears only once. The specific decomposition method is as follows:

[0235] Start from a pair of adjacent pixels with different colors, such as by selecting the leftmost black pixel in a certain row. The two selected pixels meet on an edge. We change the orientation of this edge so that the black pixel is on the left side of the edge and the white pixel is on the right side. The edge is defined as a path with a length of 1. We continue to expand this path so that each new edge has a black pixel on its left and a white pixel on its right. We continue until we return to the point where we started. Each time we find a closed graph, we remove it from the graph by inverting the colors of all its pixels. This defines a new bitmap, and we continue to recursively apply this algorithm to this bitmap until no black pixels remain.

[0236] Step 6.2, obtaining the optimal polygon. The set of vertices of the optimal polygon is the set of contour points of Chinese characters: The set of closed paths obtained in step 6.1 is used to construct polygons by the method of approximating with straight-line paths. However, many different polygons may be found, and a best polygon is selected from them. The main criterion for the best one is the number of segments: A polygon with fewer segments is considered to be better than a polygon with more segments. Among polygons with the same number of segments, the polygon with a smaller segment penalty sum is better. After this step, the set of optimal polygons is generated, and the vertices of the polygons can be regarded as the contour points of Chinese characters, thus obtaining the contour points of Chinese characters.

[0237] As shown Figure 8 in the figure, the white points at the edge of the Chinese character in the figure are all the contour points of the Chinese character "Lv".

[0238] According to the establishment method provided by the present invention, the step 7, "to traverse all contour points of the Chinese character in turn and calculate the distance from the current contour point to the nearest key skeleton point", refers to traversing all contour points of the Chinese character extracted in step 6 in turn. For the current contour point m(x1,y1), the formula (9) is used to calculate the distance from the current contour point m(x1,y1) to all key skeleton points i(x2,y2). By filtering the minimum value of the distance, the distance from the current contour point to the nearest key skeleton point is selected. The key skeleton point is the key skeleton point of the Chinese character obtained in step 4. The key skeleton point includes the endpoints, intersections, inflection points, bends, and widening points of the skeleton. The nearest key skeleton point is the key skeleton point that is closest to the current contour point among the key skeleton points in step 4.

[0239] (9).

[0240] like Figure 10 As shown, the current contour point is m(x1,y1), and the closest key skeleton point to m(x1,y1) is i(x2,y2). According to formula (9), the distance from the current contour point m(x1,y1) to the nearest key skeleton point i(x2,y2) can be calculated, which is ddist in the figure.

[0241] According to the establishment method provided by this invention, the "calculation of the distance threshold of the current nearest key skeleton point" in step 8 is to dynamically obtain the "distance threshold" size based on the stroke width of each key skeleton point of the Chinese character in step 5. The "distance threshold" size is "k * stroke width at the current key skeleton point", where the default value of k is 1.

[0242] like Figure 10 As shown, the stroke width at the current key skeleton point m(x1,y1) is SW, therefore the distance threshold to the nearest key skeleton point m(x1,y1) is SW.

[0243] According to the establishment method provided by this invention, step 9, "determining whether the current contour point is a key contour point," refers to determining whether the current contour point is a key contour point by comparing the distance from the current contour point obtained in step 7 to the nearest key skeleton point with the distance threshold of the current nearest key skeleton point obtained in step 8.

[0244] If the distance from the current contour point to the nearest key skeleton point is less than the "distance threshold", it proves that the current contour point is close to the key skeleton point and belongs to the contour point of the real stroke change. Then, the current contour point is recorded as the key contour point of the Chinese character.

[0245] Otherwise, it is proved that the current contour point is not close to any key skeleton points and belongs to the contour points at the jitter noise change or redundant contour points, so the current contour point is not recorded as the key contour point of the Chinese character;

[0246] As Figure 10 shown, the distance ddist from the current contour point m(x1, y1) to the nearest key skeleton point i(x2, y2) is less than the distance threshold SW, so the current contour point m(x1, y1) is recorded as the key contour point.

[0247] Among them, the finally extracted key contour points are the contour points that contain the true changes of the Chinese character, excluding most of the redundant contour points and noise contour points.

[0248] As Figure 9 shown, the white points on the edge of the Chinese character in the figure are all the key contour points of the Chinese character "Lv".

[0249] Considering the description of the present invention and the specific embodiments disclosed herein, other embodiments of the present invention will be obvious to those skilled in the art. These descriptions and embodiments are only considered as examples, and any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for extracting key contour points of Chinese characters based on key skeleton points and stroke width, characterized in that, The method comprises the following specific steps: Step 1, inputting a single Chinese character picture; Step 2, pre-processing the Chinese character picture in step 1 to generate a binary image; Step 3, extracting the skeleton of the Chinese character from the binary image in step 2 by using a skeleton extraction algorithm; Step 4, further extracting key skeleton points of the Chinese character from the skeleton in step 3, wherein the key skeleton points include end points, intersection points, inflection points, bending points and variable width points; Step 5, obtaining the stroke width at each key skeleton point of the Chinese character from the binary image in step 2 and the key skeleton points extracted in step 4, wherein the stroke width refers to the width of a stroke cross section formed by a specified point on the edge of the character and another point on the edge parallel to the specified point, wherein the stroke cross section is obtained by exploring in a direction perpendicular to the edge until the other point is found; Step 6, obtaining the contour points of the Chinese character from the binary image in step 2 by using a contour extraction algorithm; Step 7, sequentially traversing all the contour points of the Chinese character, and calculating the distance from the current contour point to the nearest key skeleton point; Step 8, calculating the distance threshold of the current nearest key skeleton point from the key skeleton points extracted in step 4 and the stroke width at the key skeleton points obtained in step 5; Step 9, comparing the distance from the current contour point to the nearest key skeleton point with the distance threshold obtained in step 8 to determine whether the current contour point is a key contour point; Step 10, if all the contour points are traversed, executing step 11, otherwise executing step 7; Step 11, outputting all the key contour points of the Chinese character, and ending the program.

2. The method of claim 1, wherein, The "extracting key skeleton points of the Chinese character" in step 4 refers to first extracting all the end points and intersection points of the skeleton based on the aggregation degree, further extracting all the inflection points of the skeleton, extracting all the bending points of the skeleton, and finally extracting all the variable width points with average stroke width variation, and the finally extracted key skeleton points include the end points, intersection points, inflection points, bending points and variable width points of the skeleton; the specific steps are as follows: Step 4.1, extracting the end points and intersection points of the skeleton based on the aggregation degree; The end points and intersection points are obtained by calculating the aggregation degree of the skeleton pixel point region of a given skeleton pixel point, and further comparing the aggregation degree with a threshold value; the skeleton pixel point region refers to a square region with a given side length centered on the pixel point, and the side length is 2*radius, wherein the value of radius is (max(width of the Chinese character picture, length of the Chinese character picture)*0.1) / 2; the threshold value includes a maximum threshold value and a minimum threshold value, wherein the maximum threshold value is 9 and the minimum threshold value is 6; Step 4.1.1, sequentially traversing all the skeleton pixel points (i, j), wherein 0=< i =<(width of the Chinese character picture-1) and 0=< j =<(length of the Chinese character picture-1), and executing step 4.1.2 for the current skeleton pixel point (i, j); Step 4.1.2, calculate the degree of the current skeleton pixel point (i, j) by using formula (1) and (2) i,j where i is the width coordinate of the current skeleton pixel point, j is the length coordinate of the current skeleton pixel point, k is all possible values within the range of (i-radius, i+radius), and l is all possible values within the range of (j-radius, j+radius). (1) where p k,l is the value at pixel point (k, l), p k,l is 1 if pixel point (k, l) is foreground, otherwise 0, i.e. p k,l takes the value as formula (2): (2) Step 4.1.3, compare the degree of aggregation of pixel point (i,j) i,j and the size relationship between the maximum threshold and the minimum threshold: If the degree of clustering of pixel (i,j) is... i,j If the maximum threshold is reached, then pixel (i,j) is an intersection point, and this pixel (i,j) is recorded as an intersection point. Otherwise, if the degree of aggregation degree of pixel point (i, j) is less than the minimum threshold value i,j < the minimum threshold value, this pixel point (i, j) is an endpoint, and the pixel point (i, j) is recorded as an endpoint. Otherwise, this pixel point (i, j) is neither an end point nor a crossing point, and it is not recorded. Step 4.1.4, if all skeleton pixel points are traversed, then execute step 4.1.5; otherwise, execute step 4.1.1; Step 4.1.5, all end points and all crossing points of the skeleton are obtained, wherein all end points and all crossing points of the skeleton are key skeleton points; Step 4.2, all inflection points of the skeleton are extracted by using a small-scale filtering method; Step 4.2.1, all skeleton pixel points (i, j) are traversed in turn, wherein 0 <= i <= (width of the Chinese character picture - 1), 0 <= j <= (length of the Chinese character picture - 1), and step 4.2.2 is executed for the current skeleton pixel point (i, j); Step 4.2.2, a "small region" of the current skeleton pixel point (i, j) is calculated, and the "small region" is expanded from the current skeleton pixel point (i, j) as the center, and the width and length of the "small region" are 0.1 times the width and length of the Chinese character picture respectively; Step 4.2.3, all "connected components" of key skeleton points in the "small region" of step 4.2.2 are calculated, wherein each "connected component" refers to an array of skeleton pixel points that are continuous and uninterrupted in the Chinese character skeleton; and each "connected component" is further put into an array point[N], wherein N is the number of skeleton pixel points in the "connected component"; further, the number of each "connected component" point[N] close to the boundary of the "small region" is calculated, and if the number close to the boundary of the "small region" is equal to 2, then the two boundary skeleton pixel points are recorded as the start point and the end point of the "connected component", and the two start and end points are used as the two end points of a straight line, and the equation of the straight line w is obtained by using formulas (4), (5) and (6); further, the distance of all skeleton pixel points in the "connected component" to the straight line w is calculated by using formula (7), and the result is put into an array dist[N], wherein N is the number of skeleton pixel points in the "connected component"; The equation of the straight line w is wherein: (4) (5) (6) The distance of the pixel point point[i] to the straight line w is dist[i] = |(i - x0) * (w - y0) - (w - y0) * x0| / sqrt(w * w + 1), wherein 0 <= i < N: (7) Step 4.2.4, the array index number z of the maximum value in dist[N] is obtained, that is, dist[z] is the maximum value, wherein N is the number of skeleton pixel points in the "connected component"; further, the size relationship between dist[z] and the "distance threshold value" is compared, if dist[z] > distance threshold value, then the skeleton pixel point point[z] corresponding to dist[z] is an inflection point, and the skeleton pixel point point[z] is recorded as the inflection point, wherein the distance threshold value is max(width of the "small region", length of the "small region) * 0.1, and all inflection points in the current "small region" are extracted in this step; Step 4.2.5, the "small region" in step 4.2.2 is moved according to a given step length, and the step length is set to be one quarter of the width and height of the "small region"; if all skeleton pixel points are traversed, then step 4.2.6 is executed; otherwise, step 4.2.2 is executed; Step 4.2.6, all inflection points of the skeleton are obtained. Step 4.2.6, all the turning points of the skeleton are obtained, wherein all the turning points of the skeleton are key skeleton points; Step 4.3, all the bending points of the skeleton are extracted by using a large-scale filtering method; Step 4.3.1, all the skeleton pixel points (i, j) are sequentially traversed, wherein 0=< i =<(width of the Chinese character picture-1), 0=< j =<(length of the Chinese character picture-1), and step 4.3.2 is executed for the current skeleton pixel point (i, j); Step 4.3.2, a "large area" of the current skeleton pixel point (i, j) is calculated, and a corresponding "large area" is expanded with the current skeleton pixel point (i, j) as the center, and the width and length of the "large area" are 0.2 times the width and length of the Chinese character picture, respectively; Step 4.3.3, all "connected components" of the key skeleton points in the "large area" of step 4.3.2 are calculated, and each "connected component" is put into an array point[N], wherein N is the number of skeleton pixel points in the "connected component"; the number of each "connected component" point[N] close to the boundary of the "large area" is calculated, and if the number close to the boundary of the "large area" is equal to 2, the two boundary skeleton pixel points are recorded as the starting point and the ending point of the "connected component", the two starting and ending points are taken as the two end points of a straight line, and the straight line w equation is obtained by using formulas (4), (5) and (6); further, the distance of all the skeleton pixel points in the "connected component" to the straight line w is calculated by using formula (7), and the result is put into an array dist[N], wherein N is the number of skeleton pixel points in the "connected component"; Step 4.3.4, the array index number t of the maximum value in dist[N] is obtained, that is, dist[t] is the maximum value, wherein N is the number of skeleton pixel points in the "connected component"; further, dist[t] and the "distance threshold" are compared, and if dist[t]>distance threshold, the skeleton pixel point point[t] corresponding to dist[t] is a bending point, and the skeleton pixel point point[t] is recorded as the bending point, wherein the distance threshold is max("width of the large area", "length of the large area")*0.1, and all the bending points in the current "large area" are extracted in this step; Step 4.3.5, the "large area" in step 4.3.2 is moved according to a given step length, and the step length is set to be one quarter of the width and height of the "large area"; if all the skeleton pixel points are traversed, step 4.3.6 is executed; otherwise, step 4.3.2 is executed; Step 4.3.6, all the bending points of the skeleton are obtained, wherein all the bending points of the skeleton are key skeleton points; Step 4.4, all the variable-width points of the average stroke width change are extracted; According to formula (8), key skeleton points, i.e. variable width points, whose stroke width changes greater than a width threshold t compared to the stroke width of the adjacent region are extracted, wherein SW is a set of stroke widths in a given region, SW nxt is a set of stroke widths of the adjacent region of the given region, and avg() is an average value of the stroke width. The variable width points of the skeleton are obtained as follows: (8) Step 4.4.1, a Chinese character stroke width image corresponding to the Chinese character binary image in step 2 is calculated, and the Chinese character stroke width image is an image with the same size as the original image, but the value of each pixel is the size of the stroke width at the pixel, and the value of the pixel in the background part is -1; Step 4.4.2, according to the stroke width map of Chinese characters in step 4.4.1, obtain the stroke width of all skeleton pixel points; Step 4.4.3, sequentially traverse all skeleton pixel points (i, j) of the Chinese character skeleton in step 3, wherein 0=< i =<(width of Chinese character picture-1), 0=< j =<(length of Chinese character picture-1), and perform step 4.4.4 for the current skeleton pixel point (i, j); Step 4.4.4, calculate the area of the current skeleton pixel point (i, j), wherein the width and length of the area are 0.1 times the width and length of the Chinese character picture, respectively; Step 4.4.5, in the region of step 4.4.4, the stroke width of the original picture corresponding to each skeleton pixel point in the region is calculated, the average stroke width avg(SW) of the region is calculated according to the stroke width of each skeleton pixel point in the region, and it is further compared with the difference of the average stroke width avg(SW) of the adjacent region; if it is greater than the width threshold t, the critical skeleton pixel point between the two regions is considered to be a variable width point, wherein the width threshold is 0.2 times the stroke width here. nxt ​ Step 4.4.6, if all skeleton pixel points are traversed, perform step 4.4.7; otherwise, perform step 4.4.3; Step 4.4.7, all variable width points of the skeleton are obtained, wherein all variable width points of the skeleton are key skeleton points.

3. The method of claim 1, wherein, Step 5, "obtaining the stroke width of each key skeleton point of Chinese characters" refers to calculating and generating a stroke width map from the binary image in step 2, wherein the stroke width map is an image with the same size as the original Chinese character image, but the value of each pixel is the size of the stroke width at that point, and the pixels in the background part are -1; sequentially traverse all key skeleton points obtained in step 4, and obtain the value in the stroke width map corresponding to the current key skeleton point according to the position of the current key skeleton point, as the stroke width at the current key skeleton point.

4. The method of claim 1, wherein, Step 7, "sequentially traversing all contour points of the Chinese character and calculating the distance from the current contour point to the nearest key skeleton point" refers to sequentially traversing all contour points of the Chinese character extracted in step 6, and further using formula (9) to calculate the distance from the current contour point m(x1, y1) to all key skeleton points i(x2, y2), and by screening the minimum value of the distance, the distance from the current contour point to the nearest key skeleton point is obtained, wherein the key skeleton points are the key skeleton points of the Chinese character obtained in step 4, and the key skeleton points include the end points, intersection points, turning points, bending points and variable width points of the skeleton; the nearest key skeleton point refers to the key skeleton point in step 4 that is closest to the current contour point; (9)。 5. The method of claim 1, wherein, Step 8, "calculating the distance threshold of the current nearest key skeleton point" refers to dynamically obtaining the size of the "distance threshold" according to the stroke width of each key skeleton point of the Chinese character in step 5, wherein the size of the "distance threshold" is "k*stroke width at the current key skeleton point", and the size of k is 1 by default.

6. The method of claim 1, wherein, Step 9, "determining whether the current contour point is a key contour point" refers to comparing the distance from the current contour point to the nearest key skeleton point obtained in step 7 with the distance threshold of the current nearest key skeleton point obtained in step 8 to determine whether the current contour point is a key contour point: If the distance from the current contour point to the nearest key skeleton point is less than the "distance threshold", it proves that the current contour point is close to the key skeleton point and belongs to the contour point of the true stroke change, and the current contour point is recorded as a key contour point of the Chinese character; Otherwise, it is proved that the current contour point is not close to any key skeleton point, belongs to the contour point of jitter noise variation or redundant contour point, and the current contour point is not recorded as the key contour point of the Chinese character; Among them, the finally extracted key contour point is the contour point containing the real change of the Chinese character, and most of the redundant contour points and noise contour points are removed.