CN112990183A - Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters - Google Patents

Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters Download PDF

Info

Publication number
CN112990183A
CN112990183A CN202110547648.0A CN202110547648A CN112990183A CN 112990183 A CN112990183 A CN 112990183A CN 202110547648 A CN202110547648 A CN 202110547648A CN 112990183 A CN112990183 A CN 112990183A
Authority
CN
China
Prior art keywords
point
stroke
chinese character
framework
branch
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.)
Granted
Application number
CN202110547648.0A
Other languages
Chinese (zh)
Other versions
CN112990183B (en
Inventor
陈艳红
王彦情
崔晓光
张吉祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Institute of Automation of Chinese Academy of Science
Original Assignee
Institute of Automation of Chinese Academy of Science
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Institute of Automation of Chinese Academy of Science filed Critical Institute of Automation of Chinese Academy of Science
Priority to CN202110547648.0A priority Critical patent/CN112990183B/en
Publication of CN112990183A publication Critical patent/CN112990183A/en
Application granted granted Critical
Publication of CN112990183B publication Critical patent/CN112990183B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/22Image preprocessing by selection of a specific region containing or referencing a pattern; Locating or processing of specific regions to guide the detection or recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/25Determination of region of interest [ROI] or a volume of interest [VOI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation 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
    • G06V10/267Segmentation 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 by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/44Local 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Character Discrimination (AREA)

Abstract

The invention belongs to the technical field of image processing, and particularly relates to an off-line handwritten Chinese character homonymous stroke extraction method, system and device, aiming at solving the problem that the conventional handwritten Chinese character homonymous stroke extraction method is lacked, so that students cannot be guided to normally write Chinese characters precisely to the stroke level. The method comprises the following steps: acquiring a handwritten Chinese character image and a reference Chinese character image; zooming the minimum external rectangle of the foreground area of the reference Chinese character image to realize the alignment of the minimum external rectangle with the handwritten Chinese character image; acquiring a segmentation communication area of a handwritten Chinese character image; calculating the minimum external rectangle, the main direction and the relative position relation with other strokes of each stroke communication area of the reference Chinese character image; adjusting the stroke position; acquiring a homonymous stroke communication area in a handwritten Chinese character image; and outputting the stroke connected region with the same name and the point set corresponding to the outline thereof. The invention realizes the extraction of homonymous strokes of handwritten Chinese characters, and further can guide students to write Chinese characters regularly by being accurate to the stroke level.

Description

Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to a method, a system and a device for extracting homonymous strokes of off-line handwritten Chinese characters.
Background
Can write Chinese characters in a standard and beautiful way and is beneficial to the study, work and life of one person. At present, exemplary teaching resources for teaching students to normatively write Chinese characters are rich, but feedback guidance of calligraphy practice works of the students mainly depends on manual work, and efficiency is low, so that intelligent means is needed to timely and effectively give targeted guidance opinions to the calligraphy works of the students, and the calligraphy practice effect of the students is improved.
The method is characterized in that a student is guided to correctly and normatively write the Chinese characters, except for judging the alignment and the error of the written Chinese characters, more importantly, guidance suggestions are given to regularity of each stroke, a stroke frame structure and the like of the Chinese characters, so that each stroke of the handwritten Chinese characters needs to be accurately distinguished, and the matched connected region in a handwritten Chinese character image is called homonymous stroke of the reference Chinese character. The Chinese characters are various and are the combination of communicated areas with complex topological structures, and the difficulty in extracting homonymous strokes of handwritten Chinese characters is increased due to the fact that the Chinese characters written by different people are different. Based on the method, the invention provides an off-line handwritten Chinese character homonymous stroke extraction method.
Disclosure of Invention
In order to solve the problems in the prior art, namely solving the problem that the standard writing of Chinese characters by students cannot be guided precisely to the stroke level due to the lack of the extraction method of the homonymous strokes of the handwritten Chinese characters at present, the invention provides an off-line extraction method of homonymous strokes of the handwritten Chinese characters, which comprises the following steps:
s10, acquiring a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
s20, extracting the minimum external rectangle of the foreground area of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
s30, extracting pixel points on the outline outside each connected region in the replaced handwritten Chinese character image, and constructing a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, and extracting pixel points of each pixel point on the skeleton branch corresponding to the first point set; constructing a closed contour as a segmentation communicating area, and calculating a minimum circumscribed rectangle and a main direction of each segmentation communicating area;
the skeleton endpoint is a skeleton point with only one neighbor or two adjacent neighbors in the eight neighborhoods as a skeleton point: the skeleton branch points are skeleton points with the number of 0-1 or 1-0 change times more than 4 and even number in eight neighborhoods; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 495651DEST_PATH_IMAGE001
Figure 558285DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
s40, correcting the outline of the Chinese character stroke vector in the reference Chinese character image according to the zoom ratio obtained in S20, and drawing the single stroke of the Chinese character in the corrected reference Chinese character image on the image in sequence according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
s50, sorting the boundary strokes and the internal strokes from big to small by the long side of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
s60, in a third point set that the distance between the third point set and the main direction of the segmentation communicating area is less than the set main direction distance threshold, the gradient direction distance between the third point set and the segmentation communicating area is less than the set gradient direction distance threshold, and the stroke contour point with the closest pixel distance is taken as the corresponding point of the contour point of the segmentation communicating area, the stroke category of the stroke contour point corresponding to the segmentation communicating area contour point is taken as the stroke category of the segmentation communicating area contour point, and the stroke category with the largest number of contour points is taken as the stroke category of the segmentation communicating area; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character;
and S70, extracting the images of the homonymous stroke communication areas and the point sets corresponding to the outer contours thereof as homonymous stroke extraction results of the handwritten Chinese character images and outputting the homonymous stroke extraction results.
In some preferred embodiments, in step S30, "extracting skeleton end points and skeleton branch points of the chinese character from the second point set, and extracting a skeleton branch set as the first skeleton branch set by combining the skeleton end points and the skeleton branch points; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set as a second framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point, wherein the method comprises the following steps of:
acquiring skeleton end points and skeleton branch points of the Chinese characters from the second point set;
traversing pixel points in the second point set, if the current pixel point is not a framework end point and a framework branch point, taking the pixel point as a first point of a framework branch in a pre-constructed first framework branch set, acquiring a neighborhood point of the pixel point, judging whether the neighborhood point belongs to the second point set or does not belong to the framework end point and the framework branch point, if so, adding the neighborhood point into the current framework branch, and circularly traversing the neighborhood points of the neighborhood point until the neighborhood point does not belong to the second point set or belongs to the framework end point and the framework branch point, so as to obtain a framework branch of the handwritten Chinese character image; continuously traversing the residual pixel points of the second point set until all the pixel points in the second point set are completely traversed to obtain a first skeleton branch set of the handwritten Chinese character image;
extracting a framework inflection point of the Chinese character from the first framework branch set;
traversing the pixel points in the second point set again, if the current pixel point is not a framework endpoint, a framework branch point and a framework inflection point, taking the pixel point as a first point of a framework branch in a pre-constructed second framework branch set, acquiring a neighborhood point of the pixel point, judging whether the neighborhood point belongs to the second point set or does not belong to the framework endpoint, the framework branch point and the framework inflection point, if so, adding the neighborhood point into the current framework branch, and circularly traversing the neighborhood point of the neighborhood point until the neighborhood point does not belong to the second point set or belongs to the framework endpoint, the framework branch point and the framework inflection point, so as to obtain a framework branch of the handwritten Chinese character image; and continuously traversing the residual pixel points of the second point set until all the pixel points in the second point set are completely traversed, and obtaining a second skeleton branch set of the handwritten Chinese character image.
In some preferred embodiments, in step S30, "go through the first point set in combination with the skeleton branch point and the skeleton inflection point, and calculate the corresponding point pair between the first point set and the second point set", the method includes:
for each pixel point in the first point set, if the neighborhood point set comprises a framework branch point and a framework inflection point, taking a characteristic point closest to the pixel as a corresponding point to form a corresponding point pair; if the neighborhood point set does not contain the framework branch point and the framework inflection point, taking a pixel point closest to the pixel as a corresponding point; the characteristic points comprise skeleton end points, skeleton branch points and skeleton inflection points.
In some preferred embodiments, the method for determining the main direction, the sub direction, the single x direction, and the single y direction corresponding to the split communication area includes:
solving two eigenvalues and eigenvectors of the covariance matrix for the point set corresponding to the outer contour of each segmentation communicating area by adopting a Principal Component Analysis (PCA) method;
calculating an included angle between the two eigenvectors and the x axis, taking the included angle between the eigenvector corresponding to the larger eigenvalue of the two eigenvalues and the x axis as a main direction of the divided communicating region, and taking the included angle between the other eigenvector and the x axis as a secondary direction;
if the ratio of the large characteristic value to the small characteristic value in the two characteristic values is larger than a set threshold value, the segmentation communicating area is unidirectional, otherwise the segmentation communicating area is bidirectional; if the division communication area is in a single direction, if the angular distance between the main direction of the division communication area and the x axis is smaller than the angular distance between the main direction of the division communication area and the y axis, the division communication area is in a single x direction, otherwise, the division communication area is in a single y direction.
In some preferred embodiments, in step S40, "the relative position relationship between each stroke connected region and other strokes" is calculated by:
for each stroke connected region
Figure 236960DEST_PATH_IMAGE002
If other strokes are taken
Figure 676032DEST_PATH_IMAGE003
In the single x direction, the judgment is made
Figure 217872DEST_PATH_IMAGE002
Whether or not to be at
Figure 716986DEST_PATH_IMAGE003
Above or below; if it is
Figure 95009DEST_PATH_IMAGE003
In the single y direction, the judgment is made
Figure 337772DEST_PATH_IMAGE002
Whether or not to be at
Figure 734118DEST_PATH_IMAGE003
Left or right of; otherwise, judging
Figure 404134DEST_PATH_IMAGE002
Whether or not to be at
Figure 269453DEST_PATH_IMAGE003
Up/down/left/right;
judgment of
Figure 315906DEST_PATH_IMAGE002
Whether or not to be at
Figure 566759DEST_PATH_IMAGE003
The above method of (1) is: let x coordinate at
Figure 407676DEST_PATH_IMAGE003
Between the left edge and the right edge of the circumscribed rectangle, and from the upper edge of the image to the stroke of the y coordinate
Figure 760291DEST_PATH_IMAGE003
The area between the upper edges is marked as a region of interest if
Figure 344856DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 715795DEST_PATH_IMAGE002
In that
Figure 727613DEST_PATH_IMAGE003
Above (1);
judgment of
Figure 564594DEST_PATH_IMAGE002
Whether or not to be at
Figure 687271DEST_PATH_IMAGE003
The following method is as follows: coordinate x on the stroke
Figure 115978DEST_PATH_IMAGE003
Between the left edge and the right edge of the circumscribed rectangle, and between the lower edge and the stroke of the image by the y coordinate
Figure 564277DEST_PATH_IMAGE003
The area between the lower edges is marked as a region of interest if
Figure 875173DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 817852DEST_PATH_IMAGE002
In that
Figure 163383DEST_PATH_IMAGE003
Below (1);
judgment of
Figure 517004DEST_PATH_IMAGE002
Whether or not to be at
Figure 49616DEST_PATH_IMAGE003
The method to the left of (1) is: the y coordinate is arranged in the stroke
Figure 530407DEST_PATH_IMAGE003
Between the upper edge and the lower edge of the circumscribed rectangle, and the x coordinate is from the left edge to the stroke of the image
Figure 730445DEST_PATH_IMAGE003
The area between the left edges is marked as a region of interest if
Figure 254967DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 806034DEST_PATH_IMAGE002
In that
Figure 824937DEST_PATH_IMAGE003
To the left;
judgment of
Figure 879480DEST_PATH_IMAGE002
Whether or not to be at
Figure 840483DEST_PATH_IMAGE003
The right method of (3) is: the y coordinate is arranged in the stroke
Figure 347688DEST_PATH_IMAGE003
Between the upper edge and the lower edge of the circumscribed rectangle, and the x coordinate is from the right edge to the stroke of the image
Figure 907632DEST_PATH_IMAGE003
The area between the right edges is marked as a region of interest if
Figure 82261DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 948586DEST_PATH_IMAGE002
In that
Figure 208666DEST_PATH_IMAGE003
To the right of (c).
In some preferred embodiments, the "adjusting stroke position" in step S50 is performed by:
pair of strokes
Figure 834951DEST_PATH_IMAGE004
According to the stroke
Figure 598507DEST_PATH_IMAGE004
Calculating a forbidden area of the stroke according to the relative position relation of the stroke and all the strokes with the adjusted positions, and calculating a feasible adjusting area according to the current position of the stroke;
the method comprises the steps of reserving a handwritten Chinese character communication area which is in a feasible adjustment area of a stroke, is not in a forbidden area of the stroke and has a stroke main direction smaller than a threshold value, taking a contour point set of the reserved Chinese character communication area under the hand as a target point set, taking the contour point set of the stroke communication area as a source point set, solving a transformation matrix from the source point set to the target point set according to an iterative nearest neighbor method, and further adjusting the position of a reference Chinese character stroke according to the obtained transformation matrix;
wherein the strokes are
Figure 901313DEST_PATH_IMAGE004
The calculation method of the forbidden zone comprises the following steps:
for the
Figure 383110DEST_PATH_IMAGE002
For all strokes with adjusted positions
Figure 547506DEST_PATH_IMAGE003
If, if
Figure 431148DEST_PATH_IMAGE002
Is out of position
Figure 904855DEST_PATH_IMAGE003
Above/below/left/right, then
Figure 873948DEST_PATH_IMAGE003
Above/below/left/right of
Figure 576456DEST_PATH_IMAGE002
The forbidden area of (a); if the stroke at the adjusted position of the stroke at the first position after the sorting in the step S50 is empty, the corresponding forbidden area is empty;
stroke (pen)
Figure 845763DEST_PATH_IMAGE004
The calculation method of the feasible adjustment area comprises the following steps:
Figure 490371DEST_PATH_IMAGE005
wherein,
Figure 946760DEST_PATH_IMAGE006
Figure 905489DEST_PATH_IMAGE007
Figure 245947DEST_PATH_IMAGE008
Figure 858194DEST_PATH_IMAGE009
respectively the coordinates, the width and the height of the upper left corner point of the stroke circumscribed rectangle,
Figure 5142DEST_PATH_IMAGE010
Figure 564299DEST_PATH_IMAGE011
respectively the width and the height of the image,
Figure 27772DEST_PATH_IMAGE012
Figure 748604DEST_PATH_IMAGE013
Figure 179585DEST_PATH_IMAGE014
Figure 276854DEST_PATH_IMAGE015
respectively to the left of the feasible adjustment regionCoordinates of the upper corner points, width and height,
Figure 125992DEST_PATH_IMAGE016
the predetermined coefficient represents the size of the feasible adjustment area.
In some preferred embodiments, the distance between two main directions of the divided communication areas is calculated by:
Figure 17725DEST_PATH_IMAGE017
Figure 936003DEST_PATH_IMAGE018
wherein,
Figure 836962DEST_PATH_IMAGE019
the distance in the main direction is indicated,
Figure 9449DEST_PATH_IMAGE020
Figure 337662DEST_PATH_IMAGE021
indicating the main direction of the two split linking areas.
The second aspect of the invention provides an off-line handwritten Chinese character homonymous stroke extraction system, which comprises: the device comprises an image acquisition module, an image alignment module, an area segmentation module, a feature element calculation module, a position adjustment module, a homonymy stroke connected area extraction module and an extraction result output module;
the image acquisition module is configured to acquire a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
the image alignment module is configured to extract a minimum circumscribed rectangle of a foreground area of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
the region segmentation module is configured to extract pixel points on the outer contour of each connected region in the replaced handwritten Chinese character image and construct a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, and extracting pixel points of each pixel point on the skeleton branch corresponding to the first point set; constructing a closed contour as a segmentation communicating area, and calculating a minimum circumscribed rectangle and a main direction of each segmentation communicating area;
the skeleton endpoint is a skeleton point with only one neighbor or two adjacent neighbors in the eight neighborhoods as a skeleton point: the skeleton branch points are skeleton points with the number of 0-1 or 1-0 change times more than 4 and even number in eight neighborhoods; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 477656DEST_PATH_IMAGE001
Figure 385570DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
the characteristic element calculation module is configured to correct the outline of the Chinese character stroke vector in the reference Chinese character image according to the zoom ratio obtained in the image alignment module, and draw the single stroke of the Chinese character in the corrected reference Chinese character image on the image in sequence according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
the position adjusting module is configured to sort the boundary strokes and the internal strokes from big to small by the long edge of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
the homonymous stroke connected region extraction module is configured to set the gradient direction distance between each contour point in the contour point set of the segmentation connected region of the handwritten Chinese character image and the set gradient direction distance threshold value in a third contour point set with the distance between the third contour point and the main direction of the segmentation connected region being smaller than the set main direction distance threshold value, and the stroke contour point with the closest pixel distance is taken as the corresponding point of the contour point of the segmentation connected region, and the stroke category of the stroke contour point corresponding to the segmentation connected region contour point is taken as the stroke category of the segmentation connected region contour point, and the stroke category with the largest number of contour points is taken as the stroke category of the segmentation region; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character;
and the extraction result output module is configured to extract the image of the homonymous stroke communication area and the point set corresponding to the outline thereof as the homonymous stroke extraction result of the handwritten Chinese character image to output.
In a third aspect of the present invention, a storage device is provided, in which a plurality of programs are stored, the programs being adapted to be loaded and executed by a processor to implement the above-mentioned method for extracting homonymous strokes of handwritten Chinese characters.
In a fourth aspect of the present invention, a processing apparatus is provided, which includes a processor and a storage device; a processor adapted to execute various programs; a storage device adapted to store a plurality of programs; the program is suitable for being loaded and executed by a processor to realize the off-line handwritten Chinese character homonymy stroke extraction method.
The invention has the beneficial effects that:
the invention realizes the extraction of homonymous strokes of handwritten Chinese characters, and further can guide students to write Chinese characters regularly by being accurate to the stroke level.
1) The method aligns the preprocessed handwritten Chinese character image with the reference Chinese character image, performs area segmentation on the handwritten Chinese character, respectively extracts the characteristic elements of the handwritten Chinese character segmentation area and the characteristic elements of the reference Chinese character stroke communication area, adopts a constraint overlap nearest neighbor method to adjust the stroke position of the reference Chinese character, and realizes the extraction of the homonymous strokes of the offline handwritten Chinese character based on the characteristic elements, the position and the gradient direction constraint.
2) The area segmentation method for the handwritten Chinese character image can segment the handwritten Chinese character image into image elements with better unidirectionality, and is favorable for extracting homonymous strokes of crossed strokes; the stroke position of the reference Chinese character is adjusted under the additional constraint condition, the homonymous strokes are extracted based on multiple constraints, and the accuracy of extracting the homonymous strokes is improved on the basis of keeping the inter-stroke frame structure. The output result of the method can be used for deeply analyzing the overall structure, stroke arrangement, stroke form and the like of the written Chinese characters, and provides a technical basis for guiding the standard writing of the Chinese characters.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings.
FIG. 1 is a schematic flow chart of a method for extracting homonymous strokes of an offline handwritten Chinese character according to an embodiment of the present invention;
FIG. 2 is a block diagram of an offline handwritten Chinese character homonymous stroke extraction system according to an embodiment of the present invention;
FIG. 3 is a simplified flowchart of a method for extracting homonymous strokes of an offline handwritten Chinese character according to an embodiment of the present invention;
FIG. 4 is an exemplary diagram of a handwritten Chinese character image and a reference Chinese character image in accordance with an embodiment of the invention;
FIG. 5 is an exemplary diagram of the alignment of handwritten Chinese character images and reference Chinese character images in accordance with an embodiment of the present invention;
FIG. 6 is a diagram illustrating a segmentation result of connected regions of a handwritten Chinese character image according to an embodiment of the present invention;
FIG. 7 is an exemplary diagram of a result of homonymous stroke extraction for a handwritten Chinese character, in accordance with an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
The invention discloses a method for extracting homonymous strokes of off-line handwritten Chinese characters, which comprises the following steps of:
s10, acquiring a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
s20, extracting the minimum external rectangle of the foreground area of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
s30, extracting pixel points on the outline outside each connected region in the replaced handwritten Chinese character image, and constructing a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, and extracting pixel points of each pixel point on the skeleton branch corresponding to the first point set; constructing a closed contour as a segmentation communicating area, and calculating a minimum circumscribed rectangle and a main direction of each segmentation communicating area;
the skeleton endpoint is a skeleton point with only one neighbor or two adjacent neighbors in the eight neighborhoods as a skeleton point: the skeleton branch points are skeleton points with the number of 0-1 or 1-0 change times more than 4 and even number in eight neighborhoods; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 927409DEST_PATH_IMAGE001
Figure 191905DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
s40, correcting the outline of the Chinese character stroke vector in the reference Chinese character image according to the zoom ratio obtained in S20, and drawing the single stroke of the Chinese character in the corrected reference Chinese character image on the image in sequence according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
s50, sorting the boundary strokes and the internal strokes from big to small by the long side of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
s60, in a third point set that the distance between the third point set and the main direction of the segmentation communicating area is less than the set main direction distance threshold, the gradient direction distance between the third point set and the segmentation communicating area is less than the set gradient direction distance threshold, and the stroke contour point with the closest pixel distance is taken as the corresponding point of the contour point of the segmentation communicating area, the stroke category of the stroke contour point corresponding to the segmentation communicating area contour point is taken as the stroke category of the segmentation communicating area contour point, and the stroke category with the largest number of contour points is taken as the stroke category of the segmentation communicating area; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character;
and S70, extracting the images of the homonymous stroke communication areas and the point sets corresponding to the outer contours thereof as homonymous stroke extraction results of the handwritten Chinese character images and outputting the homonymous stroke extraction results.
In order to more clearly explain the method for extracting homonymous strokes of the offline handwritten Chinese characters, the steps in one embodiment of the method of the invention are expanded and detailed in the following with reference to fig. 1 and 3.
S10, acquiring a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
in the embodiment, a handwritten Chinese character image is obtained firstly, an original image of the handwritten Chinese character image is obtained by shooting or scanning through a camera, the handwritten Chinese character image is preprocessed, so that a Chinese character area is white, the rest part of the handwritten Chinese character image is black, and the preprocessed (preferably subjected to binarization processing in the invention) image is used as the handwritten Chinese character image of the method; the reference Chinese character and the handwritten Chinese character are the same Chinese character, the reference Chinese character data is stored as the vector outline of the ordered strokes, the stroke outline points can be obtained from the vector outline, the strokes are drawn on the image to obtain the reference Chinese character image, wherein the Chinese character part is a white foreground, and the rest part is a black background, as shown in figure 4.
S20, extracting the minimum external rectangle of the foreground area of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
in this example, the process of calculating the aspect ratio of the second rectangle to be scaled to the scaling of the first rectangle is as shown in equation (1):
Figure 615933DEST_PATH_IMAGE022
(1)
wherein,
Figure 61958DEST_PATH_IMAGE023
Figure 458304DEST_PATH_IMAGE024
is the width and the height of the first rectangle,
Figure 879052DEST_PATH_IMAGE025
Figure 993639DEST_PATH_IMAGE026
is the width and the height of the second rectangle,
Figure 774513DEST_PATH_IMAGE027
indicating the scaling.
Scaling the second rectangle according to the scaling ratio to obtain a third rectangle; and constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image. Further, the handwritten Chinese character image and the reference Chinese character image are aligned, and the alignment result is shown in FIG. 5.
S30, extracting pixel points on the outline outside each connected region in the replaced handwritten Chinese character image, and constructing a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, and extracting pixel points of each pixel point on the skeleton branch corresponding to the first point set; constructing a closed contour as a segmentation communicating area, and calculating a minimum circumscribed rectangle and a main direction of each segmentation communicating area;
the skeleton endpoint is a skeleton point with only one neighbor or two adjacent neighbors in the eight neighborhoods as a skeleton point: the skeleton branch points are skeleton points with the number of 0-1 or 1-0 change times more than 4 and even number in eight neighborhoods; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 290945DEST_PATH_IMAGE001
Figure 882594DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
in this example, the area segmentation and the area feature element calculation are performed on the handwritten Chinese character image, specifically:
s31, extracting pixel points on the outline outside each connected region in the replaced handwritten Chinese character image, and constructing a first point set;
s32, extracting the skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; the method specifically comprises the following steps:
for the pixel points in the first point set
Figure 750056DEST_PATH_IMAGE028
Building a neighborhood point set
Figure 334621DEST_PATH_IMAGE029
And a deletion mark image with the same size as the handwritten Chinese character image, wherein the position of the pixel point (namely the Chinese character part) corresponding to the foreground area in the handwritten Chinese character image in the initial mark image is marked as non-deletion, and the rest part is marked as deletion; using a thinning algorithm to check each pixel in the marked image, and marking the pixel meeting the deleting condition as to-be-deleted; for each pixel point in the first point set
Figure 705560DEST_PATH_IMAGE028
Set of neighborhood points of
Figure 468110DEST_PATH_IMAGE029
Each neighborhood point in (1)
Figure 291710DEST_PATH_IMAGE030
If, if
Figure 883228DEST_PATH_IMAGE030
Marked as to be deleted, then sequentially traversing
Figure 108673DEST_PATH_IMAGE030
The eight neighborhood pixel points are marked as not deleted and not in the set
Figure 556972DEST_PATH_IMAGE029
Adding pixel points in
Figure 881250DEST_PATH_IMAGE029
Then is at
Figure 807617DEST_PATH_IMAGE029
Deletion in
Figure 887569DEST_PATH_IMAGE030
(ii) a Marking the pixel points marked to be deleted in the marked image as deleted; repeating the steps of 'inspection of marked image → update of pixel neighborhood set in first point set → update of marked image' until no more pixels in the marked image are marked to be deleted, taking the obtained neighborhood point set as a second point set, and the points in the second point set are simply called skeleton points; wherein, aggregate
Figure 710031DEST_PATH_IMAGE029
The initial element of (A) is a pixel point
Figure 508223DEST_PATH_IMAGE028
. The extraction process of the skeleton points can be specifically referred to documents: "rafael c. gonzalez, richarde. woods. digital image processing (third edition)." electronics industry press, 2011. "11 th.Section 1.7, which is not described in detail herein.
S33, extracting the skeleton end points and the skeleton branch points of the Chinese characters from the second point set, and extracting a skeleton branch set by combining the skeleton end points and the skeleton branch points to be used as a first skeleton branch set; and extracting a framework inflection point from the first framework branch set, and re-extracting the framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set. The method comprises the following specific steps:
firstly, obtaining framework end points and framework branch points of the Chinese characters from a second point set, wherein the framework end points are defined as estimation points of which only one neighbor or two adjacent neighbors in eight neighborhoods are framework points; the skeleton branch point is defined as a skeleton point with 0-1 or 1-0 change times more than 4 and even number in the eight neighborhoods, namely, in the eight neighborhoods of a certain pixel point in the second point set, if the neighbor point is the pixel point in the second point set, the neighbor point is marked as 1, otherwise, the neighbor point is marked as 0; the eight neighborhoods are visited in numerical order from small to large in the following table, and the number of 0-1 or 1-0 changes in the neighborhoods is counted.
TABLE 1
1 2 3
8
Figure 989014DEST_PATH_IMAGE031
4
7 6 5
The eight numbered regions of 1-8 in table 1 represent eight neighborhoods.
Traversing each pixel point in the second point set, if the current pixel point is not a framework endpoint or a framework branch point, performing image growth by taking the pixel point as a seed pixel point until a certain pixel point is a framework endpoint or a framework branch point or the certain pixel point does not belong to the second point set, stopping the growth, and extracting a grown pixel segment as a framework branch; deleting the pixel points which are not the skeleton branch points in the pixel points covered by the skeleton branch in the second point set; and repeating the steps until all the points in the second pixel point set are the skeleton branch points. Traversing pixel points in a second point set, if the current pixel point is not a framework endpoint or a framework branch point, taking the pixel point as a first point of a framework branch in a pre-constructed first framework branch set, acquiring a neighborhood point of the pixel point, judging whether the neighborhood point belongs to the second point set or does not belong to the framework endpoint or the framework branch point, if so, adding the neighborhood point into the current framework branch, and circularly traversing the neighborhood point of the neighborhood point until the neighborhood point does not belong to the second point set or belongs to the framework endpoint or the framework branch point, so as to obtain a framework branch of the handwritten Chinese character image; and continuously traversing the residual pixel points of the second point set until all the pixel points in the second point set are completely traversed. And obtaining a first skeleton branch set of the handwritten Chinese character image.
Extracting a framework inflection point of the Chinese character from the first framework branch set, wherein the definition of the framework inflection point is as follows: for pixel point in each skeleton branch
Figure 923472DEST_PATH_IMAGE001
If distance
Figure 713574DEST_PATH_IMAGE001
The index distance is a set distance
Figure 264641DEST_PATH_IMAGE032
Two pixel points of
Figure 283543DEST_PATH_IMAGE033
Figure 338087DEST_PATH_IMAGE034
Calculating
Figure 299090DEST_PATH_IMAGE001
Opening angle formed by two pixel points
Figure 9557DEST_PATH_IMAGE035
If the opening angle is smaller than the set threshold value
Figure 81418DEST_PATH_IMAGE036
Then, then
Figure 6780DEST_PATH_IMAGE001
Is a framework inflection point; the calculation process is shown in formula (2):
Figure 138684DEST_PATH_IMAGE037
(2)
in one embodiment of the invention, the size of the aligned handwritten chinese character image and the reference chinese character image is 340x310,
Figure 398764DEST_PATH_IMAGE032
preferably in the configuration of 11, and preferably,
Figure 8737DEST_PATH_IMAGE036
preferably configured at 140.
Traversing the pixel points in the second point set again, if the current pixel point is not a framework endpoint, a framework branch point and a framework inflection point, taking the pixel point as a first point of a framework branch in a pre-constructed second framework branch set, acquiring a neighborhood point of the pixel point, judging whether the neighborhood point belongs to the second point set or does not belong to the framework endpoint, the framework branch point and the framework inflection point, if so, adding the neighborhood point into the current framework branch, and circularly traversing the neighborhood point of the neighborhood point until the neighborhood point does not belong to the second point set or belongs to the framework endpoint, the framework branch point and the framework inflection point, so as to obtain a framework branch of the handwritten Chinese character image; and continuously traversing the residual pixel points of the second point set until all the pixel points in the second point set are completely traversed, and obtaining a second skeleton branch set of the handwritten Chinese character image.
S34, after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, and calculating corresponding point pairs of the first point set and the second point set; the method specifically comprises the following steps:
for each pixel point in the first point set, if the neighborhood point set comprises a framework branch point and a framework inflection point, taking a characteristic point closest to the pixel as a corresponding point to form a corresponding point pair; if the neighborhood point set does not contain the framework branch point and the framework inflection point, taking a pixel point closest to the pixel as a corresponding point to form a corresponding point pair; the characteristic points comprise skeleton end points, skeleton branch points and skeleton inflection points.
S35, traversing the second skeleton branch set, and extracting pixel points of each pixel point on the skeleton branch corresponding to the pixel points in the first point set; and constructing a closed contour as a segmentation communicating area, and calculating the minimum circumscribed rectangle and the main direction of each segmentation communicating area. The method specifically comprises the following steps:
traversing the second skeleton branch set, and extracting the pixel point set of which the corresponding point in the first point set is the point for the pixel point on each skeleton branch
Figure 791535DEST_PATH_IMAGE038
To, for
Figure 828761DEST_PATH_IMAGE038
The points belonging to the outline of the same handwritten Chinese character image communication area are sorted according to the outline index to obtain one or more sub-outlines; if there is more than one sub-outline, the sub-outline is inserted and sorted by
Figure 576137DEST_PATH_IMAGE039
And sorted set of sub-profiles
Figure 989801DEST_PATH_IMAGE040
Calculating the position with the minimum distance between the distance and the adjacent sub-contour as the sub-contour
Figure 76706DEST_PATH_IMAGE039
Wherein the distance to the neighborhood sub-outline is calculated if
Figure 301145DEST_PATH_IMAGE039
Insert into
Figure 535817DEST_PATH_IMAGE041
Figure 487592DEST_PATH_IMAGE042
Then calculate the following two distances-
Figure 491321DEST_PATH_IMAGE039
First pixel point of
Figure 621082DEST_PATH_IMAGE041
The pixel distance of the last pixel point and
Figure 77471DEST_PATH_IMAGE039
last pixel point and
Figure 832937DEST_PATH_IMAGE042
the sum of the pixel distances of the first pixel point
Figure 894434DEST_PATH_IMAGE043
Figure 709943DEST_PATH_IMAGE039
Last pixel point and
Figure 404361DEST_PATH_IMAGE041
the pixel distance of the last pixel point and
Figure 697939DEST_PATH_IMAGE039
first pixel point of
Figure 676259DEST_PATH_IMAGE042
The sum of the pixel distances of the first pixel point
Figure 662670DEST_PATH_IMAGE044
Figure 841454DEST_PATH_IMAGE045
If it is to
Figure 938723DEST_PATH_IMAGE039
Insert into
Figure 505971DEST_PATH_IMAGE041
Figure 866545DEST_PATH_IMAGE042
In between
Figure 784822DEST_PATH_IMAGE046
The smallest distance among all insertion positions, then
Figure 170935DEST_PATH_IMAGE039
Insert into
Figure 858269DEST_PATH_IMAGE041
Figure 186482DEST_PATH_IMAGE042
If there is a
Figure 326476DEST_PATH_IMAGE047
Then will be
Figure 781859DEST_PATH_IMAGE039
The pixel points in the image are inserted after being arranged in a reverse order; set of sub-contours
Figure 589278DEST_PATH_IMAGE040
Last inThe next neighbor sub-outline of the sub-outline is the first sub-outline; and after the sorting is finished, the closed outline formed by all the pixel points in the sub-outline set is a segmentation communicating area of the handwritten Chinese character image. The segmentation result of connected regions in the handwritten Chinese character image is shown in FIG. 6.
Calculating the minimum circumscribed rectangle and the main direction of each divided communicating area as the characteristic elements of the divided communicating areas, wherein the main direction, the secondary direction, the single x direction and the single y direction corresponding to each divided communicating area are determined by the following steps:
solving two eigenvalues and eigenvectors of the covariance matrix for the point set corresponding to the outer contour of each segmentation communicating area by adopting a Principal Component Analysis (PCA) method;
calculating an included angle between the two eigenvectors and the x axis, taking the included angle between the eigenvector corresponding to the larger eigenvalue of the two eigenvalues and the x axis as a main direction of the divided communicating region, and taking the included angle between the other eigenvector and the x axis as a secondary direction;
if the ratio of the large characteristic value to the small characteristic value in the two characteristic values is larger than a set threshold value, the segmentation communicating area is unidirectional, otherwise the segmentation communicating area is bidirectional; if the division communication area is in a single direction, if the angular distance between the main direction of the division communication area and the x axis is smaller than the angular distance between the main direction of the division communication area and the y axis, the division communication area is in a single x direction, otherwise, the division communication area is in a single y direction. In the present invention, in the case of the present invention,
Figure 88393DEST_PATH_IMAGE048
preferably configured as 10.
The method for calculating the included angle between the feature vector and the x axis is shown as formula (3):
Figure 715683DEST_PATH_IMAGE049
(3)
wherein,
Figure 443599DEST_PATH_IMAGE050
Figure 105524DEST_PATH_IMAGE051
as feature vectors
Figure 978803DEST_PATH_IMAGE012
Figure 93389DEST_PATH_IMAGE013
The component (c).
S40, correcting the outline of the Chinese character stroke vector in the reference Chinese character image according to the zoom ratio obtained in S20, and drawing the single stroke of the Chinese character in the corrected reference Chinese character image on the image in sequence according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
in this example, the contour of the stroke vector of the chinese character in the reference chinese character image is corrected in accordance with the scaling obtained in S20, as shown in equation (4):
Figure 874263DEST_PATH_IMAGE052
(4)
wherein,
Figure 132639DEST_PATH_IMAGE012
Figure 239135DEST_PATH_IMAGE013
the original coordinates of the contour points corresponding to the contour of the stroke vector,
Figure 841018DEST_PATH_IMAGE053
Figure 425583DEST_PATH_IMAGE054
and the coordinates after the correction of the contour points corresponding to the stroke vector contour are shown.
And after correction, sequentially drawing single strokes of Chinese characters in the corrected reference Chinese character image on the image according to the stroke writing sequence, extracting pixel points on the outer contour of each stroke communicating area, and calculating the minimum external rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area to serve as stroke characteristic elements of the reference Chinese character image.
Wherein, the relative position relation of each stroke connected region and other strokes is calculated, and the method specifically comprises the following steps:
for each stroke connected region
Figure 999783DEST_PATH_IMAGE002
If other strokes are taken
Figure 762334DEST_PATH_IMAGE003
In the single x direction, the judgment is made
Figure 382671DEST_PATH_IMAGE002
Whether or not to be at
Figure 770927DEST_PATH_IMAGE003
Above or below; if it is
Figure 199635DEST_PATH_IMAGE003
In the single y direction, the judgment is made
Figure 133087DEST_PATH_IMAGE002
Whether or not to be at
Figure 709562DEST_PATH_IMAGE003
Left or right of; otherwise, judging
Figure 635929DEST_PATH_IMAGE002
Whether or not to be at
Figure 715881DEST_PATH_IMAGE003
Up/down/left/right;
judgment of
Figure 351393DEST_PATH_IMAGE002
Whether or not to be at
Figure 149584DEST_PATH_IMAGE003
The above method of (1) is: let x coordinate at
Figure 614064DEST_PATH_IMAGE003
Between the left edge and the right edge of the circumscribed rectangle, and from the upper edge of the image to the stroke of the y coordinate
Figure 814101DEST_PATH_IMAGE003
The area between the upper edges is marked as a region of interest if
Figure 807465DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 575176DEST_PATH_IMAGE002
In that
Figure 108926DEST_PATH_IMAGE003
Above (1);
judgment of
Figure 429048DEST_PATH_IMAGE002
Whether or not to be at
Figure 124472DEST_PATH_IMAGE003
The following method is as follows: coordinate x on the stroke
Figure 647988DEST_PATH_IMAGE003
Between the left edge and the right edge of the circumscribed rectangle, and between the lower edge and the stroke of the image by the y coordinate
Figure 719850DEST_PATH_IMAGE003
The area between the lower edges is marked as a region of interest if
Figure 628900DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 760804DEST_PATH_IMAGE002
In that
Figure 958567DEST_PATH_IMAGE003
Below (1);
judgment of
Figure 584852DEST_PATH_IMAGE002
Whether or not to be at
Figure 613987DEST_PATH_IMAGE003
The method to the left of (1) is: the y coordinate is arranged in the stroke
Figure 651214DEST_PATH_IMAGE003
Between the upper edge and the lower edge of the circumscribed rectangle, and the x coordinate is from the left edge to the stroke of the image
Figure 398590DEST_PATH_IMAGE003
The area between the left edges is marked as a region of interest if
Figure 828565DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 712207DEST_PATH_IMAGE002
In that
Figure 920335DEST_PATH_IMAGE003
To the left;
judgment of
Figure 889428DEST_PATH_IMAGE002
Whether or not to be at
Figure 310045DEST_PATH_IMAGE003
The right method of (3) is: the y coordinate is arranged in the stroke
Figure 801856DEST_PATH_IMAGE003
Between the upper edge and the lower edge of the circumscribed rectangle, and the x coordinate is from the right edge to the stroke of the image
Figure 446464DEST_PATH_IMAGE003
The area between the right edges is marked as a region of interest if
Figure 902853DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 923899DEST_PATH_IMAGE002
In that
Figure 532866DEST_PATH_IMAGE003
To the right of (c).
And finally, judging whether the stroke is above or below or on the left or right of all other strokes, if so, taking the stroke as a boundary stroke, and if not, taking the stroke as an internal stroke.
S50, sorting the boundary strokes and the internal strokes from big to small by the long side of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
in this example, the specific process of adjusting the stroke position is as follows:
pair of strokes
Figure 82796DEST_PATH_IMAGE004
According to the stroke
Figure 760902DEST_PATH_IMAGE004
Calculating a forbidden area of the strokes according to the relative position relation of the strokes with all the adjusted positions, and calculating a feasible adjusting area according to the current position of the strokes;
and (3) reserving a handwritten Chinese character communication area which is in a feasible adjustment area of the stroke, is not in a forbidden area of the stroke and has a main direction smaller than a threshold value with the stroke, taking the contour point set of the reserved Chinese character communication area under the hand as a target point set, taking the contour point set of the stroke communication area as a source point set, solving a transformation matrix from the source point set to the target point set according to an iterative nearest neighbor method, and further adjusting the position of the reference Chinese character stroke according to the obtained transformation matrix.
Wherein the strokes are
Figure 320059DEST_PATH_IMAGE004
Is forbidden zoneThe calculation method comprises the following steps:
for the
Figure 783533DEST_PATH_IMAGE002
For all strokes with adjusted positions
Figure 35522DEST_PATH_IMAGE003
If, if
Figure 466504DEST_PATH_IMAGE002
Is out of position
Figure 563773DEST_PATH_IMAGE003
Above/below/left/right, then
Figure 881753DEST_PATH_IMAGE003
Above/below/left/right of
Figure 39065DEST_PATH_IMAGE002
The forbidden area of (a); if the stroke at the adjusted position of the stroke at the first position after the sorting in the step S50 is empty, the corresponding forbidden area is empty;
stroke (pen)
Figure 691763DEST_PATH_IMAGE004
The calculation method of the feasible adjustment area comprises the following steps:
Figure 592723DEST_PATH_IMAGE055
(5)
wherein,
Figure 27859DEST_PATH_IMAGE006
Figure 356072DEST_PATH_IMAGE007
Figure 496066DEST_PATH_IMAGE008
Figure 138400DEST_PATH_IMAGE009
respectively the coordinates, the width and the height of the upper left corner point of the stroke circumscribed rectangle,
Figure 680240DEST_PATH_IMAGE010
Figure 930087DEST_PATH_IMAGE011
respectively the width and the height of the image,
Figure 557377DEST_PATH_IMAGE012
Figure 800140DEST_PATH_IMAGE013
Figure 462065DEST_PATH_IMAGE014
Figure 148393DEST_PATH_IMAGE015
the coordinate width and the height of the upper left corner point of the feasible adjustment area are respectively,
Figure 997400DEST_PATH_IMAGE016
for a preset coefficient indicating the size of the feasible adjustment region, N is preferably configured to be 4 in the present invention.
S60, in a third point set that the distance between the third point set and the main direction of the segmentation communicating area is less than the set main direction distance threshold, the gradient direction distance between the third point set and the segmentation communicating area is less than the set gradient direction distance threshold, and the stroke contour point with the closest pixel distance is taken as the corresponding point of the contour point of the segmentation communicating area, the stroke category of the stroke contour point corresponding to the segmentation communicating area contour point is taken as the stroke category of the segmentation communicating area contour point, and the stroke category with the largest number of contour points is taken as the stroke category of the segmentation communicating area; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character; the results of the extraction are shown in fig. 7.
In this example, the distance between the two main directions of the divided connected regions is calculated as follows:
Figure 43853DEST_PATH_IMAGE017
(6)
Figure 560285DEST_PATH_IMAGE056
(7)
wherein,
Figure 604465DEST_PATH_IMAGE057
the distance in the main direction is indicated,
Figure 691500DEST_PATH_IMAGE058
Figure 541645DEST_PATH_IMAGE059
indicating a main direction of two divided connected areas, a main direction distance threshold
Figure 912583DEST_PATH_IMAGE060
Is preferably arranged as
Figure 924402DEST_PATH_IMAGE061
And S70, extracting the images of the homonymous stroke communication areas and the point sets corresponding to the outer contours thereof as homonymous stroke extraction results of the handwritten Chinese character images and outputting the homonymous stroke extraction results.
In the embodiment, the connected region of the strokes with the same name in the handwritten Chinese character image and the point set corresponding to the outer contour thereof are output, so that a data basis is provided for subsequently evaluating the handwritten Chinese characters and guiding the writing specification.
An off-line handwritten Chinese character homonymous stroke extraction system according to a second embodiment of the present invention, as shown in fig. 2, includes: the system comprises an image acquisition module 100, an image alignment module 200, an area segmentation module 300, a feature element calculation module 400, a position adjustment module 500, a homonymy stroke connected area extraction module 600 and an extraction result output module 700;
the image obtaining module 100 is configured to obtain a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
the image alignment module 200 is configured to extract a minimum circumscribed rectangle of a foreground region of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
the region segmentation module 300 is configured to extract pixel points on the outer contour of each connected region in the replaced handwritten Chinese character image, and construct a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, and extracting pixel points of each pixel point on the skeleton branch corresponding to the first point set; constructing a closed contour as a segmentation communicating area, and calculating a minimum circumscribed rectangle and a main direction of each segmentation communicating area;
the skeleton end point is only one neighbor or two adjacent neighbors in eight neighborhoodsFramework points centered at framework points: the skeleton branch points are skeleton points with the number of 0-1 or 1-0 change times more than 4 and even number in eight neighborhoods; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 216843DEST_PATH_IMAGE001
Figure 917400DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
the feature element calculation module 400 is configured to correct the contour of the stroke vector of the Chinese character in the reference Chinese character image according to the scaling obtained in the image alignment module, and sequentially draw the single strokes of the Chinese character in the corrected reference Chinese character image on the image according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
the position adjusting module 500 is configured to sort the boundary strokes and the internal strokes from large to small by the long edge of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
the homonymous stroke connected region extraction module 600 is configured to set a gradient direction distance between each contour point in a contour point set of a segmentation connected region of the handwritten Chinese character image and a set gradient direction distance threshold in a third contour point set in which a distance between the contour point set of the segmentation connected region and a main direction of the segmentation connected region is smaller than the main direction distance threshold, and a stroke contour point with a closest pixel distance is used as a corresponding point of the contour point of the segmentation connected region, and a stroke category of the stroke contour point corresponding to the segmentation connected region contour point is used as a stroke category of the segmentation connected region contour point, and a stroke category with the largest number of contour points is used as a stroke category of the segmentation region; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character;
the extraction result output module 700 is configured to extract the image of the homonymous stroke connected region and the point set corresponding to the outline thereof as the homonymous stroke extraction result of the handwritten Chinese character image for output.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process and related description of the system described above may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
It should be noted that, the system for extracting homonymous strokes of offline handwritten chinese characters provided in the above embodiment is only illustrated by the division of the above functional modules, and in practical applications, the above functions may be allocated to different functional modules according to needs, that is, the modules or steps in the embodiment of the present invention are further decomposed or combined, for example, the modules in the above embodiment may be combined into one module, or may be further split into multiple sub-modules, so as to complete all or part of the above described functions. The names of the modules and steps involved in the embodiments of the present invention are only for distinguishing the modules or steps, and are not to be construed as unduly limiting the present invention.
A storage device according to a third embodiment of the present invention stores a plurality of programs, and the programs are adapted to be loaded by a processor and to implement the method for extracting homonymous strokes of handwritten Chinese characters.
A processing apparatus according to a fourth embodiment of the present invention includes a processor and a storage device; a processor adapted to execute various programs; a storage device adapted to store a plurality of programs; the program is suitable for being loaded and executed by a processor to realize the off-line handwritten Chinese character homonymy stroke extraction method.
It can be clearly understood by those skilled in the art that, for convenience and brevity, the specific working processes and related descriptions of the storage device and the processing device described above may refer to the corresponding processes in the foregoing method examples, and are not described herein again.
Referring now to FIG. 8, there is illustrated a block diagram of a computer system suitable for use as a server in implementing embodiments of the system, method and apparatus of the present application. The server shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 8, the computer system includes a Central Processing Unit (CPU) 801 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data necessary for system operation are also stored. The CPU801, ROM 802, and RAM803 are connected to each other via a bus 804. An Input/Output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a display such as a cathode ray tube, a liquid crystal display, and a speaker; a storage portion 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a local area network card, modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809 and/or installed from the removable medium 811. The computer program, when executed by the CPU801, performs the above-described functions defined in the method of the present application. It should be noted that the computer readable medium mentioned above in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. The computer-readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the C language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network or a wide area network, or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The terms "first," "second," and the like are used for distinguishing between similar elements and not necessarily for describing or implying a particular order or sequence.
The terms "comprises," "comprising," or any other similar term are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
So far, the technical solutions of the present invention have been described in connection with the preferred embodiments shown in the drawings, but it is easily understood by those skilled in the art that the scope of the present invention is obviously not limited to these specific embodiments. Equivalent changes or substitutions of related technical features can be made by those skilled in the art without departing from the principle of the invention, and the technical scheme after the changes or substitutions can fall into the protection scope of the invention.

