CN110659644B - Automatic extraction method for strokes of calligraphy single characters - Google Patents
Automatic extraction method for strokes of calligraphy single characters Download PDFInfo
- Publication number
- CN110659644B CN110659644B CN201910561134.3A CN201910561134A CN110659644B CN 110659644 B CN110659644 B CN 110659644B CN 201910561134 A CN201910561134 A CN 201910561134A CN 110659644 B CN110659644 B CN 110659644B
- Authority
- CN
- China
- Prior art keywords
- point
- contour
- stroke
- points
- triangle
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/26—Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
Abstract
The invention discloses a method for automatically extracting strokes of calligraphy single characters, which is specifically carried out according to the following steps; step 1: graying and binarization processing are carried out on the calligraphy single character picture, and the outline of the single character is obtained according to the information of four neighborhood pixels of black pixels in the binarized picture; step 2: carrying out corner point detection on the contour obtained in the step 1, selecting a constraint side set and a constraint point set, and carrying out constraint Delaunay triangulation; and step 3: calculating the minimum distance between any two connecting triangles containing more than two angular points in the step 2, and determining a cross region and stroke segments connected with the cross region; and 4, step 4: and 3, analyzing the continuity of the stroke sections connected with all the cross areas in the step 3, connecting the stroke sections meeting the conditions to obtain a single stroke contour, filling the contour, and finally finishing the extraction of the strokes. The method can accurately search the cross area in the stroke extraction of the calligraphy single character; and the composite strokes can be extracted well.
Description
Technical Field
The invention belongs to the technical field of image processing methods and graphics, and particularly relates to an automatic stroke extraction method for calligraphy single characters.
Background
The hand stroke is the basic composition element of the Chinese character, and the stroke extraction has important functions in the fields of Chinese character classification, font identification, text retrieval, automatic generation of the Chinese character and the like. Chinese character strokes can be divided into: the more 30 categories of horizontal, vertical, left-falling, right-falling, etc. can be subdivided, and some strokes can be subdivided into more categories. The calligraphy characters are a handwriting form of Chinese characters, and the handwriting writing is divided into two modes of hard-tipped pen writing and wool-tipped pen writing. The stroke deformation, the adhesion among strokes, the thickness change of the strokes and the like of the writing brush calligraphy all bring difficulty to the stroke extraction of the calligraphy characters. But the information is unique information of the calligraphy works and has important functions on calligraphy style identification, copying and generation of calligraphy words with different styles.
The information of the stroke tip, the turning, the thickness and the like of the strokes is important embodiment of the style of the calligraphy characters and also is an important basis for judging the aesthetic property of the fonts, which is enough to explain the importance of the writing of the strokes on the overall artistic expression of the calligraphy characters. Therefore, the extraction of strokes of a calligraphy character is an indispensable step in representation, storage and understanding of the calligraphy, style learning, imitation creation of the calligraphy character and the writing process of reproducing the calligraphy character. Different from standard printed Chinese characters, however, because the writing of calligraphy characters has certain randomness, stroke tip, turning, thickness and the like, the current stroke extraction of calligraphy single characters cannot accurately search a cross region; the problem of not extracting compound strokes well.
Disclosure of Invention
The invention aims to provide an automatic stroke extraction method for calligraphy single characters, which solves the problem that the existing stroke extraction of calligraphy single characters cannot accurately search a cross region; the problem of not extracting compound strokes well.
The technical scheme adopted by the invention is that,
a method for automatically extracting strokes of calligraphy single characters is specifically carried out according to the following steps;
step 1: graying and binarization processing are carried out on the calligraphy single character picture, and the outline of the single character is obtained according to the information of four neighborhood pixels of black pixels in the binarized picture;
step 2, carrying out corner point detection on the contour obtained in the step 1, selecting a constraint edge set and a constraint point set, and carrying out constraint Delaunay triangulation;
step 3, calculating the minimum distance between any two connecting triangles including more than two angular points in the step 2, and determining a cross region and a stroke segment connected with the cross region;
and 4, analyzing the continuity of the stroke sections connected with all the cross areas in the step 3, connecting the stroke sections meeting the conditions to obtain a single stroke contour, filling the contour, and finally finishing the extraction of the strokes.
The present invention is also characterized in that,
in step 1, graying processing specifically includes setting RGB values of any pixel point in the picture to be r, g, and b, respectively, and then a calculation formula of a gray value gray of the pixel point is as follows:
gray=0.11×r+0.59×g+0.11×b;
the binarization processing specifically comprises the steps of counting the number of pixels with a pixel value of i, wherein the total number of pixels of the image is n, the number of pixels with a pixel value of i is an integer between 1 and 254, and the integer is divided by n to obtain a normalized value which is recorded as ni(ii) a Selecting an integer from 0 as a threshold t according toCounting the proportion w of pixels with pixel values in the interval [0, t)0According toCalculating the average gray value u of the pixels in the interval0(ii) a According toThe statistical pixel value is in the interval [ t, 255%]Inner pixel proportion w1According toCalculating the average gray value u of the pixels in the interval1According toCalculating the variance g of the mean gray level values of the pixels in the two intervals under the condition that the threshold is ttWill result in gtAnd (3) taking the maximum threshold value t as an optimal threshold value, and performing binarization processing on the image by taking the value as the threshold value, wherein the processed image is an image with white background and black characters, the white background pixel value is 255, and the black foreground corresponding pixel value is 0.
The contour of the single character is obtained by traversing all black pixel points in the binary image, and if the pixel values of the pixel points in the four neighborhoods of the single character are all 0, the single character is obtainedThe point is a non-contour point, the pixel value of the point is assigned to be 255, otherwise, the point is a contour point, and finally a contour map is obtained according to the result thatEstimating stroke width stroke _ width, wherein Nb,NcThe number of black pixel points in the binary image and the contour image, respectively.
Contour single-pixelization processing and bifurcation point removal: traversing black pixel points in the contour map, and if one of the following conditions is met, assigning the pixel value of the pixel point to be 255;
only one black pixel point is in the 8 neighborhoods of the pixel point;
after the pixel point is removed, the black pixel points in the 8 neighborhoods are still communicated;
judging the number n of connected domains by using a connected domain analysis function in an OpenCV (open circuit vehicle) library, and if n is greater than 1, disconnecting the connected domains;
and repeating the steps until the image is not changed any more, and finally obtaining the contour map with the single-pixel width.
Carrying out contour tracing on the single-pixel contour map: setting a tracking record for each black pixel, wherein the initial value is 0 to indicate that the black pixel is not tracked, tracking the first black pixel which is not tracked, changing the tracking record of the black pixel into 1, and adding the index value of the tracked pixel into the set CiFinally, a set C of closed contour points is obtainedi={(xk,yk) And repeating the step until the tracking records of all the black pixel points are 1, and finally obtaining a plurality of closed contour point sets.
Contour corner detection: traversing all points in the set of contour points, the ith point being denoted viThe coordinates are expressed as (v)i_x,viY) whose sharpness sharp (v) is calculated according to the following equationi):
Wherein v isi-k、vi+kRepresents and viTwo points with distance k ═ R (stroke _ width/3),
representing the Euclidean distance between two points, if the sharpness of the point satisfies sharp < th _ c, and th _ c is a threshold value, judging the point as a corner point, and adding the corner point into a corner point set corner { (x)k,yk)|k=1,2...n},
Screening corner points: for a point v in the set of corner pointsiIf the following formula is satisfied, the corner point is retained, otherwise, the corner point is deleted from the corner point set:
selecting a constraint point: at the ith contour point set CiUniformly sampling, and adding a certain point into a constraint point set C if the certain point meets the following conditionsi_point={(xk,yk) 1, 2.. n }:
wherein i represents the serial number of the point in the contour point set,representing a sampling interval, wherein i _ last represents the sequence number of the last point in the corner point set in the contour point set;
for the ith constraint point set CiPoint, corresponding to a set of constrained edges Ci_edge={(m,(m+1)%numi)|m=1,2...numiWhere numiRepresents the ith constraint point set CiThe number of points _;
judging the inner contour and the outer contour: for each closed contour, the number of points num1 in the contour and the number of black pixels num2 in the contour are determined, ifThen the profile isAn outer profile, otherwise the profile is an inner profile. And recording the coordinates of the first point in the inner contour, and adding an inner point set I _ point { (x)i,yi)|i=1,2,...numIIn (1) };
delaunay triangulation: according to the obtained constraint point set, constraint edge set and inner point set, utilizing a Triangle triangulation library to carry out constraint Delaunay triangulation, and obtaining a Triangle set T { (l, m, n) | l, m, n ∈ [0, num)p-1]An Edge set Edge { (l, m) | l, m ∈ [0, num {, m { (l, m) | l }p-1]},numpAnd the number of the constraint point concentration points is represented, a triangle is determined by three points, an edge is determined by two points, wherein the triangle containing one constraint edge is called a common triangle, and the triangle containing the constraint edge is called a connecting triangle.
The method for judging the inner contour and the outer contour comprises the following steps:
if the index of a certain point is (x, y), the number of contour points in a point set { (x ', y) | x' ═ 0, 1., x-1} is n1, the number of contour points in a point set { (x ', y) | x' ═ x +1, x + 2., the number of contour points in h-1} is n2, the number of contour points in a point set { (x, y ') | y' ═ 0, 1., y-1} is n3, the number of contour points in a point set is n4, the number of contour points in { (x, y ') | y' ═ x +1, x +2, ·, w-1} where h and w are respectively the height and width of an image, if one or four of n1, n2, n3, n4 is 0 or an even number, then the point is not within a contour, otherwise, the point is within a contour.
In step 3, a triangle adjacency list is established: searching the triangle adjacent to the ith triangle in the triangle set, if the ith triangle and the l, m and n triangles have common edges, the ith element in the adjacency list set is (l, m and n), and finally obtaining the adjacency list set
Table={(a,b,c)|a,b,c∈[0,numT-1]},
numTRepresenting the number of triangles in the triangle set;
finding a cross region: for any two connected triangles t containing two or more corner points in the triangle set1,t2Setting the middle points corresponding to the three sides of the two triangles to be M respectively1,M2,M3And M1',M2',M3', define the distance dis (t) of the two triangles1,t2)=min{|MiMj'||i,j∈[1,3]Where | MiMj' | denotes the euclidean distance between two points,
if the following conditions are met:then t1,t2Belonging to the same cross region, adding a cross region set c _ area { (a, b.) | a, b ∈ [0, num.) |T-1]}, weigh Mi,MjThe two sides are merged, the judgment is carried out on all the connecting triangle pairs containing two or more angular points, and the sides which are not merged are recorded;
the definition of the sub-stroke segment connected by the cross region is as follows: the length normal triangles that are adjacent to the triangles in the intersection region set and contain unmerged edges are denoted as (a)1,a2,...,alength) Wherein, a with subscript represents the serial number of the triangle, and the triangle adjacency list is traversed from the triangle of the crossing region to obtain a sub-stroke set corresponding to a certain crossing region as follows:
{(a1,a2,...,alength),(b1,b2,...,blength),....}。
in step 4, estimating the width and slope of the sub-stroke segment: sub-stroke section (a)1,a2,...,alength) Is represented as (a _ e)1,a_e2,...,a_elength+1) Edge a _ eiHas a midpoint coordinate of (a _ x)i,a_yi) The lengths of three sides of a common triangle are l1, l2 and l3 respectively, wherein l3 is the length of a constraint side according to wi=2×SiL3 calculating the width w of a triangle with index iiWherein
p=(l1+ l2+ l3)/2, according toEstimate the sub-stroke segment (a)1,a2,...,alength) Stroke width w ofaEstimating the sub-stroke segment (a) according to the following formula1,a2,...,alength) Slope K ofa:
Combination of cross-region sub-stroke segments: for any two sub-stroke segments (a) connected in the cross-region1,a2,...,alength),(b1,b2,...,blength) According toCalculating the slope of the point connecting line of the two sub-stroke segments, and calculating the continuity f (a, b) of the two sub-stroke segments according to the following formula:wherein A isa=arctan(Ka),Aa,Aa,bSimilarly, calculating the continuity of any two sub-stroke segments connected in the cross region, and adding the sequence number of the first triangle of the two sub-stroke segments meeting f < th _ con into the set join { (a)1,b1),(c1,d1) .., and arranging the elements of the set according to the order of their continuity from small to large, where th _ con is a threshold, and adding the first triangle sequence number of a single sub-stroke segment which does not satisfy f < th _ con with the continuity of any sub-stroke segment to the set break { e }1,f1,., the process is repeated, starting with the first element in the join set, and according to the triangle sequence number contained in this element, the add-delete operation 1 is performed on the adjacency list, and the elements in the set containing the processed triangle sequence number are deleted until the process is completedStarting from the first element in the break set, performing addition and deletion operation 2 on the adjacency list according to the element;
extracting the outline of a single stroke: starting from the first triangle, the adjacency list is traversed, and the traversed triangle sequence number is added into the single stroke set STi={t1,t2,.., where i represents the ith traversal, and this step is repeated until all triangle sequence numbers exist in a certain set; all triangles in a single stroke set are processed, and the two vertices of the constraint edge contained in the triangle are assumed to be (x)1,y1),(x2,y2) If the two vertexes belong to the certain contour point set, adding all elements between the two elements in the contour set into a single stroke contour point set:
SCi={(xi,yi) In 1,2, repeat this step, resulting in all the individual stroke sets STiCorresponding single stroke contour point set SCi;
And (3) contour filling, namely completing stroke extraction: newly-built n blank pictures I with the same size as the original pictures1,I2,...,InN is the number of the single stroke contour point set, and IiMiddle SCiAnd assigning the value of the pixel point corresponding to the set to be 0, finally obtaining the outline drawing of the single stroke, and carrying out outline filling on each outline drawing to obtain the final single stroke extraction result.
In the steps, the adding and deleting operation 1 comprises the following specific steps: for the element (a) in the join set1,b1) At a-th of the adjacency list set1Addition of b to each element1At b th of contiguous table set1Addition of a to each element1This operation is performed on all elements in the join set;
the adding and deleting operation 2 comprises the following specific steps: for element e in break set1Adjacent to table e1The value of a certain cross region in an element is d, and the e-th element in the adjacent table set1Deleting d from each element, deleting e from the d-th element of the adjacency list set1Performing the operation on all elements in the break set;
the outline filling method comprises the following specific steps:
if the coordinate of a certain black pixel point in the original binary image is (x, y), judging whether a certain point is in the contour, if the certain point is in the ith contour image IiInternally, then IiThe point with the (x, y) middle coordinate is assigned a value of 0 and the process is repeated until all contours have been filled.
The method has the beneficial effects that by utilizing Delaunay triangulation, the algorithm can extract the strokes of the calligraphy characters, has important effects on style recognition, copying and generation of the calligraphy characters with different styles, and can accurately search a cross region in the stroke extraction of the calligraphy single characters; and the compound strokes can be well extracted by combining the key point information.
Drawings
FIG. 1 is a general flowchart of a method for automatically extracting strokes of calligraphic single characters according to the present invention;
FIG. 2 is a schematic diagram of the outline obtained after step 1 of the automatic stroke extraction method for calligraphy single characters is implemented;
FIG. 3 is a schematic diagram of an angular point and Delaunay triangulation obtained after the step 2 of the automatic stroke extraction method for calligraphy characters is implemented;
FIG. 4 is a schematic diagram of a cross region and sub-stroke segments thereof obtained after step 3 of the automatic stroke extraction method for calligraphy characters according to the present invention is implemented;
FIG. 5 is a schematic diagram of a single stroke contour obtained after step 4 of the automatic stroke extraction method for calligraphy characters of the present invention is implemented, and a result after filling.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
The invention relates to a method for automatically extracting strokes of calligraphy single characters, which is specifically carried out according to the following steps as shown in figure 1:
step 1: graying and binarization processing are carried out on the calligraphy single character picture, and the outline of the single character is obtained according to the information of four neighborhood pixels of black pixels in the binarized picture;
step 1.1: specifically, if the RGB values of any pixel in the picture are r, g, and b, the gray value gray of the pixel is calculated as:
gray=0.11×r+0.59×g+0.11×b;
step 1.2: the binarization processing specifically comprises the steps of counting the number of pixels with a pixel value of i, wherein the total number of pixels of the image is n, the number of pixels with a pixel value of i is an integer between 1 and 254, and the integer is divided by n to obtain a normalized value which is recorded as ni(ii) a Selecting an integer from 0 as a threshold t according toCounting the proportion w of pixels with pixel values in the interval [0, t)0According toCalculating the average gray value u of the pixels in the interval0(ii) a According toThe statistical pixel value is in the interval [ t, 255%]Inner pixel proportion w1According toCalculating the average gray value u of the pixels in the interval1According toCalculating the variance g of the mean gray level values of the pixels in the two intervals under the condition that the threshold is ttWill result in gtAnd (3) taking the maximum threshold value t as an optimal threshold value, and performing binarization processing on the image by taking the value as the threshold value, wherein the processed image is an image with white background and black characters, the white background pixel value is 255, and the black foreground corresponding pixel value is 0.
Step 1.3: the contour is extracted by the method of extracting the contour,and traversing all black pixel points in the binary image, if the pixel values of the pixel points in the four neighborhoods of the binary image are all 0, determining the point as a non-contour point, assigning the pixel value of the point as 255, and if not, determining the point as a contour point to finally obtain the contour map. According toEstimating stroke width stroke _ width as 11, Nb,NcThe number of black pixel points in the binary image and the contour image, respectively, and R () represents rounding.
Step 1.4: acquiring the outline of the single word specifically including traversing all black pixel points in the binary image, if the pixel values of the pixel points in the four neighborhoods of the single word are all 0, the point is a non-outline point, the pixel value of the point is assigned to be 255, otherwise, the point is an outline point, finally obtaining an outline image, and according to the outline image, obtaining the outline image according to the fact that the pixel values of the pixel points in the four neighborhoods of the single word are all 0Estimating stroke width stroke _ width, wherein Nb,NcThe number of black pixel points in the binary image and the contour image, respectively.
Contour single-pixelization processing and bifurcation point removal: traversing black pixel points in the contour map, and if one of the following conditions is met, assigning the pixel value of the pixel point to be 255;
(1) only one black pixel point is in the 8 neighborhoods of the pixel point;
(2) after the pixel point is removed, the black pixel points in the 8 neighborhoods are still communicated;
and repeating the steps until the image is not changed any more, and finally obtaining the contour map with the single-pixel width. As shown in fig. 2.
The method for judging the connectivity of the black pixel points in the 8 neighborhoods comprises the following steps:
and judging the number n of the connected domains by using a connected domain analysis function in the OpenCV library, and if n is greater than 1, disconnecting the connected domains.
Step 1.5: contour tracing, setting a tracing record for each black pixel point in the single-pixel contour map obtained in step 1.4, wherein the initial value is 0, which indicates that the single-pixel contour map is not traced. Tracking from the first untracked black pixel, changing the tracking record to 1, adding the index value of the tracked pixel to the set CiFinally, a set C of closed contour points is obtainedi={(xk,yk) And repeating the step until the tracking records of all the black pixel points are 1, and finally obtaining a plurality of closed contour point sets.
The process in which a single closed contour is traced is:
and changing the tracking record of the first black pixel point into 1 by taking the first black pixel point as a tracking starting point, selecting a black pixel point with the tracking record of 0 from the 8 neighborhoods of the first black pixel point, starting tracking, and repeating the process until the tracking point returns to the starting point, so that all the pixel points with a closed contour are tracked.
Step 2, carrying out corner point detection on the contour obtained in the step 1, selecting a constraint edge set and a constraint point set, and carrying out constraint Delaunay triangulation;
step 2.1: detecting contour angular points;
traversing all points in the set of contour points, the ith point being denoted viThe coordinates are expressed as (v)i_x,viY) whose sharpness sharp (v) is calculated according to the following equationi):
Wherein v isi-k、vi+kRepresents and viA distance ofAt the two points of (a) and (b),representing the Euclidean distance between two points, if the sharpness of the point satisfies sharp < th _ c, and th _ c is a threshold value, judging the point as an angular point, and adding the angular point into an angular point set corners { (x)k,yk)|k=1,2...n},
Step 2.2: screening angular points;
for a point v in the set of corner pointsiIf the following formula is satisfied, the corner point is retained, otherwise, the corner point is deleted from the corner point set:
step 2.3: selecting a constraint point;
at the ith contour point set CiUniformly sampling, and adding a certain point into a constraint point set C if the certain point meets the following conditionsi_point={(xk,yk) 1, 2.. n }:
wherein i represents the serial number of the point in the contour point set,representing a sampling interval, wherein i _ last represents the sequence number of the last point in the corner point set in the contour point set;
step 2.4: selecting a constraint edge;
for the ith constraint point set CiPoint, corresponding constraint edge set is Ci_edge={(m,(m+1)%numi)|m=1,2...numiWhere numiRepresents the ith constraint point set CiNumber of points in point.
Step 2.5, judging the inner and outer contours, judging the number num1 of points in the contour and the number num2 of black pixels in the contour for each closed contour,
if num2/num1 is > 0.1,
the profile is an outer profile, otherwise the profile is an inner profile. And recording the coordinates of the first point in the inner contour, and adding an inner point set I _ point { (x)i,yi)|i=1,2,...numIIn (c) }.
The method for judging whether the point is in the contour comprises the following steps:
if the index of a certain point is (x, y), the number of contour points in the point set { (x ', y) | x' ═ 0, 1., x-1} is n1, the number of contour points in the point set { (x ', y) | x' ═ x +1, x + 2., h-1} is n2, the number of contour points in the point set { (x, y ') | y' ═ 0, 1., y-1} is n3,
the number of contour points in the point set { (x, y ') | y' ═ x +1, x +2,. ·, w-1} is n4, where h, w are the height and width of the image, respectively, and if one or four of n1, n2, n3, n4 are even numbers, the point is not within the contour, otherwise, the point is within the contour.
And 2.6, performing Delaunay triangulation by utilizing a Triangle triangulation library according to the obtained constraint point set, constraint edge set and inner point set, wherein the result is shown in figure 3. This step will get a triangle set T { (l, m, n) | l, m, n ∈ [0, num { (l, m, n) | lp-1]An Edge set Edge { (l, m) | l, m ∈ [0, num {, m { (l, m) | l }p-1]},numpAnd the number of the constraint point concentration points is represented, a triangle is determined by three points, and an edge is determined by two points. Wherein, the triangle containing one constraint side is called as a common triangle, and the triangle containing one constraint side is called as a connecting triangle.
Step 3, calculating the minimum distance between any two connecting triangles including more than two angular points in the step 2, and determining a cross region and a stroke segment connected with the cross region;
step 3.1, a triangle adjacency list is established, the ith triangle in the triangle set is searched for a triangle adjacent to the ith triangle, if the ith triangle and the l, m and n triangles have a common edge, the ith element in the adjacency list set is (l, m and n), and finally the adjacency list set Table { (a, b and c) | a, b and c ∈ [0, numT-1]},numTRepresenting the number of triangles in the set of triangles.
Step 3.2, searching a cross region, and for any two connected triangles t containing two or more angular points in the triangle set1,t2Setting the middle points corresponding to the three sides of the two triangles to be M respectively1,M2,M3And M1',M2',M3', define the distance dis (t) of the two triangles1,t2)=min{|MiMj'||i,j∈[1,3]Where | MiMj' | denotes the euclidean distance between two points. If it satisfiesThen t1,t2Belonging to the same cross region, adding a cross region set c _ area { (a, b.) | a, b ∈ [0, num.) |T-1]}, weigh Mi,MjThe two edges at which' are merged. All pairs of connected triangles comprising two or more corner points are subjected to the above judgment, and the sides which are not combined are recorded.
Step 3.3, the definition of the sub-stroke segments connected with the cross region is as follows: the length common triangles adjacent to the triangles in the intersection region set and containing unmerged sides is 4, and is marked as (a)1,a2,...,alength) Wherein a with subscript indicates the number of the triangle. Traversing the triangle adjacency list from the triangle of the crossing region to obtain a sub-stroke segment set corresponding to a certain crossing region as { (a)1,a2,...,alength),(b1,b2,...,blength),....}. The intersection region and its sub-stroke segments are shown in fig. 4.
And 4, analyzing the continuity of the stroke sections connected with all the cross areas in the step 3, connecting the stroke sections meeting the conditions to obtain a single stroke contour, filling the contour, and finally finishing the extraction of the strokes.
Step 4.1, estimating the width and slope of the sub-stroke segment, the sub-stroke segment (a)1,a2,...,alength) Is represented as (a _ e)1,a_e2,...,a_elength+1) Edge a _ eiHas a midpoint coordinate of (a _ x)i,a_yi) The lengths of three sides of a common triangle are l1, l2 and l3 respectively, wherein l3 is the length of a constraint side according to wi=2×Si/l3 calculating sequence number iWidth w of triangleiWhereinAccording toEstimate the sub-stroke segment (a)1,a2,...,alength) Stroke width w ofaEstimating the sub-stroke segment (a) according to1,a2,...,alength) Slope K ofa:
Step 4.2, the combination of the sub-stroke segments in the cross area, for any two sub-stroke segments (a) connected in the cross area1,a2,...,alength),(b1,b2,...,blength) According toAnd calculating the slope of the connecting line of the midpoints of the two sub-stroke segments. The continuity f (a, b) of the two sub-stroke segments is calculated according to the following formula:wherein A isa=arctan(Ka),Aa,Aa,bThe same is true. Alpha is alpha1,α2Are all taken as 0.4, alpha3Taking 0.2, calculating the continuity of any two sub-stroke segments connected in the cross area, and adding the sequence number of the first triangle of the two sub-stroke segments meeting f < th _ con into the join set join { (a)1,b1),(c1,d1) .., and arranging the set elements according to the order of their continuity from small to large, where th _ con is 0.7 as the threshold, adding the first triangle sequence number of a single sub-stroke segment not meeting f < th _ con with the continuity of any sub-stroke segment into the set break { e }1,f1,.. The following process is repeated, from the first of the join setsStarting the element, according to the triangle sequence number contained in the element, adding and deleting operation 1 is carried out on the adjacent table, and the element containing the processed triangle sequence number in the set is deleted until the element is deletedUntil now. Starting from the first element in the break set, add/delete operation 2 is performed on the adjacency list according to the element.
The specific steps of the adding and deleting operation 1 are as follows:
for the element (a) in the join set1,b1) At a-th of the adjacency list set1Addition of b to each element1At b th adjacent table set1Addition of a to each element1This is done for all elements in the join set.
The adding and deleting operation 2 comprises the following specific steps:
for element e in break set1Adjacent to the table e1The value of a certain cross region in an element is d, and the e-th element in the adjacent table set1Deleting d from each element, deleting e from the d-th element of the adjacency list set1This is done for all elements in the break set.
Step 4.3, extracting the outline of the single stroke, traversing the adjacency list from the first triangle, and adding the traversed triangle sequence number into the single stroke set STi={t1,t2,.., where i represents the ith traversal, this step is repeated until all triangle sequence numbers exist in a certain set. All triangles in a single stroke set are processed, and two vertices of a constraint edge contained in the triangle are assumed to be (x)1,y1),(x2,y2) If the two vertices belong to a contour point set in step 1.5, all elements between the two elements in the contour set are added to a single stroke contour point set SCi={(xi,yi) I 1, 2. This step is repeated to obtain all the single stroke sets STiCorresponding single stroke contour point set SCi。
And 4.4, contour filling is carried out, and stroke extraction is completed. Newly-built n blank pictures I with the same size as the original pictures1,I2,...,InN is the number of the single stroke contour point set, and IiMedium SCiAnd (4) assigning the value of the pixel point corresponding to the set to be 0, and finally obtaining the contour map of the single stroke. And carrying out contour filling on each contour map to obtain a final single stroke extraction result. The profile and its filling results are shown in fig. 5.
The contour filling method comprises the following specific steps:
if the coordinate of a black pixel in the original binary image is (x, y), and the black pixel is located in the ith contour image IiInternally, then IiThe point with the middle coordinate (x, y) is assigned a value of 0 this step is repeated until all contours have been filled. The method in which it is determined that a point is inside the contour is the same as step 2.5.
The automatic stroke extraction method for the calligraphy single character utilizes Delaunay triangulation to accurately search a cross region; and the compound strokes can be well extracted by combining the key point information. The algorithm can extract strokes of the calligraphy characters, has important effects on style recognition and copying of the calligraphy characters and generation of the calligraphy characters with different styles, and is suitable for popularization and use.
Claims (1)
1. A method for automatically extracting strokes of calligraphy single characters is characterized by comprising the following steps of;
step 1: graying and binaryzation processing are carried out on the calligraphy single character picture, and the outline of the single character is obtained according to the information of pixel points in four neighborhoods of black pixel points in the binaryzation picture;
step 2, carrying out corner point detection on the contour obtained in the step 1, selecting a constraint edge set and a constraint point set, and carrying out constraint Delaunay triangulation;
step 3, calculating the minimum distance between any two connecting triangles including more than two angular points in the step 2, and determining a cross region and a stroke segment connected with the cross region;
step 4, carrying out continuity analysis on the stroke sections connected with all the cross areas in the step 3, connecting the stroke sections meeting the conditions to obtain a single stroke contour, carrying out contour filling, and finally finishing the extraction of the strokes;
in step 1, the graying processing specifically includes setting RGB values of any one pixel point in the picture to be r, g, and b, respectively, and then a calculation formula of a gray value gray of the pixel point is as follows:
gray=0.11×r+0.59×g+0.11×b;
the binarization processing specifically comprises the steps of counting the number of pixel points with a pixel value of i, wherein the total number of the pixels of the image is n, the number of the pixel points with a pixel value of i is an integer between 1 and 254, and the integer is divided by n to obtain a normalized value which is recorded as ni(ii) a Selecting an integer from 0 as a threshold t according toCounting the proportion w of pixels with pixel values in the interval [0, t)0According toCalculating the average gray value u of the pixels in the interval0(ii) a According toThe statistical pixel value is in the interval [ t, 255%]Inner pixel proportion w1According toCalculating the average gray value u of the pixels in the interval1According to gt=w0×w1×(u0-u1)2Calculating the variance g of the mean gray level values of the pixels in the two intervals under the condition that the threshold is ttWill result in gtTaking the maximum threshold value t as an optimal threshold value, and performing binarization processing on the image by taking the value as the threshold value, wherein the processed image is an image with white background and black characters, the pixel value of a white background is 255, and the pixel value corresponding to a black foreground is 0;
the contour of the obtained single character is specifically all black pixel points in the ergodic binary image, if the contour is the black pixel pointsIf the pixel values of the pixel points in the four neighborhoods are all 0, the pixel point is a non-contour point, the pixel value of the point is assigned to be 255, otherwise, the pixel point is a contour point, a contour map is finally obtained, and the contour map is obtained according to the conditions that the pixel values of the pixel points in the four neighborhoods are all 0, the pixel value of the point is assigned to be 255, and the pixel value of the point is not assigned to be 255Estimating stroke width stroke _ width, wherein Nb,NcThe number of black pixel points in the binary image and the contour image respectively;
contour single-pixelization processing and bifurcation point removal: traversing black pixel points in the contour map, and if one of the following conditions is met, assigning the pixel value of the pixel point to be 255;
only one black pixel point is in the 8 neighborhoods of the pixel point;
after the pixel point is removed, the black pixel points in the 8 neighborhoods are still communicated;
judging the number n of connected domains by using a connected domain analysis function in an OpenCV (open circuit vehicle) library, and if n is greater than 1, disconnecting the connected domains;
repeating the steps until the image is not changed any more, and finally obtaining a contour map with the width of a single pixel;
carrying out contour tracing on the single-pixel contour map: setting a tracking record for each black pixel point, wherein the initial value is 0 to indicate that the black pixel point is not tracked, tracking the first black pixel point which is not tracked, changing the tracking record into 1, and adding the index value of the tracked pixel point into the set CiFinally, a set C of closed contour points is obtainedi={(xk,yk) Repeating the step until the tracking records of all black pixel points are 1, and finally obtaining a plurality of closed contour point sets;
and detecting the contour corner points: traversing all points in the set of contour points, the ith point being denoted viThe coordinates are expressed as (v)i_x,viY) whose sharpness sharp (v) is calculated according to the following equationi):
Wherein v isi-k、vi+kRepresents and viA distance ofAt the two points of (a) and (b),representing the Euclidean distance between two points if the sharpness of the point satisfies sharp<And th _ c are threshold values, the point is determined to be a corner point, and the corner point is added into a corner point set corner { (x)k,yk)|k=1,2...n},
Screening corner points: for one point v in the set of corner pointsiIf the following formula is satisfied, the corner point is retained, otherwise, the corner point is deleted from the corner point set:
selecting a constraint point: at the ith contour point set CiUniformly sampling, and adding a certain point into a constraint point set C if the certain point meets the following conditionsi_point={(xk,yk) 1, 2.. n }:
wherein, i represents the sequence number of the point in the contour point set, interval ═ R (stroke _ width/3) represents the sampling interval, i _ last represents the sequence number of the last point in the corner point set in the contour point set;
for the ith constraint point set CiPoint, corresponding constraint edge set is Ci_edge={(m,(m+1)%numi)|m=1,2...numiWhere numiRepresents the ith constraint point set CiThe number of points in point;
judging the inner contour and the outer contour: for each closed contour, the number of points num1 in the contour and the number of black pixels num2 in the contour are determined, if num2/num1>0.1, then the profile is an outer profile, otherwise the profile is an inner profile(ii) a And recording the coordinates of the first point in the inner contour, and adding an inner point set I _ point { (x)i,yi)|i=1,2,...numIIn (1) };
delaunay triangulation: according to the obtained constraint point set, constraint edge set and inner point set, utilizing a Triangle triangulation library to carry out constraint Delaunay triangulation, and obtaining a Triangle set T { (l, m, n) | l, m, n ∈ [0, num)p-1]An Edge set Edge { (l, m) | l, m ∈ [0, num {, m { (l, m) | l }p-1]},numpRepresenting the number of the constraint point concentration points, determining a triangle by three points, determining an edge by two points, wherein the triangle containing a constraint edge is called a common triangle, and the triangle containing the constraint edge is called a connecting triangle;
the method for judging the inner and outer contours comprises the following steps:
if the index of a certain point is (x, y), the number of contour points in a point set { (x ', y) | x' ═ 0, 1., x-1} is n1, the number of contour points in a point set { (x ', y) | x' ═ x +1, x + 2., the number of contour points in h-1} is n2, the number of contour points in a point set { (x, y ') | y' ═ 0, 1., y-1} is n3, the number of contour points in n4, the number of contour points in { (x, y ') | y' ═ x +1, x +2, ·, w-1} where h, w are respectively the height and width of the image, if one or four of n1, n2, n3, n4 is 0 or an even number, then the point is not within the contour, otherwise, the point is within the contour;
in step 3, a triangle adjacency list is established: finding the triangle adjacent to the ith triangle in the triangle set, if the ith triangle has a common edge with the l, m and n triangles, the ith element in the adjacency list set is (l, m and n), and finally obtaining the adjacency list set Table { (a, b and c) | a, b and c ∈ [0 and num { (a, b and c) | aT-1]},numTRepresenting the number of triangles in the triangle set;
finding a cross region: for any two connected triangles t containing two or more corner points in the triangle set1,t2Setting the middle points corresponding to the three sides of the two triangles to be M respectively1,M2,M3And M1',M2',M3' two or three angles are definedDistance dis (t) of the shape1,t2)=min{|MiMj'||i,j∈[1,3]H, where | MiMj' | denotes the euclidean distance between two points;
if the following conditions are met:then t1,t2Belonging to the same cross region, adding a cross region set c _ area { (a, b.) | a, b ∈ [0, num.) |T-1]}, weigh Mi,MjThe two sides are merged, the judgment is carried out on all the connecting triangle pairs containing two or more angular points, and the sides which are not merged are recorded;
the definition of the sub-stroke segment connected by the cross region is as follows: the length normal triangles that are adjacent to the triangles in the intersection region set and contain unmerged edges are denoted as (a)1,a2,...,alength) Wherein, a with subscript represents the serial number of the triangle, and the triangle adjacency list is traversed from the triangle of the crossing region to obtain a sub-stroke set corresponding to a certain crossing region as follows:
{(a1,a2,...,alength),(b1,b2,...,blength),....};
in the step 4, the width and the slope of the sub-stroke segment are estimated: sub-stroke section (a)1,a2,...,alength) Is represented as (a _ e)1,a_e2,...,a_elength+1) Edge a _ eiHas a midpoint coordinate of (a _ x)i,a_yi) The lengths of three sides of a common triangle are l1, l2 and l3 respectively, wherein l3 is the length of a constraint side according to wi=2×SiL3 calculating the width w of a triangle with index iiIn which
p ═ 2 (l1+ l2+ l3)/2, according toEstimate the sub-stroke segment (a)1,a2,...,alength) Stroke width w ofaEstimating the sub-stroke segment (a) according to the following formula1,a2,...,alength) Slope K ofa:
Combination of cross-region sub-stroke segments: for any two sub-stroke segments (a) connected at the cross region1,a2,...,alength),(b1,b2,...,blength) According toCalculating the slope of the point connecting line of the two sub-stroke segments, and calculating the continuity f (a, b) of the two sub-stroke segments according to the following formula:
wherein A isa=arctan(Ka),Aa,Aa,bSimilarly, calculating the continuity of any two sub-stroke segments connected in the cross region will satisfy f<the sequence number of the first triangle of the two sub-stroke segments of th _ con is added to the join-pending set join { (a)1,b1),(c1,d1) .., and arranging the collection elements according to the order of their continuity from small to large, wherein th _ con is a threshold value, and the continuity of any sub-stroke segment will not satisfy f<the first triangle sequence number of a single sub-stroke segment of th _ con is added to the set break { e }1,f1,., repeating the following processes, starting from the first element in the join set, and according to the triangle sequence number contained in the element, performing add-delete operation 1 on the adjacency list, and deleting the triangle sequence number contained in the set and processedUp toStarting from the first element in the break set, performing addition and deletion operation 2 on the adjacency list according to the element;
extracting the outline of a single stroke: starting from the first triangle, the adjacency list is traversed, and the traversed triangle sequence number is added into the single stroke set STi={t1,t2,.., where i represents the ith traversal, and this step is repeated until all triangle sequence numbers exist in a certain set; all triangles in a single stroke set are processed, and the two vertices of the constraint edge contained in the triangle are assumed to be (x)1,y1),(x2,y2) If the two vertexes belong to the certain contour point set, adding all elements between the two elements in the contour set into a single stroke contour point set:
SCi={(xi,yi) In 1,2, repeat this step, resulting in all the individual stroke sets STiCorresponding single stroke contour point set SCi;
And (3) contour filling, namely completing stroke extraction: newly-built n blank pictures I with same size as the original picture1,I2,...,InN is the number of the single stroke contour point set, and IiMiddle SCiAssigning the value of the pixel points corresponding to the set to be 0, finally obtaining the contour map of a single stroke, and carrying out contour filling on each contour map to obtain the final single stroke extraction result;
in the step 4, the add/delete operation 1 specifically includes the following steps: for the element (a) in the join set1,b1) At a-th of the adjacency list set1Addition of b to each element1At b th of contiguous table set1Addition of a to each element1This operation is performed on all elements in the join set;
the adding and deleting operation 2 comprises the following specific steps: for element e in break set1Adjacent to table e1The value of a certain cross region in an element is d, and the e-th element in the adjacent table set1Deleting d from each element, deleting e from the d-th element of the adjacency list set1Performing the operation on all elements in the break set;
the outline filling method comprises the following specific steps:
if the coordinate of a certain black pixel point in the original binary image is (x, y), judging whether a certain point is in the contour, if the certain point is in the ith contour image IiInternally, then IiThe point with the (x, y) middle coordinate is assigned a value of 0 and the process is repeated until all contours have been filled.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910561134.3A CN110659644B (en) | 2019-06-26 | 2019-06-26 | Automatic extraction method for strokes of calligraphy single characters |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910561134.3A CN110659644B (en) | 2019-06-26 | 2019-06-26 | Automatic extraction method for strokes of calligraphy single characters |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110659644A CN110659644A (en) | 2020-01-07 |
CN110659644B true CN110659644B (en) | 2022-07-01 |
Family
ID=69028700
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910561134.3A Active CN110659644B (en) | 2019-06-26 | 2019-06-26 | Automatic extraction method for strokes of calligraphy single characters |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110659644B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111812923A (en) * | 2020-05-06 | 2020-10-23 | 帝能(广州)电子科技股份有限公司 | Control method of copying projection system and projection system thereof |
CN111598883B (en) * | 2020-05-20 | 2023-05-26 | 重庆工程职业技术学院 | Calibration label equipment for acquiring cloud data medical images and working method |
CN112036522A (en) * | 2020-07-20 | 2020-12-04 | 上海卓希智能科技有限公司 | Calligraphy individual character evaluation method, system and terminal based on machine learning |
CN112598768B (en) * | 2021-03-04 | 2021-05-25 | 中国科学院自动化研究所 | Method, system and device for disassembling strokes of Chinese characters with common fonts |
CN113642542B (en) * | 2021-10-14 | 2022-02-08 | 中国科学院自动化研究所 | Method for extracting homonymous strokes of handwritten Chinese characters based on position constraint |
CN114820873B (en) * | 2022-05-13 | 2023-04-07 | 南京大学 | Sketch regularization method, device and medium based on painting |
CN116580129A (en) * | 2023-04-18 | 2023-08-11 | 南京信息工程大学 | Method, device and storage medium for improving calligraphy character skeleton based on distance transformation |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102968764A (en) * | 2012-10-26 | 2013-03-13 | 北京航空航天大学 | Chinese character image inpainting method based on strokes |
CN103927537A (en) * | 2014-05-08 | 2014-07-16 | 电子科技大学 | Extraction algorithm of self-adapting intersection regions of strokes of Chinese characters |
CN104951788A (en) * | 2015-07-08 | 2015-09-30 | 上海海事大学 | Extracting method of strokes of separate character in calligraphy work |
CN109919158A (en) * | 2018-11-12 | 2019-06-21 | 上海海事大学 | A kind of stroke separation method based on Chinese character contour |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2012103794A1 (en) * | 2011-01-31 | 2012-08-09 | 北京壹人壹本信息科技有限公司 | Method and device for implementing original handwriting, and electronic device |
-
2019
- 2019-06-26 CN CN201910561134.3A patent/CN110659644B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102968764A (en) * | 2012-10-26 | 2013-03-13 | 北京航空航天大学 | Chinese character image inpainting method based on strokes |
CN103927537A (en) * | 2014-05-08 | 2014-07-16 | 电子科技大学 | Extraction algorithm of self-adapting intersection regions of strokes of Chinese characters |
CN104951788A (en) * | 2015-07-08 | 2015-09-30 | 上海海事大学 | Extracting method of strokes of separate character in calligraphy work |
CN109919158A (en) * | 2018-11-12 | 2019-06-21 | 上海海事大学 | A kind of stroke separation method based on Chinese character contour |
Non-Patent Citations (4)
Title |
---|
Triangular Mesh Based Stroke Segmentation for Chinese Calligraphy;Xiaoqing Wang,et al.;《2013 12th International Conference on Document Analysis and Recognition》;20130828;全文 * |
刘佳岩 等.基于书写规则的书法字笔画及笔顺提取.《微型机与应用》.2015, * |
基于书写规则的书法字笔画及笔顺提取;刘佳岩 等;《微型机与应用》;20151231;全文 * |
基于轮廓尖锐度的图像角点检测方法;钱文光 等;《计算机工程》;20080331;第34卷(第6期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110659644A (en) | 2020-01-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110659644B (en) | Automatic extraction method for strokes of calligraphy single characters | |
CN111814722B (en) | Method and device for identifying table in image, electronic equipment and storage medium | |
CN110738207B (en) | Character detection method for fusing character area edge information in character image | |
CN106156761B (en) | Image table detection and identification method for mobile terminal shooting | |
CN105931295B (en) | A kind of geologic map Extracting Thematic Information method | |
CN111626146B (en) | Merging cell table segmentation recognition method based on template matching | |
CN110188778B (en) | Residential area element outline regularization method based on image extraction result | |
CN103093240A (en) | Calligraphy character identifying method | |
CN109409211B (en) | Processing method, processing device and storage medium for Chinese character skeleton stroke segments | |
US11488402B2 (en) | Method and system for segmenting touching text lines in image of uchen-script Tibetan historical document | |
CN112364834A (en) | Form identification restoration method based on deep learning and image processing | |
CN114359538A (en) | Water meter reading positioning and identifying method | |
CN110598581B (en) | Optical music score recognition method based on convolutional neural network | |
CN111626145A (en) | Simple and effective incomplete form identification and page-crossing splicing method | |
Ntzios et al. | An old greek handwritten OCR system based on an efficient segmentation-free approach | |
CN112070684B (en) | Method for repairing characters of a bone inscription based on morphological prior features | |
CN109325483B (en) | Method and device for processing internal short pen section | |
Park et al. | A method for automatically translating print books into electronic Braille books | |
Tung et al. | Binarization of uneven-lighting image by maximizing boundary connectivity | |
CN105160300B (en) | A kind of text abstracting method based on level-set segmentation | |
CN110378337B (en) | Visual input method and system for drawing identification information of metal cutting tool | |
CN115471849B (en) | Handwritten Chinese character image evaluation method and system | |
CN111444903A (en) | Method, device and equipment for positioning characters in cartoon bubbles and readable storage medium | |
CN109215047B (en) | Moving target detection method and device based on deep sea video | |
CN104112135B (en) | Text image extraction element and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |