Four. Entity recognition
The element is the smallest element that makes up the graph, and the element recognition is the basis of the graph recognition. Based on the segmentation of the stroke, the separated elements are further identified.
1. Line recognition
The characteristics of a line are linearized, assuming that the sampled points collected are P (xi,yi) and I=1,2,3...N.
There are three ways to determine linearization:
1) The distance of the head position of the figure, and the ratio of the accumulated chord length of the sampling point sequence, is greater than a given threshold value
2) The number of points from the sample point to the first point in the element that are connected to a line that exceeds the threshold, whether within the allowable range
3) Whether the external rectangle aspect ratio of the entity is less than a certain threshold value
2. Linear fitting (least squares)
The linear fitting adopts the least square method, and the Y=f (x) =A+BX is the fitting linear equation.
D is the distance from the point sequence s={p (Xi,yi) |I=0,1,2...N} to the fitting line.
When the squared deviations are the smallest, the fitting is the highest.
A and B values are brought into the linear equation y=a+bx, that is, the regression linear equations are obtained.
2. Extracting geometric feature parameters
Maximum inner triangular quadrilateral of convex-clad rectangle
3. Example of first feature ratio
Graphic type |
First characteristic ratio |
Round |
Convex hull circumference square/convex bag area |
Line |
Bounding rectangle height/bounding rectangle width |
Rectangular |
Convex hull area/circumscribed rectangular area |
Elliptic |
Maximum internal cutting area/convex hull area |
Triangle |
Maximum inner triangular area/convex hull area |
Rhombic |
Maximum inner Triangle area/maximum inner tangent quadrilateral area |
Trapezoidal |
Maximum inner cut quadrilateral area/bounding rectangle area |
Pentagram |
Maximum inner triangular area/bounding rectangle area |
Five. Feature Point selection
After identifying what kind of graphics, the corresponding feature points, the selection of feature points directly affect the final drawing of the good or bad. The main reference is 2 parameters for drawing speed and curvature.
Calculation formula for curvature: k= φ/S
Where: φ represents the tangent inclination change value, s represents the arc length of the curve. Φ=atan (y/x) as the angle of the curve at point p change value, from the definition of curvature can be seen, the tangent dip angle changes the same situation, the smaller the distance between two points, the greater the curvature. This feature is ideal for judging feature points, because the distance between the sample points at the feature points in the stroke is small and the angle varies greatly.
However, when the stroke contains more noise, the method calculates the curvature at the noise point, and the true characteristic point curvature is larger, which can not distinguish between the real feature point and the characteristic point caused by the noise. Use the ODR (orthogonal distance regression) method to find the tangent direction of a curve at a point. The method is to find a straight line through the line fitting, so that the points in the neighborhood of the point to the distance of the line and the smallest, and then take the line and the x-axis angle as the tangent direction of the point. For a point p on a curve.
The ODR method asks for the tangent direction:
Then, the characteristic points are obtained by means of mean filtering method. To draw.
Hand-drawn geometry recognition (bottom)