Invention content
To solve the above-mentioned problems, the present invention proposes that a kind of automatic based on face key point goes pouch method and system,
To realize that user is capable of the removal of one-key operation pouch, the method simple and stable, and treated image effect is natural.
In order to achieve the above objectives, the technical solution adopted by the present invention is:It is a kind of that pouch is gone based on face key point automatically
Method, the method includes the steps:
(1) input picture is obtained, 3 channel RGB images can be used in the input picture.
(2) the masking-out figure and pouch area image in the pouch region of the input picture are extracted.
(3) the pouch area image is transformed into LAB color spaces, and isolates Color Channel L, channel A and channel
B。
(4) brightness adjustment curve is calculated by the channel L.
(5) channel L is mapped by the brightness adjustment curve, obtains new tunnel L.
(6) new tunnel L, channel A and channel B are converted into rgb color space image.
(7) Gaussian Blur is carried out to the masking-out figure in the pouch region and obtains new masking-out figure.
(8) the pouch area image, rgb color space image and new masking-out figure are synthesized, new pouch area image is obtained.
(9) new pouch area image replaces pouch area image, obtains final image.
Further, the step (2) includes step:
(2.1) face critical point detection is carried out to the input picture, obtains face key point information.
(2.2) key point information of existing standard faces figure and the face key point information are mapped, is obtained
Mapping matrix.
(2.3) by mapping matrix, the external quadrilateral area of pouch in standard faces figure is mapped in input picture,
Obtain the mask figure in the pouch region in input picture.
(2.4) data in input picture in mask figure corresponding region are extracted, as pouch area image.
Further, the face key point information includes informer midpoint, a left side under the left eye exterior angle of left face part, left eye
Informer midpoint, right eye interior angle and right nasal fossa under angulus oculi medialis, left nose ditch and right eye exterior angle, right eye.
Further, the standard faces figure uses single channel standard faces figure, the single channel standard faces figure eye
Bag region is by calibration in advance, and it is 255 to be initialized as white and pixel value, and other regions are that black pixel value is 0.
Further, the step (4) includes step:
(4.1) statistics with histogram is carried out to the channel L, obtains statistical data.
(4.2) four groups of mappings pair are calculated according to the statistical data.
(4.3) according to four groups of mappings pair, brightness adjustment curve is obtained.
Further, the statistical data includes bright pixel value A ' and dark pixel values B ';Four groups of mappings are to respectively
For (L0,H0),(L1,H1),(L2,H2),(L3,H3), wherein L3=H3=255, L2=H2=A ', L1=B ', H1=A ' -0.4142
× (A '-B '), L0=0, H0=H1–B′×(A′-H1)/(A′-B′)。
Further, the step (4.3), including step:
(4.3.1) calculating matrix H:
Wherein hi=Hi+1-Li, i=0,1,2;
(4.3.2) calculating matrix M=[m1,m2]T;
(4.3.3) calculating matrix Y:
Y=6 × [(H2-H1)/h1-(H1–H0)/h0,(H3–H2)/h2-(H2–H1)/h1]T;
(4.3.4) solves equation H × M=Y, and enables m0=m3=0, obtain m1,m2Value;
(4.3.5) calculates the cubic polynomial coefficient a of each segment matched curvei,bi,ci,di;
Wherein, ai=Hi;
bi=(Hi+1-Hi)/hi-hi×mi/2-hi×(mi+1-mi)/6;
ci=mi/2;
di=(mi+1-mi)/(6hi);
(4.3.6) is according to cubic polynomial coefficient ai,bi,ci,di, respectively in section [Li,Li+1] on calculate y values, it is specific public
Formula is:
Y=ai+bi×(x-xi)+ci×(x-xi)2+di×(x-xi)3, i=0,1,2;
(4.3.7) is brightness adjustment curve by the mapping of x to y.
Further, in the step (7), the Gaussian Blur carries out convolution with Gaussian template to image, described
Convolution is optimized using IIR filterings.
Further, in the step (8), new pouch area image is synthesized using composite formula.
On the other hand, the present invention also provides a kind of going pouch system automatically based on face key point, including:
Image input module:For obtaining input picture.
Extraction module:The masking-out figure and pouch area image in the pouch region for calculating and extracting the input picture.
LAB color space conversion modules:The pouch area image is transformed into LAB color spaces, and isolates color
Channel L, channel A and channel B.
Brightness adjusting section:Brightness adjustment curve is calculated and obtained, and channel L is reflected by the brightness adjustment curve
It penetrates, obtains new tunnel L.
Rgb color space conversion module:New tunnel L, channel A and channel B are converted into rgb color space image.
Gaussian Blur module:Gaussian Blur is carried out to the masking-out figure in the pouch region and obtains new masking-out figure.
Synthesis module:The pouch area image, rgb color space image and new masking-out figure are synthesized, new pouch area is obtained
Area image.
Image output module, new pouch area image replace pouch area image, obtain final image.
Using the advantageous effect of the technical program:
A kind of automatic based on face key point proposed by the invention goes pouch method, by key point, takes and a little reflects
The pouch region that the mode penetrated obtains is accurate;By generating brightness curve, make the image after brightness adjustment more naturally, and can
Reduce the influence of isolated noise;By being adjusted in LAB color spaces, the color loss of artwork is reduced;It is proposed by the invention
It is a kind of that pouch system is gone based on face key point automatically, method proposed by the invention can be coordinated to realize answering for this method
With.
Specific implementation mode
To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention is made into one below in conjunction with the accompanying drawings
Step illustrates.
In the present embodiment, shown in Figure 1, it is a kind of that pouch method, the method are gone based on face key point automatically
Including step:
(1) input picture is obtained, 3 channel RGB images can be used in the input picture.
(2) the masking-out figure and pouch area image in the pouch region of the input picture are extracted.
As shown in Fig. 2, the step (2) includes step:
(2.1) face critical point detection is carried out to the input picture, obtains face key point information.
The face key point information includes informer midpoint, left eye interior angle, left nose under the left eye exterior angle of left face part, left eye
Informer midpoint, right eye interior angle and right nasal fossa under ditch and right eye exterior angle, right eye.
(2.2) key point information of existing standard faces figure and the face key point information are mapped, is obtained
Mapping matrix.
(2.3) by mapping matrix, the external quadrilateral area of pouch in standard faces figure is mapped in input picture,
Obtain the mask figure in the pouch region in input picture.
The standard faces figure uses single channel standard faces figure, single channel standard faces figure pouch region to pass through thing
It first demarcates, it is 255 to be initialized as white and pixel value, and other regions are that black pixel value is 0.
(2.4) data in input picture in mask figure corresponding region are extracted, as pouch area image.
(3) the pouch area image is transformed into LAB color spaces, and isolates Color Channel L, channel A and channel
B。
The specific method is as follows for conversion:
L=0.2126 × r+0.7152 × g+0.0722 × b.
A=1.4749 × (0.2213 × r-0.3390 × g+0.1177 × b)+0.5 × 255.
B=0.6245 × (0.1949 × r+0.6057 × g-0.8006 × b)+0.5 × 255.
Wherein, r, g, b are pixel value in pouch area image, and L, A, B is respectively the picture in channel L, channel A and channel B
Element value.
(4) brightness adjustment curve is calculated by the channel L, as shown in figure 3, including step:
(4.1) statistics with histogram is carried out to the channel L, obtains statistical data.
The statistical data includes bright pixel value A ' and dark pixel values B ';Wherein A ' is preceding 30% most bright part in the L of channel
The mean value of pixel, B ' are the mean value of preceding 30% most dark-part pixel in the L of channel.
(4.2) four groups of mappings pair are calculated according to the statistical data.
Four groups of mappings are to being respectively (L0,H0),(L1,H1),(L2,H2),(L3,H3), wherein L3=H3=255, L2=
H2=A ', L1=B ', H1=A ' -0.4142 × (A '-B '), L0=0, H0=H1–B′×(A′-H1)/(A′-B′)。
(4.3) according to four groups of mappings pair, brightness adjustment curve is obtained.
As shown in figure 4, including step:
(4.3.1) calculating matrix H:
Wherein hi=Hi+1-Li, i=0,1,2;
(4.3.2) calculating matrix M=[m1,m2]T;
(4.3.3) calculating matrix Y:
Y=6 × [(H2-H1)/h1-(H1–H0)/h0,(H3–H2)/h2-(H2–H1)/h1]T;
(4.3.4) solves equation H × M=Y, and enables m0=m3=0, obtain m1,m2Value;
(4.3.5) calculates the cubic polynomial coefficient a of each segment matched curvei,bi,ci,di;
Wherein, ai=Hi;
bi=(Hi+1-Hi)/hi-hi×mi/2-hi×(mi+1-mi)/6;
ci=mi/2;
di=(mi+1-mi)/(6hi);
(4.3.6) is according to cubic polynomial coefficient ai,bi,ci,di, respectively in section [Li,Li+1] on calculate y values, it is specific public
Formula is:
Y=ai+bi×(x-xi)+ci×(x-xi)2+di×(x-xi)3, i=0,1,2;
(4.3.7) is brightness adjustment curve by the mapping of x to y.
(5) channel L is mapped by the brightness adjustment curve, obtains new tunnel L.
The brightness adjustment curve mapping process is that the value on abscissa is mapped to ordinate, is y=f with function representation
(x), x, y ∈ [0,255];
That is Channel_L_new (i)=f (Channel_L (i)), Channel_L_new (i) and Channel_L (i) divide
Pixel value that Biao Shi be in new tunnel L and channel L.
(6) new tunnel L, channel A and channel B are converted into rgb color space image.
Conversion method is as follows:
R=L+ ((A-0.5 × 255) × 0.682353 × 3.07989502+ (B-0.5 × 255) × 0.607843 ×
0.542907715)。
G=L- ((A-0.5 × 255) × 0.682353 × 0.92089844+ (B-0.5 × 255) × 0.607843 ×
0.045196535)。
B=L+ ((A-0.5 × 255) × 0.682353 × 0.05310059- (B-0.5 × 255) × 0.607843 ×
1.151092529)。
Wherein L, A, B are respectively the value of image new tunnel L, channel A and the pixel in the B of channel, and r, g, b are that rgb color is empty
Between pixel in image value.
(7) Gaussian Blur is carried out to the masking-out figure in the pouch region and obtains new masking-out figure.
The Gaussian Blur carries out convolution with Gaussian template to image, and the convolution is carried out excellent using IIR filterings
Change.
Gaussian template can be described with following formula:
Convolution process is ∑ w (x, the y) * of R_mask_new (i, j)=1/ ∑s (w (x, y) * R_mask (i+x, j+y));x,y
∈ [- 3 σ, 3 σ], namely ∑ summation range.
Wherein, R_mask_new (i, j) is the pixel value of i rows j row in new masking-out figure, and R_mask (i+x, j+y) is pouch
The pixel value that i+x rows j+y is arranged in the masking-out figure in region, σ take 10, and in order to accelerate arithmetic speed, convolution process was filtered using IIR
Journey optimizes
(8) the pouch area image, rgb color space image and new masking-out figure are synthesized, new pouch area image is obtained.
New pouch area image is synthesized using composite formula.
Composite formula is:(a×alpha+b×(255–alpha))/255.
Wherein, a is the pixel in the rgb color space image, and b is the pixel in the pouch area image, alpha
For the pixel in new masking-out figure.
(9) new pouch area image replaces pouch area image, obtains final image.
It is shown in Figure 5 based on identical inventive concept to coordinate the realization of the method for the present invention, the present invention also provides
It is a kind of that pouch system is gone based on face key point automatically, including:
Image input module:For obtaining input picture.
Extraction module:The masking-out figure and pouch area image in the pouch region for calculating and extracting the input picture.
LAB color space conversion modules:The pouch area image is transformed into LAB color spaces, and isolates color
Channel L, channel A and channel B.
Brightness adjusting section:Brightness adjustment curve is calculated and obtained, and channel L is reflected by the brightness adjustment curve
It penetrates, obtains new tunnel L.
Rgb color space conversion module:New tunnel L, channel A and channel B are converted into rgb color space image.
Gaussian Blur module:Gaussian Blur is carried out to the masking-out figure in the pouch region and obtains new masking-out figure.
Synthesis module:The pouch area image, rgb color space image and new masking-out figure are synthesized, new pouch area is obtained
Area image.
Image output module, new pouch area image replace pouch area image, obtain final image.
The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention.The technology of the industry
Personnel are it should be appreciated that the present invention is not limited to the above embodiments, and the above embodiments and description only describe this
The principle of invention, without departing from the spirit and scope of the present invention, various changes and improvements may be made to the invention, these changes
Change and improvement all fall within the protetion scope of the claimed invention.The invention of this reality be claimed range by appended claims and
Its equivalent thereof.