Summary of the invention
The detection and the sorting technique that the purpose of this invention is to provide a kind of face contour obtain face contour accurately to overcome can't detecting that prior art exists, and therefore can't really this class technology be applied to carry out the problem that shape of face is classified.
For overcoming the problem that prior art exists, technical scheme provided by the invention is:
A kind of detection of face contour and sorting technique may further comprise the steps:
Step (one): people's face location
Adopt conventional detection to detect the position of one or more people face in the arbitrary image, and provide the rectangular area ABCD of face, wherein the coordinate to angular vertex is A (Xa, Ya), and C (Xc, Yc), the coordinate O of central point O ((Xa+Xc)/2, (Ya+Yc)/2);
Step (two): facial contour detects
The basic model of at first setting face contour is one and forms vector sealing symmetrical curve L by some spots
m, its coordinate sequence is (x
i, y
i), i=1,2 .., M; With the egg type face in common seven kinds of shapes of face as basic model.
Make (x
i, y
i) the height y of coordinate
iUniformly-spaced change, so only need determine the horizontal ordinate x of each point
iJust can determine face contour.The horizontal ordinate that defines this profile central shaft is 0, and does normalization so that face is wide, and promptly establishing face wide is 1, and the face height is determined subsequently with ratio.
With vector curve L
mThe center overlap with the central point O of face, be benchmark with the size of the rectangular area ABCD of face, be reference point with O, to L
mIt is flexible to make vector, makes L
mThe K of summit up and down
1, K
2, K
3, K
4Cut each edge of the scope ABCD of face respectively, with the initial value L of each curvilinear coordinates at this moment as face contour
0At initial profile L
0The basis on, the details at each position of face revised, comprising the horizontal ordinate position that the height of forehead, the height of chin, left and right sides cheek keep to the side most, be described below respectively,
(1) height of forehead is determined: the top of forehead generally is the junction of more shallow forehead skin and darker hair, the line of promptly gaining fame and fortune
The step of revising is:
(a) in human face region rectangle ABCD, take out the part B of the centre 1/2 in last 1/4 zone
1, represent that with shade the latter half is a forehead in this part image, the first half is a hair.
(b) determine the to gain fame and fortune detection criteria of line: with area B
1The picture element gray level C at interior each some place
XyBe divided into N interval, the gray level of adding up all picture elements, the picture element interval of searching number minimum is with the gray level thresholding G of this interval intermediate value as the line pixel of gaining fame and fortune
T
(c) in area B
1In, bottom-up, the gray level of statistics every each pixel of row in the image of getting is higher than thresholding G
TThe number of point, in certain delegation, be higher than thresholding G
TThe number of pixel and the ratio of the total number of this row pixel be higher than at 1/7 o'clock, determine the residing upright position of this row gain fame and fortune exactly line, the i.e. top of forehead.
(d) according to the upright position on forehead top, the flexible L that adjusts
0, make summit K on it
1Overlap with this upright position, revised contour curve is kept at L
1In.
If,, at this moment just keep initial value L with not satisfying the condition of above-mentioned (c) because the whole coverings of line of will gaining fame and fortune of the hair of facial image can not find in the photo at all
0Constant;
(2) determining of chin height: the upright position of chin is the junction of the dark color (illumination is weak) of light areas of chin (illumination is stronger) and neck, and determining step is:
(a) in human face region rectangle ABCD, vertically extract facial in the middle of 1/3 zone, bottom-up 1/10 the area B of getting
2
(b) to area B
2In pixel grayscale summation of each row and that delegation's correspondence of value minimum be exactly the height and position of chin.
(c) according to the upright position of chin, the flexible L that adjusts
1, revised contour curve is kept at L
2In.
(3) left and right sides cheek determines
(a) remove vertical part of middle 1/3 in the human face region rectangle ABCD, two zones are B
31And B
32
(b) be B to the zone
31And B
32The gray level of each row pixel sue for peace;
(c) search left field B
31The zone and the right side area B of W/15 width on the left side
32The zone of W/15 width on the right in the minimum value of each row pixel grayscale sum, obtain the horizontal ordinate position of left and right sides cheek.
(d) according to the horizontal level of cheek, level is stretched and is adjusted L
2, revised contour curve is kept at L
3In.
Step (three): shape of face classification
After obtaining the face contour curve, can utilize existing method to classify.
In the above-mentioned steps (two), can also comprise the revision of (4) cheek shape, its concrete steps are:
(a) Lower Half of taking out human face region ABCD separately assigns to extract the image of people's face cheek;
(b) utilize the Canny method to carry out rim detection, obtain some discontinuous contour edges at cheek;
(c) find out the longest lines l of length in the many contour edge lines of cheek, preserve the coordinate (x that is had a few of these root lines
j, y
j), j=1,2 ..., P;
(d) adopt following surface function to simulate the cheek curve data of egg type face model,
x
i=0.5sinα
i+k(sinβ
i)
0.4
y
i=0.5·i/N
K=1 wherein, i=0,1,2 ..., N, N=M/4-1 obtains one group of α and β thus.Then, in this function, only need regulate the k value and can change the cheek curvature of curve, form various cheek shape;
(e) utilize above-mentioned function, the k value changed from-0.1 to 0.1, seek with (c) in the most identical curve of lines l that finds, make on each height, the horizontal range mean square deviation minimum of this curve and lines l, these lines are cheek best edge curve;
(f), replace L according to the best edge curve
3In respective coordinates, revised contour curve is kept among the L.
In the above-mentioned steps (three), the sorting technique that is adopted is specifically: according to facial contour calculated characteristics parameter as a result, then characteristic parameter and classification thresholding are compared, the final the most representative characteristic parameter of shape of face classification that obtains: the ratio H2W_RATIO that the face height is wide with face, the ratio XB_RATIO that chin is wide and face is wide, the ratio ET_RATIO that forehead is wide and face is wide, the ratio LS_RATIO that two cheeks are wide and face is wide, chin curvature YJ_RATIO2, utilize these eigenwerts to add up, can obtain concrete classification threshold parameter, provide the Rule of judgment of a simple shape of face classification in the table below
The shape of face title |
Condition (with relation) |
Microscler face |
H2W_RATIO>=1.43 |
The egg type face |
H2W_RATIO>=1.33 H2W_RATIO<1.40 |
Round face |
H2W_RATIO<1.30 |
Side's face |
LS_RATIO+ET_RATIO>=1.51 ET_RATIO>0.7 LS_RATIO>0.76 |
Heart-shaped face |
XB_RATIO<0.48 LS_RATIO<=0.69 ET_RATIO>=0.75 YJ_RATIO2<-0.03 |
The ocean pears |
XB_RATIO>=0.55 LS_RATIO>=0.80 ET_RATIO<=0.67 LS_RATIO-ET_RATIO>=0.13 LS_RATIO-ET_RATIO>0.25 |
Bore the shape face |
XB_RATIO<0.52 LS_RATIO<0.75 ET_RATIO<0.7 LS_RATIO+ET_RATIO<=1.40 LS_RATIO+ET_RATIO<1.34 |
When certain shape of face did not satisfy any one condition combination, he may be between certain two kinds of shape of face.
In the above-mentioned steps (), described face area detection method is the Harr method
In the above-mentioned steps (two), symmetrical curve L
mCoordinate sequence be (x
i, y
i), i=1,2 ..., M, M are big more, and precision is high more.
Compared with prior art, advantage of the present invention is:
The present invention proposes a kind of method that detects people's face external form profile in the arbitrary image, and this method is at first oriented the position of people's face from image, determine complete, continuous, a smooth face contour then, at last the type of people's face external form profile is classified.The present invention can provide the automated graphics processing means of effect for all conglomeraties such as image design, beauty treatment, hairdressing, clothes, jewellery, cosmetic, amusements, for various application industries provide robotization, objectively technical support.Simultaneously, also can help broad masses to carry out self-shape of face and judge, carry out the self-image design according to rule.
Embodiment:
Below in conjunction with accompanying drawing the present invention is done and to explain.
The objective of the invention is from piece image, to detect the position of people's face, obtain its face's external form profile, finally provide classification results.Referring to Fig. 4, implementation step was divided into for three steps, and promptly people's face location, facial contour detect and the shape of face classification.
Step (one): people's face location,
Adopt existing Harr detection method can effectively detect the position of one or more people face in the arbitrary image, and provide the coordinate on the summit, rectangular area of face.In the narration of back, we are that example is explained with a width of cloth facial image only.When having more than a width of cloth people face in the original graph photo, this method can detect the position and the scope of every width of cloth people face one by one.
Referring to Fig. 1, the coordinate that defines four angles of detected human face region is respectively A, B, and C, D, wherein the coordinate of A is that (Xa, Ya), the coordinate of C is that (Xc, Yc), central point is O ((Xa+Xc)/2, (Ya+Yc)/2).
Step (two): facial contour detects, and process is referring to Fig. 5, comprising in the coordinate of face area respectively to the height of forehead, the height of chin, the horizontal ordinate position that left and right sides cheek keeps to the side most, the cheek shape is revised the synthetic final face contour in back.
Behind the coordinate that obtains face area, the Flame Image Process work of seeking face contour just is confined near this zone.For the face contour that makes acquisition is smooth, continuous, as a to seal curve, we adopt following method:
The basic model of at first setting face contour is for being made of vector sealing symmetrical curve L some spots
m, its coordinate sequence is (x
i, y
i), i=1,2 .., M, the egg type face is as basic model among employing Fig. 3, and Fig. 7 provides the synoptic diagram on this shape of face and each summit thereof.
It is symmetrical to provide one of employing in the present embodiment, constitutes the profile of egg type face as basic model by M=72 point.Make (x
i, y
i) height of coordinate uniformly-spaced changes, and so only need determine that the horizontal ordinate of each point just can be determined face contour.The horizontal ordinate that defines this profile central shaft is 0, and does normalization so that face is wide, and promptly face is wide is 1, and it is fixed that height comes with ratio.Provide the coordinate following (left-right symmetric) of half 36 point in one group of profile that the present invention adopts below, the order of horizontal ordinate is from the chin to the forehead:
x
i=[0.0000 0.2501 0.3025 0.3549 0.3889 0.4153 0.4346 0.4524 0.4672
0.4759 0.4850 0.4907 0.4938 0.5000 0.4999 0.4996 0.4990 0.4979
0.4958 0.4914 0.4826 0.4776 0.4675 0.4557 0.4447 0.4308 0.4157
0.3939 0.3709 0.3459 0.3168 0.2792 0.2376 0.1834 0.1459 0.0000]
y
i=H/35·(i-1),i=1,2,...,36
H=Yc-Ya
W=Xc-Xa
Because the approximate range ABCD of our known face therefore can be with vector curve L
mThe center overlap with the central point O of face, be benchmark with face's range size, be reference point with O, to L
mIt is flexible to make vector, makes L
mThe K of summit up and down
1, K
2, K
3, K
4Stick each edge of the scope ABCD of face respectively, with the initial value L of each curvilinear coordinates at this moment as face contour
0
At initial profile L
0The basis on, need revise the details at each position of face, comprising the horizontal ordinate position that the height of forehead, the height of chin, left and right sides cheek keep to the side most, cheek shape etc.The method of determining these several parameters can obtain by the analysis to image gray levels.We are after passing through observation and statistical experiment to a large amount of photos, obtained the highly effective method of a cover, in Fig. 8, provide the implementation step flow process, positioning result according to people's face, can roughly obtain people's face scope apex coordinate, accurately locate forehead height, chin height again, the horizontal vertex position of left and right sides cheek according to this, the cheek curve, finally synthetic face contour.Concrete grammar describes in detail below.In definite process of this Several Parameters, initial value L originally
0Can adjust according to the revision result, the gained result will approach true face contour L gradually.
The height of forehead is determined
The top of forehead generally is the junction of more shallow forehead skin and darker hair, the line of promptly gaining fame and fortune.Find the upright position of the line of gaining fame and fortune, just can be used for further revising face contour initial value L
0The exact position on topmost summit.
Determine that the gain fame and fortune where the shoe pinches of line of forehead is, be not every photo all outside the clearly naked leakage of the line of gaining fame and fortune, sometimes be a part, sometimes just almost can't see.Blocking of hair becomes main difficulty.Take following method for this reason:
At first, we have had initial value L
0The position on topmost summit.Line just can not find at all if gain fame and fortune, and we just do not revise initial value L
0If some spills, we just might detect the line of gaining fame and fortune so, revise initial value L
0
The method of judging the line of gaining fame and fortune is:
(a) as shown in Figure 7, in human face region rectangle ABCD, take out the area B of the centre 1/2 in last 1/4 zone
1, represent that with shade the latter half should be forehead in this part image, the first half should be hair.
(b) determine the to gain fame and fortune detection criteria of line.With area B
1The picture element gray level G at interior each some place
XyBe divided into N interval (for example, N=10).In this part, the yellow corresponding gray scale level pixel of the black of hair and forehead is should proportion higher, and the gray level picture element at the line place of gaining fame and fortune is compared and occupied the minority.Therefore, we add up the gray level of all picture elements, seek the picture element interval of number minimum, with the gray level thresholding G of this interval intermediate value as the line pixel of gaining fame and fortune
T
(c) in area B
1In, bottom-up, the gray level of statistics every each pixel of row in the image of getting is higher than thresholding G
TThe number of point.In certain delegation, be higher than thresholding G
TThe number of pixel and the ratio of the total number of this row pixel be higher than (empirical value) at 1/7 o'clock, think the residing upright position of this row gain fame and fortune exactly line, the i.e. top of forehead.
(d) according to the upright position on forehead top, the flexible L that adjusts
0, revised contour curve is kept at L
1In.
Determining of chin height
Referring to Fig. 1, the upright position of chin is the junction of the dark color (illumination is weak) of light areas of chin (illumination is stronger) and neck.Concrete determination methods is:
(a) referring to Fig. 7, in face area, vertically extract facial in the middle of 1/3 zone, bottom-up 1/10 the area B of getting
2
(b) to area B
2In pixel grayscale summation of each row and that delegation's correspondence of value minimum be exactly the height and position of chin.
(c) according to the upright position of chin, the flexible L that adjusts
1, revised contour curve is kept at L
2In.
Determining of left and right sides cheek
The comparison difficulty is determined in the influence of determining to be subjected to ear, hair, irradiate light, contextual factor of cheek horizontal ordinate position, the left and right sides.Concrete determination methods is:
(a) as shown in Figure 8, remove vertically middle 1/3rd part of people's face scope, do like this and can remove the influence of ear part.Two zones are B
31And B
32
(b) be B to the zone
31And B
32The gray level of each row pixel sue for peace;
(c) according to the features of shape of people's face, in most photos, search for left field B
31The zone and the right side area B of W/15 width on the left side
32The zone of W/15 width on the right in the minimum value of each row pixel grayscale sum, just can obtain the horizontal ordinate position of left and right sides cheek.
(d) according to the horizontal level of cheek, level is stretched and is adjusted L
2, revised contour curve is kept at L
3In.
Because above employing always is a basic shape of face model, just carry out the fat or thin variation of height on this basis simply, do that so most of shape of face can be met the demands substantially.
But as square face, heart-shaped face etc., just can not well approach some.At this moment we need readjust cheek (curve of whole face contour bottom 1/2).
The revision of cheek shape
Concrete implementation step is as follows:
(a) image of extraction people face cheek, as shown in Figure 1, we take out the latter half of regional ABCD separately.
(b) utilize the Canny method to carry out rim detection.We can obtain some desultory edges like this.Zone as shown in phantom in Figure 2 has the lines that some lines are cheek profiles here, and many lines then are not.
(c) find out the longest lines l of length in all multi-lines of cheek, these root lines generally are exactly facial contour, preserve the coordinate (x that is had a few of these root lines
j, x
j), j=1,2 ..., P.
(d) adopt following surface function to simulate the cheek curve data of egg type face model,
x
i=0.5sinα
i+k(sinβ
i)
0.4
y
i=0.5·i/N
K=1 wherein, i=0,1,2 ..., N, N=M/4-1 obtains one group of α and β thus.Then, in this function, only need regulate the k value and can change the cheek curvature of curve, form various cheek shape.For example, when M=72, we can obtain
α=[1.5708 1.6297 1.6887 1.7482 1.8083 1.8693 1.9315 1.9952 2.0608
2.1287 2.1997 2.2745 2.3545 2.4414 2.5384 2.6516 2.7969 3.14159]
β=[0.0000 0.0057 0.0201 0.0435 0.0763 0.1188 0.1718 0.2361 0.3131
0.4042 0.5119 0.6390 0.7906 0.9736 1.2002 1.4947 1.9200 3.14159]
The cheek curve is the first half of face contour curve L, and left-right symmetric gets final product Yi Bian calculate, 18 points totally.
(d) utilize above-mentioned function, the k value is changed from-0.1 to 0.1, seek and the most identical curve of lines l, make on each height, the horizontal range mean square deviation minimum of this curve and lines l, these lines are cheek best edge curve.
(e), replace L according to the best edge curve
3In respective coordinates, revised contour curve is kept among the L.
(f) face contour calculates and finishes.
Step (three); The shape of face classification
Referring to Fig. 9.At first, then characteristic parameter and classification thresholding are compared, finally obtain the shape of face classification according to facial contour calculated characteristics parameter as a result.
In order to distinguish different shapes of face, determined the most representative following characteristic parameter: the ratio that the face height is wide with face, the wide ratio wide of chin, the wide ratio wide of forehead, the wide ratio wide of two cheeks, chin curvature with face with face with face.By these parameter individual events are added up, carry out the thresholding setting then and compare, just can realize every width of cloth shape of face is classified, sorting parameter is as follows:
(a) the face height ratio H2W_RATIO wide with face
(b) the wide ratio XB_RATIO wide of chin with face
(c) the wide ratio ET_RATIO wide of forehead with face
(d) the wide ratio LS_RATIO wide of two cheeks with face
(e) chin curvature YJ_RATIO2
Utilize these eigenwerts to add up, can obtain concrete classification threshold parameter, provide the Rule of judgment of a simple shape of face classification in the table below.
The shape of face title |
Condition (with relation) |
Microscler face |
H2W_RATIO>=1.43 |
The egg type face |
H2W_RATIO>=1.33 H2W_RATIO<1.40 |
Round face |
H2W_RATIO<1.30 |
Side's face |
LS_RATIO+ET_RATIO>=1.51 ET_RATIO>0.7 LS_RATIO>0.76 |
Heart-shaped face |
XB_RATIO<0.48 LS_RATIO<=0.69 ET_RATIO>=0.75 YJ_RATIO2<-0.03 |
The ocean pears |
XB_RATIO>=0.55 LS_RATIO>=0.80 |
|
ET_RATIO<=0.68 LS_RATIO-ET_RATIO>=0.13 LS_RATIO-ET_RATIO>0.25 |
Bore the shape face |
XB_RATIO<0.52 LS_RATIO<0.75 ET_RATIO<0.7 LS_RATIO+ET_RATIO<=1.40 LS_RATIO+ET_RATIO<1.34 |
When certain shape of face did not satisfy any one condition combination, he may be between certain two kinds of shape of face.This situation can be handled according to user's demand.
After automatic face contour detection was finished, the user can also revise voluntarily among a small circle, so that reach optimum efficiency.
With the people's face among Figure 10 is example, further complete description each step of the present invention.
At first, the people's face in the image is positioned.The Harr detection method can utilize the people's face mapping function among the computer vision storehouse OpenCV that increases income of Intel to realize, concrete function name is cvHaarDetectObjects.Utilize this function just can obtain position, scope and the number of people's face in image.The use of relevant this function is following description in the C language.
cvHaarDetectObjects(m_plmg,cascade,storage,1.2,2,CV_HAAR_DO_CANNY_PRUNING,cvSize(0,0));
Positioning result is shown in Figure 10 (a).At this moment the frame of a rectangle has been determined people's face scope roughly, and in making that this scope necessarily is included in everyone face part;
The second, be foundation with the shape of face position, the model that adopts the egg shape face is as initial profile, and profile variation at this moment is bigger, regardless of different kinds of, still with the pressing close to degree and all can not satisfy request for utilization of true shape of face.
The 3rd, the forehead position of shape of face part is adjusted.According to the method that we propose, the position of forehead is effectively adjusted, and, can see at this moment that the position of forehead is well adjusted referring to the forehead position of Figure 10 (b), and basic and physical location is coincide.
The 4th, the chin position of shape of face part is adjusted, referring to Figure 10 (c), after the chin position is accurately located, extremely press close to actual position.
The 5th, the cheek position is adjusted, referring to Figure 10 (d), at this moment the position of cheek coincide with actual position.
The 6th, the cheek curve is calculated, referring to Figure 10 (e), position and top basically identical are because original just suitable substantially.
The 7th, carry out the shape of face classification.According to definition, the result of each characteristic parameter is as follows:
(a) the face height ratio H2W_RATIO=1.45 wide with face
(b) the wide ratio XB_RATIO=0.51 wide of chin with face
(c) the wide ratio ET_RATIO=0.70 wide of forehead with face
(d) the wide ratio LS_RATIO=0.68 wide of two cheeks with face
(e) chin curvature YJ_RATIO2=0.01
According to above-mentioned judgment condition, this shape of face is long shape of face, extremely kiss with our visual result and.