Claims (10)

1. An off-line handwritten Chinese character homonymous stroke extraction method is characterized by comprising the following steps:
s10, acquiring a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
s20, extracting the minimum external rectangle of the foreground area of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
s30, extracting pixel points on the outline outside each connected region in the replaced handwritten Chinese character image, and constructing a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, extracting pixel points of each pixel point on the skeleton branch corresponding to the pixel points in the first point set, constructing a closed contour as a partition communicating area, and calculating the minimum circumscribed rectangle and the main direction of each partition communicating area;
the skeleton endpoint is a skeleton point with only one neighbor or two adjacent neighbors in the eight neighborhoods as a skeleton point: the skeleton branch points are skeleton points with the number of 0-1 or 1-0 change times more than 4 and even number in eight neighborhoods; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 112038DEST_PATH_IMAGE001
Figure 269350DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
s40, correcting the outline of the Chinese character stroke vector in the reference Chinese character image according to the zoom ratio obtained in S20, and drawing the single stroke of the Chinese character in the corrected reference Chinese character image on the image in sequence according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
s50, sorting the boundary strokes and the internal strokes from big to small by the long side of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
s60, in a third point set that the distance between the third point set and the main direction of the segmentation communicating area is less than the set main direction distance threshold, the gradient direction distance between the third point set and the segmentation communicating area is less than the set gradient direction distance threshold, and the stroke contour point with the closest pixel distance is taken as the corresponding point of the contour point of the segmentation communicating area, the stroke category of the stroke contour point corresponding to the segmentation communicating area contour point is taken as the stroke category of the segmentation communicating area contour point, and the stroke category with the largest number of contour points is taken as the stroke category of the segmentation communicating area; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character;
and S70, extracting the images of the homonymous stroke communication areas and the point sets corresponding to the outer contours thereof as homonymous stroke extraction results of the handwritten Chinese character images and outputting the homonymous stroke extraction results.
2. The method for extracting homonymous strokes of offline handwritten Chinese characters according to claim 1, wherein in step S30, "skeleton end points and skeleton branch points of Chinese characters are extracted from the second point set, and a skeleton branch set is extracted by combining the skeleton end points and the skeleton branch points to serve as a first skeleton branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set as a second framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point, wherein the method comprises the following steps of:
acquiring skeleton end points and skeleton branch points of the Chinese characters from the second point set;
traversing pixel points in the second point set, if the current pixel point is not a framework end point and a framework branch point, taking the pixel point as a first point of a framework branch in a pre-constructed first framework branch set, acquiring a neighborhood point of the pixel point, judging whether the neighborhood point belongs to the second point set or does not belong to the framework end point and the framework branch point, if so, adding the neighborhood point into the current framework branch, and circularly traversing the neighborhood points of the neighborhood point until the neighborhood point does not belong to the second point set or belongs to the framework end point and the framework branch point, so as to obtain a framework branch of the handwritten Chinese character image; continuously traversing the residual pixel points of the second point set until all the pixel points in the second point set are completely traversed to obtain a first skeleton branch set of the handwritten Chinese character image;
extracting a framework inflection point of the Chinese character from the first framework branch set;
traversing the pixel points in the second point set again, if the current pixel point is not a framework endpoint, a framework branch point and a framework inflection point, taking the pixel point as a first point of a framework branch in a pre-constructed second framework branch set, acquiring a neighborhood point of the pixel point, judging whether the neighborhood point belongs to the second point set or does not belong to the framework endpoint, the framework branch point and the framework inflection point, if so, adding the neighborhood point into the current framework branch, and circularly traversing the neighborhood point of the neighborhood point until the neighborhood point does not belong to the second point set or belongs to the framework endpoint, the framework branch point and the framework inflection point, so as to obtain a framework branch of the handwritten Chinese character image; and continuously traversing the residual pixel points of the second point set until all the pixel points in the second point set are completely traversed, and obtaining a second skeleton branch set of the handwritten Chinese character image.
3. The method for extracting homonymous strokes of offline handwritten Chinese characters according to claim 1, wherein in step S30, "go through the first point set in combination with the skeleton branch points and the skeleton inflection points, and calculate the corresponding point pairs between the first point set and the second point set", the method comprises:
for each pixel point in the first point set, if the neighborhood point set comprises a framework branch point and a framework inflection point, taking a characteristic point closest to the pixel as a corresponding point to form a corresponding point pair; if the neighborhood point set does not contain the framework branch point and the framework inflection point, taking a pixel point closest to the pixel as a corresponding point; the characteristic points comprise skeleton end points, skeleton branch points and skeleton inflection points.
4. The method for extracting homonymous strokes of off-line handwritten Chinese characters according to claim 1, wherein the method for judging the main direction, the secondary direction, the single x direction and the single y direction corresponding to the divided connected region comprises the following steps:
solving two eigenvalues and eigenvectors of the covariance matrix for the point set corresponding to the outer contour of each segmentation communicating area by adopting a Principal Component Analysis (PCA) method;
calculating an included angle between the two eigenvectors and the x axis, taking the included angle between the eigenvector corresponding to the larger eigenvalue of the two eigenvalues and the x axis as a main direction of the divided communicating region, and taking the included angle between the other eigenvector and the x axis as a secondary direction;
if the ratio of the large characteristic value to the small characteristic value in the two characteristic values is larger than a set threshold value, the segmentation communicating area is unidirectional, otherwise the segmentation communicating area is bidirectional; if the division communication area is in a single direction, if the angular distance between the main direction of the division communication area and the x axis is smaller than the angular distance between the main direction of the division communication area and the y axis, the division communication area is in a single x direction, otherwise, the division communication area is in a single y direction.
5. The method for extracting homonymous strokes of offline handwritten Chinese characters according to claim 4, wherein the calculation method of the relative position relationship between each stroke connected area and other strokes is as follows:
for each stroke connected region
Figure 669851DEST_PATH_IMAGE002
If other strokes are taken
Figure 570811DEST_PATH_IMAGE003
In the single x direction, the judgment is made
Figure 258144DEST_PATH_IMAGE002
Whether or not to be at
Figure 586357DEST_PATH_IMAGE003
Above or below; if it is
Figure 211505DEST_PATH_IMAGE003
In the single y direction, the judgment is made
Figure 650577DEST_PATH_IMAGE002
Whether or not to be at
Figure 192416DEST_PATH_IMAGE003
Left or right of; otherwise, judging
Figure 691531DEST_PATH_IMAGE002
Whether or not to be at
Figure 69554DEST_PATH_IMAGE003
Up/down/left/right;
judgment of
Figure 312316DEST_PATH_IMAGE002
Whether or not to be at
Figure 708662DEST_PATH_IMAGE003
The above method of (1) is: let x coordinate at
Figure 644257DEST_PATH_IMAGE003
The minimum circumscribed rectangle is between the left edge and the right edge, and the y coordinate is from the upper edge of the reference Chinese character image to the stroke
Figure 227686DEST_PATH_IMAGE003
The area between the upper edges is marked as a region of interest if
Figure 24871DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 541303DEST_PATH_IMAGE002
In that
Figure 382220DEST_PATH_IMAGE003
Upper part ofA method for preparing;
judgment of
Figure 718524DEST_PATH_IMAGE002
Whether or not to be at
Figure 802891DEST_PATH_IMAGE003
The following method is as follows: coordinate x on the stroke
Figure 173829DEST_PATH_IMAGE003
The minimum circumscribed rectangle is between the left edge and the right edge, and the y coordinate is from the lower edge to the stroke of the reference Chinese character image
Figure 185647DEST_PATH_IMAGE003
The area between the lower edges is marked as a region of interest if
Figure 9247DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 131924DEST_PATH_IMAGE002
In that
Figure 373680DEST_PATH_IMAGE003
Below (1);
judgment of
Figure 556400DEST_PATH_IMAGE002
Whether or not to be at
Figure 867296DEST_PATH_IMAGE003
The method to the left of (1) is: the y coordinate is arranged in the stroke
Figure 528084DEST_PATH_IMAGE003
Between the upper edge and the lower edge of the circumscribed rectangle, and the x coordinate is from the left edge to the stroke of the image
Figure 624347DEST_PATH_IMAGE003
The area between the left edges is marked as a region of interest if
Figure 712389DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 510581DEST_PATH_IMAGE002
In that
Figure 240639DEST_PATH_IMAGE003
To the left;
judgment of
Figure 440676DEST_PATH_IMAGE002
Whether or not to be at
Figure 450352DEST_PATH_IMAGE003
The right method of (3) is: the y coordinate is arranged in the stroke
Figure 735840DEST_PATH_IMAGE003
Between the upper edge and the lower edge of the circumscribed rectangle, and the x coordinate is from the right edge to the stroke of the image
Figure 4010DEST_PATH_IMAGE003
The area between the right edges is marked as a region of interest if
Figure 58554DEST_PATH_IMAGE002
Intersect with the region of interest, then
Figure 753977DEST_PATH_IMAGE002
In that
Figure 274564DEST_PATH_IMAGE003
To the right of (c).
6. The method for extracting homonymous strokes of offline handwritten Chinese characters according to claim 5, wherein in step S50, "adjusting stroke positions" includes:
pair of strokes
Figure 346425DEST_PATH_IMAGE004
According to the stroke
Figure 255475DEST_PATH_IMAGE004
Calculating a forbidden area of the stroke according to the relative position relation of the stroke and all the strokes with the adjusted positions, and calculating a feasible adjusting area according to the current position of the stroke;
the method comprises the steps of reserving a handwritten Chinese character communication area which is in a feasible adjustment area of a stroke, is not in a forbidden area of the stroke and has a stroke main direction smaller than a threshold value, taking a contour point set of the reserved Chinese character communication area under the hand as a target point set, taking the contour point set of the stroke communication area as a source point set, solving a transformation matrix from the source point set to the target point set according to an iterative nearest neighbor method, and further adjusting the position of a reference Chinese character stroke according to the obtained transformation matrix;
wherein the strokes are
Figure 387379DEST_PATH_IMAGE004
The calculation method of the forbidden zone comprises the following steps:
for the
Figure 867033DEST_PATH_IMAGE002
For all strokes with adjusted positions
Figure 742585DEST_PATH_IMAGE003
If, if
Figure 506142DEST_PATH_IMAGE002
Is out of position
Figure 808947DEST_PATH_IMAGE003
Above/below/left/right, then
Figure 25165DEST_PATH_IMAGE003
Above/below/left/right of
Figure 189561DEST_PATH_IMAGE002
The forbidden area of (a); if the stroke at the adjusted position of the stroke at the first position after the sorting in the step S50 is empty, the corresponding forbidden area is empty;
stroke (pen)
Figure 73204DEST_PATH_IMAGE004
The calculation method of the feasible adjustment area comprises the following steps:
Figure 281331DEST_PATH_IMAGE005
wherein,
Figure 250424DEST_PATH_IMAGE006
Figure 218511DEST_PATH_IMAGE007
Figure 956660DEST_PATH_IMAGE008
Figure 335689DEST_PATH_IMAGE009
respectively the coordinates, the width and the height of the upper left corner point of the stroke circumscribed rectangle,
Figure 792078DEST_PATH_IMAGE010
Figure 547544DEST_PATH_IMAGE011
respectively the width and the height of the image,
Figure 159441DEST_PATH_IMAGE012
Figure 443792DEST_PATH_IMAGE013
Figure 387477DEST_PATH_IMAGE014
Figure 946635DEST_PATH_IMAGE015
respectively the coordinates, the width and the height of the upper left corner point of the feasible adjustment area,
Figure 410108DEST_PATH_IMAGE016
the predetermined coefficient represents the size of the feasible adjustment area.
7. The method for extracting homonymous strokes of offline handwritten Chinese characters according to claim 6, wherein the distance between two main directions of the divided communicating areas is calculated by:
Figure 130939DEST_PATH_IMAGE017
Figure 296341DEST_PATH_IMAGE018
wherein,
Figure 393610DEST_PATH_IMAGE019
the distance in the main direction is indicated,
Figure 960858DEST_PATH_IMAGE020
Figure 868902DEST_PATH_IMAGE021
indicating the main direction of the two split linking areas.
8. An off-line handwritten Chinese character homonymous stroke extraction system is characterized by comprising: the device comprises an image acquisition module, an image alignment module, an area segmentation module, a feature element calculation module, a position adjustment module, a homonymy stroke connected area extraction module and an extraction result output module;
the image acquisition module is configured to acquire a handwritten Chinese character image and a reference Chinese character image; the handwritten Chinese character image is a binary image obtained by preprocessing a shot or scanned hard-tipped writing Chinese character image; the standard Chinese character image is a standard Chinese character image with known strokes and writing sequence;
the image alignment module is configured to extract a minimum circumscribed rectangle of a foreground area of the handwritten Chinese character image as a first rectangle; extracting a minimum external rectangle of the foreground region of the reference Chinese character image as a second rectangle; calculating the aspect ratio of the second rectangle, scaling to the scaling of the first rectangle, and scaling the second rectangle according to the scaling to obtain a third rectangle; constructing an image with the same size as the third rectangle, placing the foreground area of the handwritten Chinese character image in the middle of the constructed image as a first image, and replacing the original handwritten Chinese character image with the first image;
the region segmentation module is configured to extract pixel points on the outer contour of each connected region in the replaced handwritten Chinese character image and construct a first point set; extracting skeleton points of the replaced handwritten Chinese character image by combining the first point set, and constructing a second point set; extracting framework end points and framework branch points of the Chinese characters from the second point set, and extracting a framework branch set by combining the framework end points and the framework branch points to be used as a first framework branch set; extracting a framework inflection point from the first framework branch set, and re-extracting a framework branch set by combining a framework endpoint, a framework branch point and the framework inflection point to be used as a second framework branch set;
after re-extraction, traversing the first point set by combining the skeleton branch points and the skeleton inflection points, calculating corresponding point pairs of the first point set and the second point set, further traversing the second skeleton branch set, extracting pixel points of each pixel point on the skeleton branch corresponding to the pixel points in the first point set, constructing a closed contour as a partition communicating area, and calculating the minimum circumscribed rectangle and the main direction of each partition communicating area;
the skeleton endpoint is a skeleton point with only one neighbor or two adjacent neighbors in the eight neighborhoods as a skeleton point: the branch points of the framework are 0-1 or 1-0 change in eight neighborhoodsThe number of the skeleton points is more than 4 and is an even number; the frame inflection point is that the field angle formed by the frame inflection point and two pixel points which are away from the frame inflection point by a set index distance is smaller than a set field angle threshold value
Figure 521601DEST_PATH_IMAGE001
Figure 156981DEST_PATH_IMAGE001
Pixel points in the skeleton branch;
the characteristic element calculation module is configured to correct the outline of the Chinese character stroke vector in the reference Chinese character image according to the zoom ratio obtained in the image alignment module, and draw the single stroke of the Chinese character in the corrected reference Chinese character image on the image in sequence according to the stroke writing sequence; after drawing, extracting pixel points on the outer contour of each stroke communicating area, calculating the minimum circumscribed rectangle, the main direction and the relative position relation with other strokes of each stroke communicating area, and judging whether the stroke is above or below or on the left or on the right of all other strokes, if so, the stroke is taken as a boundary stroke, otherwise, the stroke is taken as an internal stroke;
the position adjusting module is configured to sort the boundary strokes and the internal strokes from big to small by the long edge of the minimum bounding rectangle of the strokes; after sorting, traversing the strokes in sequence and adjusting the stroke positions; extracting an outer contour point set of each stroke communication area of the Chinese character in the reference Chinese character image after the position is adjusted to be used as a third point set;
the homonymous stroke connected region extraction module is configured to set the gradient direction distance between each contour point in the contour point set of the segmentation connected region of the handwritten Chinese character image and the set gradient direction distance threshold value in a third contour point set with the distance between the third contour point and the main direction of the segmentation connected region being smaller than the set main direction distance threshold value, and the stroke contour point with the closest pixel distance is taken as the corresponding point of the contour point of the segmentation connected region, and the stroke category of the stroke contour point corresponding to the segmentation connected region contour point is taken as the stroke category of the segmentation connected region contour point, and the stroke category with the largest number of contour points is taken as the stroke category of the segmentation region; after classification, sequentially marking the handwritten Chinese character segmentation communicating areas with the same stroke category, merging all the segmentation communicating areas with the same category and the same connection into one, and taking the segmentation communicating area with the largest product after merging as the homonymous stroke communicating area of the stroke of the category in the handwritten Chinese character image in the reference Chinese character;
and the extraction result output module is configured to extract the image of the homonymous stroke communication area and the point set corresponding to the outline thereof as the homonymous stroke extraction result of the handwritten Chinese character image to output.
9. A storage device having stored therein a plurality of programs, wherein said programs are adapted to be loaded and executed by a processor to implement the method for extracting homonymous strokes of handwritten chinese characters as claimed in any of claims 1 to 7.
10. A processing device comprising a processor and a storage device; a processor adapted to execute various programs; a storage device adapted to store a plurality of programs; wherein the program is adapted to be loaded and executed by a processor to implement the method for extracting homonymous strokes of handwritten Chinese characters as claimed in any of claims 1 to 7.
CN202110547648.0A 2021-05-19 2021-05-19 Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters Active CN112990183B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110547648.0A CN112990183B (en) 2021-05-19 2021-05-19 Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110547648.0A CN112990183B (en) 2021-05-19 2021-05-19 Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters

