Summary of the invention
Technical matters to be solved by this invention is: a kind of hair styling method based on eyes location and shape of face identification is provided, and coupling hair image and facial image that the method can be automatic and easy, and the hair image is carried out Change In Design.
The technical solution adopted in the present invention is: a kind of hair styling method based on eyes location and shape of face identification comprises the following steps successively:
S1) face image acquisition module input face image;
S2) the face image locating module carries out eyes to face image and automatically locates, and face mask is identified automatically, and eyes anchor point and the face mask line that identifies is presented on face image, in the situation that identification is not accurate enough, manually adjusts; Then calculate shape and the size parameter of face, finally obtain the locating information of face image;
S3) hair style is selected to select hair image in database with matching module, and obtains its positional parameter (the hair image refers to only comprise hair information, does not comprise the image of facial information);
S4) hair style is selected the positional parameter that carries according to the hair image with matching module and the locating information of face image, and Auto-matching face image and hair image if mate not accurate enoughly, are manually adjusted;
S5) hair style design and processing module are carried out the hair style design processing to the hair image.
Described method, the detailed process of step S2 comprises:
S21) eyes of face image are located automatically, show detected eyes anchor point on face image, if identification is inaccurate, the operator makes the eyes anchor point more accurate by manual operations;
S22) calculate left eye centre of form E according to anchor point
1fTo right eye centre of form E
2fDistance C
f, the left eye centre of form is to the distance A in image Far Left sideline
f, the left eye centre of form apart from the character facial picture topmost the sideline apart from B
f
S23) profile and face's eyebrow, the lip coordinate of face image are detected automatically, identify the face mask line of face image, and face's eyebrow coordinate position in face image, face's lip coordinate position in face image, and be presented on face image; If identification is inaccurate, the operator manually adjusts;
S24) calculate the width W of face image eyebrow place face according to face mask line and face's eyebrow, lip position coordinates
1f, face image lip place face width W
2f, the width W of face's the widest part in face image
f, the height L of face in face image
fAccording to face mask line and the face's width and the height parameter W that calculate
1f, W
2f, W
f, L
f, extrapolate the affiliated shape of face of this face image.
Described method, the method for extrapolating the affiliated shape of face of this face image in S24 is:
1. calculate the length breadth ratio L of face
f/ W
fIf, L
f/ W
fValue greater than 3/2, this shape of face with this character facial image is labeled as the elongated face; If L
f/ W
fValue less than 4/3, entered for the 2. step; If L
f/ W
fValue between 4/3 and 3/2, entered for the 3. step;
2. at L
f/ W
fValue less than 4/3 o'clock, calculate near the degree of crook of the face mask line face's the widest part in face image, concrete computing method are first to draw the horizontal line that the both ends, face left and right of face's the widest part connect, and are all L in the distance up and down of this horizontal line
fTwo parallel lines are drawn in/7 place, obtain the intersection point of these two parallel lines and face mask line, all get the intersection point on the left side.Draw at last the angle of the tangent line of these two points, if the value of this angle just is labeled as square face with the shape of face of face in the hair style image than 25 ° little, if the value of this angle just is labeled as round face with the shape of face of this character facial image unlike 25 ° little;
3. at L
f/ W
fValue between 4/3 and 3/2 time, W relatively
1f, W
2f, W
fBetween value, if W
2f/ W
1fValue less than 0.7, the shape of face of this character facial image is labeled as the inverted triangle face; If W
1f/ W
2fValue less than 0.7, it is labeled as foreign pears face; If 0.7<W
1f/ W
2f<1.43, and W
1f/ W
f, W
2f/ W
fAll more than or equal to 0.9, just it is labeled as the egg shape face, if W
1f/ W
f, W
2f/ W
fAll less than 0.9, just it is labeled as the diamond pattern face.
Described method, step S3 specifically comprises:
S31) input contains the hair style image of facial information;
S32) proofread and correct the hair style image, make people's face center line perpendicular to the horizontal edge of image;
S33) eyes in the face of hair style image are located automatically, identify the coordinate points E of the right and left eyes centre of form of face in the hair style image
1h, E
2h(the hair style image refers to both comprise hair information, also comprises the image of facial information);
S34) according to coordinate points E
1h, E
2h, calculate the left eye centre of form apart from the distance A in hair style picture Far Left sideline
h, and the left eye centre of form apart from the hair style picture topmost the sideline apart from B
h, the distance C in the hair style picture between the eyes centre of form
h
S35) face mask of hair style image detected automatically, identify the face mask line of hair style image, and face's eyebrow coordinate position in the hair style image, face's lip coordinate position in the hair style image; If identify not accurate enoughly, carry out manual setting;
S36) according to face's eyebrow coordinate position in the hair style image, and the face mask line computation of the hair style image that identifies goes out the width W of face's eyebrow in hair style image place face
1hAccording to face's lip coordinate position in the hair style image, and the face mask line computation of the hair style image that identifies goes out the width W of face's lip in hair style image place face
2hScan the face mask line of hair style image, calculate the width W of face's the widest part in the hair style image
hThe forehead peak of the face mask line of the hair style image that scanning recognition goes out and lower jaw minimum point calculate the height L of face of character facial image
hAccording to face mask line and these width that calculates and height parameter W
1h, W
2h, W
h, L
h, extrapolate the shape of face of face in the hair style image;
S37) facial information in removal hair style image, obtain to have kept parameter information A
h, B
h, C
h, W
1h, W
2h, L
hThe hair image, and the shape of face under this hair style image is labeled as the resulting shape of face of previous step.
Described method, step S36 calculates that the method for face's shape of face is:
1. calculate the length breadth ratio L of face
h/ W
hIf, L
h/ W
hValue greater than 3/2, the shape of face with this hair style image is labeled as the elongated face; If L
h/ W
hValue less than 4/3, entered for the 2. step; If L
h/ W
hValue between 4/3 and 3/2, entered for the 3. step;
2. at L
h/ W
hValue less than 4/3 o'clock, calculate near the degree of crook of the face mask line face's the widest part in the hair style image, concrete account form is exactly first to draw the horizontal line that the both ends, face left and right of face's the widest part connect, and is all L in the distance up and down of this horizontal line
hTwo parallel lines are drawn in/7 place, obtain the intersection point of these two parallel lines and face mask line, all get the intersection point on the left side.Draw at last the angle of the tangent line of these two intersection points, if the value of this angle just is labeled as square face with the shape of face of face in the hair style image than 25 ° little, if the value of this angle just is labeled as round face with the shape of face of this hair style image unlike 25 ° little;
3. at L
h/ W
hValue between 4/3 and 3/2 time, W relatively
1h, W
2h, W
hBetween value, if W
2h/ W
1hValue less than 0.7, the shape of face with this hair style image is labeled as the inverted triangle face; If W
1h/ W
2hValue less than 0.7, it is labeled as foreign pears face; If 0.7<W
1h/ W
2h<1.43, and W
1h/ W
h, W
2f/ W
hAll more than or equal to 0.9, just it is labeled as the egg shape face, if W
1h/ W
h, W
2h/ W
hAll less than 0.9, just it is labeled as the diamond pattern face.
Described method, step S4 specifically comprises:
S41) face of contrast face image and hair style image height L
f, L
h, the left eye centre of form is to the distance C of the right eye centre of form
f, C
h, distinguish in the horizontal and vertically upper convergent-divergent hair image according to their ratio; And the left eye centre of form of hair style image is to the distance A in image Far Left sideline
h, the left eye centre of form apart from the character facial picture topmost the sideline apart from B
h, face image eyebrow place face width W
1h, face image lip place face width information W
2hAlso make equal proportion thereupon and change, obtain respectively new corresponding parameter A
h', B
h', W
1h', W
2h';
S42) according to the distance A of the left eye centre of form in the hair style image after face image and convergent-divergent to image Far Left sideline
f, A
h', the left eye centre of form apart from the character facial picture topmost the sideline apart from B
f, B
h', to the position that is complementary with face image, namely in two figure, the corresponding right and left eyes centre of form overlaps, and completes preliminary Auto-matching the hair style image translation;
S43) if the shape of face that the hair style image is fit to and character facial image shape of face are mated, finish the Auto-matching process of S4; If do not mate, contrast the width W of face image eyebrow place face
1f, W
1h', corresponding width information W in the width of lip place face and hair image
2f, W
2h', draw respectively two groups of stand outs
S44) according to two groups of stand outs
With the method for smearing processing, inside contracting or extending out to a certain degree carried out in hair image appointed area; If smear the respond well of processing, the hair style coupling is very accurate, finishes the matching process of S4, otherwise enters next step;
S45) if mate not accurate enoughly, the operator adjusts size and the position of hair image by manual operations, until perfect matching.
Described method in step S23 or S35, is used the human face characteristic positioning method based on active shape model, and face mask line, eyebrow coordinate position and lip coordinate position are detected.
Described method, the method for the hair image being carried out the hair style design processing comprises that hair style pruning, hair style adjustment, hair style are had hair dyed, manually improved looks or light is played up.
Described method, it also comprises step at last: the S6) plane/video teaching of plane/video teaching module by associating with every money hair image provides the study design cycle of moulding corresponding to hair image.And set up special advertisement position in plane/video teaching, and the every money hair style of design material used is mapped with relevant product, realize the accurate advertisement delivery.
Advantage of the present invention: the present invention is in the hair styling method based on eyes location and shape of face identification, suitable face image to input, automatically detect the eyes centre of form coordinate in the face image of inputting, and face mask, then according to the hair image with the comparison of parameter, horizontal or vertical zoomed image, the position of mating automatically hair image and face image.Automaticity is high, does not need operator's handwork, just can simply carry out this synthetic.
And the present invention is after the profile identification to face image, its shape of face is identified, and in the pre-service of hair image, its shape of face that is fit to is sorted out, so just can automatically list the hair image that can naturally mate this face image, avoided the operator to go manual searching.Even if the shape of face that selected hair image is fit to and the shape of face of face image are not mated, also can be after the operator have selected this hair image, to the hair image stretch automatically, deformation process, make the coupling face image that it finally also can nature.
After hair image in the database of completing character facial image and selection synthetic, can also the dyeing of hair image be pruned, and the processing of stretching, deformation, until reach satisfied final effect.
In a word, the present invention locates automatically by eyes and shape of face is identified automatically, hair image in automatic and easy coupling face image and database, and also the coupling of face image and hair image is not lost naturality.After coupling, can also prune by hair style, the hair dyeing of hair style adjustment, hair style, manually beauty treatment or light are played up, and revise design hair image.Client before haircut, just can be before display terminal the satisfied hair style design effect of preview oneself, and and the hairdresser come together to determine whole design cycle.The present invention is as a kind of desktop computer that is applicable to, and the hair styling method based on eyes location and shape of face identification of notebook computer and intelligent movable platform is widely used in hair style design industry.
Embodiment
During practical application of the present invention, operate on desktop computer, notebook computer or intelligent movable platform.As shown in architecture Fig. 1, the present invention includes face image acquisition module, face image locating module, hair style selection and matching module, hair style design and the processing module, the plane/video teaching module that are connected successively.
The present invention mainly completes the hair style design based on eyes location and shape of face identification as follows: the input face image; Computing machine carries out eyes to face image and automatically locates, automatic identification with face mask, the eyes anchor point and the face mask line that identify are presented on face image, in the situation that identification is not accurate enough, can manually adjust anchor point and face mask line until accurately; Select hair image in database; The positional parameter that carries according to the hair image and the locating information of face image, Auto-matching face image and hair image also can be by manually adjusting, and the hair image and the face image that make reach the perfect matching effect; After coupling was completed, synthetic images carried out hair style pruning, hair style adjustment, hair style hair dyeing, manually beauty treatment or the light processing of playing up, and reached the hair style design effect of Customer Satisfaction.
Concrete scheme of the present invention is as follows:
S1) character facial image input.
S2) eyes of face image are located automatically, show detected eyes anchor point on face image, if identification is inaccurate, the operator can make the eyes anchor point more accurate by manual operations.
S3) calculate the left eye centre of form according to anchor point and arrive the image distance in sideline topmost to the distance of the right eye centre of form, distance, the left eye centre of form that the left eye centre of form arrives image Far Left sideline.
S4) profile and face's eyebrow, the lip coordinate of face image are detected automatically, show detected face mask line and face's eyebrow, lip position coordinates on face image.If identification is inaccurate, the operator can manually adjust the face mask line of the character facial image that identifies, and allows the face mask line mate more exactly the face mask of personage's face image; In like manner, also can adjust as required face's eyebrow position coordinates and the lip position coordinates of the character facial image that identifies.
S5) calculate the height of face in the width, face image of face's the widest part in the width, face image of width, the face image lip place face of face image eyebrow place face according to face mask line and face's eyebrow, lip position coordinates.According to face mask line and the face's width and the height parameter that calculate, extrapolate the affiliated shape of face of this face image.For eyes to face image are accurately located automatically, and detect the outline line of character facial, the character facial image of input is positive and face image do not covered face by hair preferably.
S6) anticipated in selection hair style storehouse, the hair image of containing parameter information (the hair image refers to only comprise hair information, does not comprise the image of facial information), the hair image of suitable this face image of the preferential displaying of hair style this moment storehouse meeting is for you to choose.Wherein, similar to preprocessing process and the face image of all hair images, all obtain each positional parameter of their correspondence, its key step comprises:
A) input contains the hair style image of facial information.(the hair style picture refers to both comprise hair information, also comprises the image of facial information)
B) proofread and correct the hair style image, make people's face center line perpendicular to the horizontal edge of picture.
C) the hair style picture that contains facial information is carried out eyes and automatically locate, and the outline line that automatically detects face.In addition, the professional can adjust locating information by manual operations, makes more accurate that in eyes anchor point and face mask line and hair style picture, face mates.
D) calculate the width of face's the widest part in the width, hair style picture of lip in the width, hair style picture of the position, the left eye centre of form of face area eyebrow place face in the distance of the right eye centre of form, hair style picture place face and the height of face according to anchor point and outline line.
E) facial information in removal hair style image, obtain the hair image that comprises locator data.
S7) according to the right and left eyes centre of form co-ordinate position information of the character facial image that calculates, width information between the eyes centre of form, the width of face's eyebrow place face in the character facial image, the width of face's lip place face in the character facial image, face's height in the character facial image, with in the hair image with the contrast of corresponding information, coupling personage's face image and hair image.
S8) height of contrast face image and hair image, the left eye centre of form be to the distance of the right eye centre of form, according to they ratio respectively in the horizontal and vertically upper convergent-divergent hair image.And, the left eye centre of form of hair image to the distance in image Far Left sideline, the left eye centre of form to image topmost the information such as width of the width of the distance in sideline, face image eyebrow place face, face image lip place face also make equal proportion thereupon and change.
S9) arrive the distance in sideline, image the top to distance, the left eye centre of form in image Far Left sideline according to the left eye centre of form in the hair image after face image and convergent-divergent, to the position that is complementary with face image, namely in two figure, the corresponding right and left eyes centre of form overlaps the hair image translation.Complete preliminary Auto-matching.
S10) if the shape of face that the hair image is fit to and character facial image shape of face are mated, at this moment the Auto-matching process is completed.If do not mate, contrast corresponding width information in the width of width, lip place face of face image eyebrow place face and hair image, draw two groups of stand outs.
S11) two groups of stand outs that draw according to S10 step to the appointed area liquefaction of hair image, make that hair is local, and inside contracting or extending out to a certain degree occur with the liquefaction algorithm, and wherein, degree is determined by above-mentioned stand out.So far the Auto-matching process is completed.
S12) if mate not accurate enoughly, the operator also can adjust by manual operations size and the position of hair image, or extends out or inside contract the hair image with the liquefaction algorithm at regional area, makes hair image and face image perfect matching.
S13) after the coupling of the hair image in the database of the character facial image of completing input and selection, the image after the method that can select to provide in software is completed coupling further designs processing.These methods comprise: hair style pruning, hair style adjustment, hair style are had hair dyed, manually improve looks or light is played up.
Below, with reference to accompanying drawing, explain the present invention.
The architecture of the hair styling method that is based on eyes location and shape of face identification that Fig. 1 represents; What Fig. 2 represented is synthetic face image and hair integral image coupling process flow diagram; What Fig. 3 represented is the detailed process of computing machine Auto-matching face image and hair image.Whole step comprises successively:
(1) character facial image of input.The character facial image of input is positive and face image do not covered face by hair preferably.As shown in Figure 4 in example
(2) computing machine is located automatically to the eyes of character facial image, identifies the coordinate points E of the eyes centre of form of character facial image
1f, E
2fIf identification is inaccurate, the operator can manually adjust E
1f, E
2f, make the location of the left eye centre of form and the right eye centre of form more accurate.
(3) according to coordinate points E
1f, E
2f, calculate the left eye centre of form apart from the distance A in character facial picture Far Left sideline
f, and the left eye centre of form apart from the character facial image topmost the sideline apart from B
f, the distance C between the eyes centre of form
f, as shown in Figure 5 in example.
(4) computing machine detects automatically to the face mask of character facial image, the face mask line of the character facial image that identifies, and face's eyebrow coordinate position in the character facial image, face's lip coordinate position in the character facial image.If identification is inaccurate, the operator can manually adjust the face mask line of the character facial image that identifies, and allows the face mask line mate more accurately the face mask of personage's face image; In like manner, also can adjust as required face's eyebrow position coordinates of the character facial image that identifies, and face's lip position coordinates of character facial image.Can use the human face characteristic positioning method based on active shape model (ASM), face mask and face feature are detected automatically.Active shape model is a kind of image search method based on statistical model, is proposed the earliest by people such as T.F.Cootes.ASM describes the shape of target with some distributed model (Point Distribution Model, PDM).It is by carrying out statistical modeling to having certain representational same class target image.He is similar to active contour model theoretically, namely defines an energy function, by the adjustment model parameter, energy function is minimized.Utilize priori to carry out model preliminary examination in the target search process and locate, then utilize local texture model to carry out the unique point search, and utilize shape that shape rationally is similar to adjust.
(5) according to face's eyebrow coordinate position in the character facial image, and the face mask line computation of the character facial image that identifies goes out the width W of face's eyebrow in character facial image place face
1fAccording to face's lip coordinate position in the character facial image, and the face mask line computation of the character facial image that identifies goes out the width W of face's lip in character facial image place face
2fScan the face mask line of character facial image, calculate the width W of face's the widest part in the character facial image
fThe forehead peak of the face mask line of the character facial image that goes out according to scanning recognition and the height L of the face that the lower jaw minimum point calculates the character facial image
f, concrete as shown in Figure 6 in example.Extrapolate shape of face under this character facial image according to the outline line of character facial image and the face's width that calculates and height parameter, its detailed step comprises:
1. calculate the length breadth ratio L of face
f/ W
fIf, L
f/ W
fValue greater than 3/2, this shape of face with this character facial image is labeled as the elongated face; If L
h/ W
hValue less than 4/3, entered for the 2. step; If L
h/ W
hValue between 4/3 and 3/2, entered for the 3. step;
2. at L
f/ W
fValue less than 4/3 o'clock, calculate near the degree of crook of the face mask line face's the widest part in face image, concrete account form is exactly first to draw the horizontal line that the both ends, face left and right of face's the widest part connect, and is all L in the distance up and down of this horizontal line
fTwo parallel lines are drawn in/7 place, obtain the intersection point of these two parallel lines and face mask line, all get the intersection point on the left side.Draw at last the angle (getting that less angle) of the tangent line of these two intersection points.If the value of this angle just is labeled as square face with the shape of face of face in the hair style image than the threshold value of setting is little, if the value of this angle just is labeled as round face with the shape of face of this character facial image greatly than the threshold value of setting, Threshold is 25 °;
3. at L
f/ W
fValue between 4/3 and 3/2 time, W relatively
1f, W
2f, W
fBetween value, if W
2fMuch smaller than W
1f, i.e. W
2f/ W
1fValue less than 0.7, the shape of face with this character facial image is labeled as the inverted triangle face; If W
1fMuch smaller than W
2f, i.e. W
1f/ W
2fValue less than 0.7, it is labeled as positive triangle face (foreign pears face); If W
1fAnd W
2fVery approaching, again in two kinds of situation, if W
fWith W
1f, W
2fValue very near (two groups of ratio W
1f/ W
f, W
2f/ W
fAll be not less than 0.9) just it is labeled as the egg shape face; Otherwise just it is labeled as the diamond pattern face;
(6) according to the shape of face under the character facial image extrapolated, the hair style storehouse can preferentially show be fit to this face image the hair image for you to choose, the operator also can select other hair image arbitrarily.Hair image in database was all anticipated, and contained specific parameter information.Anticipating of the hair image of mentioning in this step, its detailed step comprises:
A) input contains the hair style image of facial information.
B) proofread and correct the hair style image, make people's face center line perpendicular to the horizontal edge of image.
C) computing machine is located automatically to the eyes in the face of hair style image, identifies the coordinate points E of the eyes centre of form of face in the hair style image
1h, E
2h
D) according to coordinate points E
1h, E
2h, calculate the left eye centre of form apart from the distance A in hair style picture Far Left sideline
h, and the left eye centre of form apart from the character facial picture topmost the sideline apart from B
h, the distance C between the eyes centre of form
h, as shown in Figure 7.
E) computing machine detects automatically to the face mask of hair style image, the face mask line of the character facial image that identifies, and face's eyebrow coordinate position in the character facial image, face's lip coordinate position in the character facial image.Because hair style image major part exists hair to cover the problem of face image, it is more accurate that face mask line and eyebrow, lip position coordinates need that manual operations go to adjust.
F) according to face's eyebrow coordinate position in the hair style image, and the face mask line computation of the hair style image that identifies goes out the width W of face's eyebrow in character facial image place face
1hAccording to face's lip coordinate position in the hair style image, and the face mask line computation of the hair style image that identifies goes out the width W of face's lip in character facial image place face
2hScan the face mask line of hair style image, calculate the width W of face's the widest part in the hair style image
hThe forehead peak of the face mask line of the character facial image that scanning recognition goes out and lower jaw minimum point calculate the height L of face of character facial image
h, as shown in Figure 8.According to face mask line and these width that calculates and height parameter, extrapolate the shape of face of face in the hair style image, its detailed step comprises:
1. calculate the length breadth ratio L of face
h/ W
hIf, L
h/ W
hValue greater than 3/2, this shape of face with face in this hair style image is labeled as the elongated face; If L
h/ W
hValue less than 4/3, entered for the 2. step; If L
h/ W
hValue between 4/3 and 3/2, entered for the 3. step;
2. at L
h/ W
hValue less than 4/3 o'clock, calculate near the degree of crook of the face mask line face's the widest part in the hair style image, concrete account form is exactly first to draw the horizontal line that the both ends, face left and right of face's the widest part connect, and is all L in the distance up and down of this horizontal line
hTwo parallel lines are drawn in/7 place, obtain the intersection point of these two parallel lines and face mask line, all get the intersection point on the left side.Draw at last the angle (getting that less angle) of the tangent line of these two intersection points.If the value of this angle just is labeled as square face with the shape of face of face in the hair style image than the threshold value of setting is little, if the value of this angle just is labeled as round face with the shape of face of this hair style image greatly than the threshold value of setting, Threshold is 25 °;
3. at L
h/ W
hValue between 4/3 and 3/2 time, W relatively
1h, W
2h, W
hBetween value, if W
2hMuch smaller than W
1h, i.e. W
2h/ W
1hValue less than 0.7, the shape of face with face in this hair style image is labeled as the inverted triangle face; If W
1hMuch smaller than W
2h, i.e. W
1h/ W
2hValue less than 0.7, it is labeled as positive triangle face (foreign pears face); If W
1hAnd W
2hVery approaching, again in two kinds of situation, if W
hWith W
1h, W
2hValue very near (two groups of ratio W
1h/ W
h, W
2h/ W
hAll be not less than 0.9) just it is labeled as the egg shape face, otherwise just it is labeled as the diamond pattern face.
G) facial information in removal hair style image, obtain to have kept parameter information A
h, B
h, C
h, W
1h, W
2h, L
hThe hair image, and the shape of face under this hair style image is labeled as the shape of face that the hair image is fit to, as shown in Figure 9.Hair image and corresponding parameter information are written to data, complete the pre-service of hair image.Remove this process of facial information in the hair style image, can complete with the software photoshop that adobe company provides.
(7) according to the right and left eyes centre of form co-ordinate position information A of the character facial image that calculates
f, B
f, the width information C between the eyes centre of form
f, the width W of face's eyebrow place face in the character facial image
1f, the width W of face's lip place face in the character facial image
2f, face's height L in the character facial image
f, with in the hair image with the contrast of corresponding information, coupling personage's face image and hair image.
(8) respectively according to width C
fAnd the width C between the eyes centre of form in hair image institute information
hBetween ratio, the height L
fWith the character facial height L in institute's information in the hair image
hBetween ratio, horizontal and vertical convergent-divergent hair image makes C
f=C
h', L
f=L
h'.Wherein, C
h', L
h' be respectively C
h, L
hResult after variation.In addition, other parameters of convergent-divergent hair image, obtain new A in proportion
h', B
h', W
1h', W
2h'.
(9) with the hair image as upper tomographic image, face image is as bottom layer image, according to the left eye locating information A of two figure
f, B
fWith A
h', B
h', mobile hair style picture on the bottom picture makes the C of both correspondences
f, C
h' overlap, complete preliminary Auto-matching.
(10) if the shape of face that the hair image is fit to and character facial image shape of face are mated, the Auto-matching process is completed.If the shape of face that the hair image is fit to and character facial image shape of face are not mated, contrast corresponding width information in the width of width, lip place face of face image eyebrow place face and hair image, draw two groups of stand outs.
(11) calculate W
1fAfter convergent-divergent hair image, the width W of face's eyebrow place face in the hair image
1h' difference
Namely
And W
2fAfter convergent-divergent hair image, the width W of face's eyebrow place face in the hair image
2h' difference
Namely
According to
With
Value, extend out or inside contract the hair image with the liquefaction algorithm at regional area, make more natural that the figure of hair image and face mates.So far the Auto-matching process is completed.The basic functional principle of liquefaction algorithm is as follows:
In Figure 15, the shade annulus represents that a radius is r
maxCircular constituency.Wherein, C is the center of circle in circular constituency, when C moves to M, causes the some U in image to transform to an X, and the inverse transformation formula of this coordinate transform is formula 1.Wherein
Be respectively a U, X, C, M be the position vector in coordinate system in the drawings.When providing a some X, can obtain the coordinate U (accurate floating-point coordinate) before its conversion, then draw near the pixel value of the pixel of image coordinate points U before changing.Find the solution by these pixel values are carried out bilinear interpolation, derive and namely draw the pixel value of an X.So each pixel in circular constituency is carried out evaluation, just can draw the image after conversion.
(formula 1)
(12) if mate not accurate enoughly, the operator also can adjust by manual operations size and the position of hair image, or extends out or inside contract the hair image with liquify tool at regional area, makes hair image and face image perfect matching.
(13) then the operator can also further process the image after synthetic with the image processing method of summary, and these methods mainly comprise: hair style pruning, hair style adjustment, hair style are had hair dyed, manually improve looks or light is played up.
The method that hair style in step (13) is pruned comprises following four kinds of methods:
1. straight snips: straight snips is the hair image to be pruned as template with border circular areas.When with template, the hair image being pruned, the hair image information of template overlay area can be wiped.The operator realizes the pruning work to the hair image, as shown in figure 10 by dragging the mode of mouse.
2. tooth is cut: it is the hair image to be pruned as template with jagged irregular area that tooth is cut, by the height of regulating sawtooth and the tooth cut-off-die plate that bottom width is set up different densities.When with template, the hair image being pruned, the hair image information of template overlay area can be wiped, and the hair that the sawtooth on template is encountered will be cut into jagged breach.Each jagged breach intersects and will form the thin silky effect that thins when dragging template fast with mouse, makes the hair image after pruning not lose naturality, has more stereovision.
3. profile is pruned: as shown in figure 11, the face mask line of face image is presented on composograph, and the operator can change the zone that the face mask line covers by point on the drag wheel profile, and the information of the hair image in capped zone can be wiped.The operator simply just can wipe unnecessary hair information by the mode that drags a little like this, realizes the function that hair style is pruned.
4. hair style is cloned: the operator first gets a point on the hair image by mouse, orientate source point as.Then mouse press drag in, near the hair information source point will by the complete zone that mouse drags that copies to, can realize lengthening the effect of hair like this.
Hair style adjustment in step (13): the operator can be simply by dragging the point of appointment on the hair image, and the hair image that stretches makes it more mate face image, as shown in figure 12.On the operator drags in the point of some marks, utilize the liquefaction algorithm to being carried out image deformation as the zone of the appointment radius in the center of circle and process to drag a little in the hair image, the basic functional principle of liquefaction algorithm is consistent with the principle of the middle introduction of embodiment (11).
As shown in architecture Fig. 1, the method for the hair style dyeing in step (13) comprises following four kinds of methods:
1. choose and dye: the operator smears the hair image by pressing the mode of mouse drag, and specifying needs the zone of having hair dyed in the hair image, and then the color of object of hair dyeing is provided, and just can easily realize changing the colouring information of application area, realizes hair dyeing effect.The mode of color change is: kept the brightness attribute of former hair color, form and aspect, the saturation attributes of color are revised.And in the place that the regional area of the hair image that is modified color attribute is connected with the part that is not modified, the effect that color is revised is that gradual manner weakens gradually, makes the whole structure after dyeing more natural.
2. colour code hair dyeing: the operator provides the color of object of hair dyeing, just can change the integral color information of hair image, realizes whole hair dyeing effect.The mode of color change is: kept the brightness attribute of former hair color, form and aspect, the saturation attributes of color are revised, made the stereovision of the hair image after being colored well be kept.
3. multiple dimensioned hair dyeing: on the hair image, acquiescence superposeed multilayer and the onesize figure layer of hair image, these figure layers all possess respectively the information of certain regional area of hair image.The operator only need to provide and want the color of object of having hair dyed just can change the figure layer color that these possess local region information like this, realizes like a cork the hair dyeing of regional area.The mode of color change is the brightness attribute that keeps former hair color, and form and aspect, the saturation attributes of color are modified, and makes the stereovision of the hair image after being colored well be kept.Like this operator can be very easily to hair some specific zones dyeing, and during the hair image blend of these figure layers and the bottom, those edges of regions and bottoms that are changed color attribute are that gradual change is merged, and make the effect of dyeing more natural.
4. path hair dyeing: the operator need at a plurality of points of hair image pickup, connect into the path.Extend out a certain size radius take this paths as the axle center, form the regional area of an appointment in the hair image, the operator get a little describe after, select or own adjustment required color, just easily realizing route is had hair dyed.The mode of color change is: kept the brightness attribute of former hair color, form and aspect, the saturation attributes of color are modified.In the regional area that is modified color attribute hair image and the place that is not modified part and is connected, the effect that color is revised weakens gradually with gradual manner, makes the whole structure after dyeing more natural.
As shown in architecture Fig. 1, the manual beauty treatment in step (13) comprises following two kinds of methods:
1. grind the skin anti-acne: face area is combined with Gaussian Blur algorithm and skin detection algorithm, face image is carried out anti-acne process.
2. skin is cloned: the operator first gets a point by mouse face area on composograph, orientates source point as.Then mouse press drag in, near the facial information source point will be by the complete zone that mouse drags that copies to, and can cover with skin area information preferably the skin area information of other parts like this.
In step (13), light is played up: add the effect of light-illuminating to composograph, as shown in figure 14.
By above-mentioned steps, the operator can design brand-new, beautiful moulding like a cork on the basis of the face image of inputting.
(14) after designing moulding, the stylist can also be by the plane/video teaching that associates with every money hair image, corresponding moulding, the design cycle of study hair image.
Plane/video teaching: hair image corresponding in the design flow diagram of each moulding on the website and design Video tutorials and database is associated, and operator (particularly stylist) just can learn according to the curricula on the website making flow process of this hair style (hair style refers to the effect that the hair image represents).And set up special advertisement position in plane/video teaching, and the every money hair style of design material used is mapped with relevant product, realize the accurate advertisement delivery.
Embodiment:
A kind of hair styling method architecture based on eyes location and shape of face identification that the present invention proposes comprises: hair image in coupling input face image and database, formation composograph as shown in Figure 1; Synthetic images carries out hair style design; Plane/video teaching;
S1) hair image in coupling input face image and database, the process that forms composograph comprises:
(1) character facial image input;
(2) eyes of face image are located automatically, show detected eyes anchor point on face image, if identification is inaccurate, the operator can make the eyes anchor point more accurate by manual operations;
(3) calculate the left eye centre of form according to anchor point and arrive the image distance in sideline topmost to the distance of the right eye centre of form, distance, the left eye centre of form that the left eye centre of form arrives image Far Left sideline;
(4) profile and face's eyebrow, the lip coordinate of face image are detected automatically, show detected face mask line and face's eyebrow, lip position coordinates on face image.If identification is inaccurate, the operator can manually adjust the face mask line of the character facial image that identifies, and allows the face mask line mate more exactly personage's face image face mask; In like manner, also can adjust as required the face's eyebrow position coordinates that identifies, and the lip position coordinates;
(5) according to the face mask line of face image and eyebrow, lip position coordinates, calculate the height of face in the width, face image of face's the widest part in the width, face image of width, the face image lip place face of face image eyebrow place face.According to face mask line and the face's width and the height parameter that calculate, extrapolate the affiliated shape of face of this face image.For eyes to face image are accurately located automatically, and detect the outline line of character facial, the character facial image of input is positive and face image do not covered face by hair preferably.
(6) anticipated in selection hair style storehouse, the hair image of containing parameter information (the hair image refers to only comprise hair information, does not comprise the image of facial information), the hair image of suitable this face image of the preferential displaying of hair style this moment storehouse meeting is for you to choose.Wherein, similar to preprocessing process and the face image of all hair images, all obtain each positional parameter of their correspondence.
(7) according to the right and left eyes centre of form co-ordinate position information of the character facial image that calculates, width information between the eyes centre of form, the width of face's eyebrow place face in the character facial image, the width of face's lip place face in the character facial image, face's height in the character facial image, with in the hair image with the contrast of corresponding information, coupling personage's face image and hair image.
(8) height of contrast face image and hair image, the left eye centre of form be to the distance of the right eye centre of form, according to they ratio respectively in the horizontal and vertically upper convergent-divergent hair image.And, the left eye centre of form of hair image to the distance in Far Left sideline, the left eye centre of form to image topmost the information such as width of the width of the distance in sideline, face image eyebrow place face, face image lip place face also make equal proportion thereupon and change.
(9) arrive the distance in sideline, image the top to distance, the left eye centre of form in image Far Left sideline according to the left eye centre of form in the hair image after face image and convergent-divergent, to the position that is complementary with face image, namely in two figure, the corresponding right and left eyes centre of form overlaps the hair image translation.Complete preliminary Auto-matching.
(10) if the shape of face that the hair image is fit to and character facial image shape of face are mated, at this moment the Auto-matching process is completed.If do not mate, contrast corresponding width information in the width of width, lip place face of face image eyebrow place face and hair image, draw two groups of stand outs.
(11) two groups of stand outs that draw according to S10 step to the appointed area liquefaction of hair image, make that hair is local, and inside contracting or extending out to a certain degree occur with the liquefaction algorithm, and wherein, degree is determined by above-mentioned stand out.So far the Auto-matching process is completed.
(12) if mate not accurate enoughly, the operator also can adjust by manual operations size and the position of hair image, or extends out or inside contract the hair image with the liquefaction algorithm at regional area, makes hair image and face image perfect matching.
S2) the composograph process of carrying out hair style design comprises:
(1) hair style is pruned, and the hair image is carried out pruning modes;
(2) the hair image is adjusted in hair style adjustment, make that itself and face image fit better;
(3) hair style dyeing adds Color for synthetic image, makes moulding seem more fashion;
(4) manually beauty treatment, process face image, beautifies composograph;
(5) light is played up, and adds the effect of light-illuminating to composograph, completes final hair style design process;
S3) plane/video teaching: offer one of stylist and learn easily passage, learn cutting, the operating process of the different hair styles of more moneys.