Publications (2)

Publication Number Publication Date
CN112990183A true CN112990183A (en) 2021-06-18
CN112990183B CN112990183B (en) 2021-08-10

Family

ID=76337032

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110547648.0A Active CN112990183B (en) 2021-05-19 2021-05-19 Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters

Country Status (1)

Country Link
CN (1) CN112990183B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113642542A (en) * 2021-10-14 2021-11-12 中国科学院自动化研究所 Method for extracting homonymous strokes of handwritten Chinese characters based on position constraint
CN114495117A (en) * 2022-02-15 2022-05-13 甘肃政法大学 Stroke extraction method of Chinese handwritten Chinese character
CN115471849A (en) * 2022-11-03 2022-12-13 南京信息工程大学 Handwritten Chinese character image evaluation method and system
CN115841671A (en) * 2023-02-21 2023-03-24 南京信息工程大学 Calligraphy character skeleton correction method, system and storage medium
CN116580129A (en) * 2023-04-18 2023-08-11 南京信息工程大学 Method, device and storage medium for improving calligraphy character skeleton based on distance transformation

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488339A (en) * 2013-09-09 2014-01-01 北京大学 Method for generating individualized digital ink of Chinese characters
CN103927537A (en) * 2014-05-08 2014-07-16 电子科技大学 Extraction algorithm of self-adapting intersection regions of strokes of Chinese characters
CN104156721A (en) * 2014-07-31 2014-11-19 南京师范大学 Off-line Chinese character stroke extraction method based on template matching
CN104951788A (en) * 2015-07-08 2015-09-30 上海海事大学 Extracting method of strokes of separate character in calligraphy work
US20150339525A1 (en) * 2013-01-11 2015-11-26 Natural Intelligent Technologies S.R.L. Process of handwriting recognition and related apparatus
CN112597876A (en) * 2020-12-20 2021-04-02 湖北工业大学 Calligraphy Chinese character judging method based on feature fusion

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150339525A1 (en) * 2013-01-11 2015-11-26 Natural Intelligent Technologies S.R.L. Process of handwriting recognition and related apparatus
CN103488339A (en) * 2013-09-09 2014-01-01 北京大学 Method for generating individualized digital ink of Chinese characters
CN103927537A (en) * 2014-05-08 2014-07-16 电子科技大学 Extraction algorithm of self-adapting intersection regions of strokes of Chinese characters
CN104156721A (en) * 2014-07-31 2014-11-19 南京师范大学 Off-line Chinese character stroke extraction method based on template matching
CN104951788A (en) * 2015-07-08 2015-09-30 上海海事大学 Extracting method of strokes of separate character in calligraphy work
CN112597876A (en) * 2020-12-20 2021-04-02 湖北工业大学 Calligraphy Chinese character judging method based on feature fusion

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张瑞 等: "一种基于端点顺序预测的手写体笔画恢复方法", 《计算机科学》 *
朱江 等: "一种基于骨架特征顺序编码的脱机手写体数字识别方法", 《小型微型计算机系统》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113642542A (en) * 2021-10-14 2021-11-12 中国科学院自动化研究所 Method for extracting homonymous strokes of handwritten Chinese characters based on position constraint
CN114495117A (en) * 2022-02-15 2022-05-13 甘肃政法大学 Stroke extraction method of Chinese handwritten Chinese character
CN115471849A (en) * 2022-11-03 2022-12-13 南京信息工程大学 Handwritten Chinese character image evaluation method and system
CN115841671A (en) * 2023-02-21 2023-03-24 南京信息工程大学 Calligraphy character skeleton correction method, system and storage medium
CN116580129A (en) * 2023-04-18 2023-08-11 南京信息工程大学 Method, device and storage medium for improving calligraphy character skeleton based on distance transformation
CN116580129B (en) * 2023-04-18 2024-05-14 南京信息工程大学 Method, device and storage medium for improving calligraphy character skeleton based on distance transformation

Also Published As

Publication number Publication date
CN112990183B (en) 2021-08-10

Similar Documents

Publication Publication Date Title
CN112990183B (en) Method, system and device for extracting homonymous strokes of offline handwritten Chinese characters
CN111325203B (en) American license plate recognition method and system based on image correction
CN108229509B (en) Method and device for identifying object class and electronic equipment
CN110866871A (en) Text image correction method and device, computer equipment and storage medium
CN111611643B (en) Household vectorization data acquisition method and device, electronic equipment and storage medium
TWI536277B (en) Form identification method and device
CN110781885A (en) Text detection method, device, medium and electronic equipment based on image processing
WO2020125057A1 (en) Livestock quantity identification method and apparatus
CN107563379B (en) Method for positioning text in natural scene image
CN109493400A (en) Handwriting samples generation method, device, computer equipment and storage medium
US8805056B2 (en) Automatic detection and grouping of straight lines in images for personalization
CN108171127A (en) A kind of invoice automatic identifying method based on deep learning
CN114529837A (en) Building outline extraction method, system, computer equipment and storage medium
CN110176064B (en) Automatic identification method for main body object of photogrammetric generation three-dimensional model
Mousa et al. Building detection and regularisation using DSM and imagery information
CN113762269A (en) Chinese character OCR recognition method, system, medium and application based on neural network
CN111862040B (en) Portrait picture quality evaluation method, device, equipment and storage medium
CN114266860A (en) Three-dimensional face model establishing method and device, electronic equipment and storage medium
CN113223011B (en) Small sample image segmentation method based on guide network and full-connection conditional random field
CN113642542B (en) Method for extracting homonymous strokes of handwritten Chinese characters based on position constraint
CN111612045B (en) Universal method for acquiring target detection data set
CN113657377A (en) Structured recognition method for airplane ticket printing data image
CN117237681A (en) Image processing method, device and related equipment
CN109117841B (en) Scene text detection method based on stroke width transformation and convolutional neural network
CN111667429A (en) Target positioning and correcting method for inspection robot

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