Summary of the invention
In order to address the above problem, the present invention propose a kind of based on face key point automatically go pouch method and system,To realize the removal that user can one-key operation pouch, the method simple and stable, and image effect after treatment nature.
For achieving the above object, the technical solution used in the present invention is: a kind ofly automatically remove pouch based on face key pointMethod, described method comprises step:
(1) obtain input picture, described input picture can adopt 3 passage RGB images.
(2) extract masking-out figure and the pouch area image in the pouch region of described input picture.
(3) described pouch area image is transformed into LAB color space, and isolates Color Channel L, passage A and passageB。
(4) calculate brightness adjustment curve by described passage L.
(5) by described brightness adjustment curve, passage L is shone upon, obtain new tunnel L.
(6) new tunnel L, passage A and channel B are converted to rgb color space image.
(7) the masking-out figure in described pouch region is carried out to Gaussian Blur and obtain new masking-out figure.
(8) synthetic described pouch area image, rgb color space image and new masking-out figure, obtain new pouch area image.
(9) new pouch area image is replaced pouch area image, obtains final image.
Further, described step (2) comprises step:
(2.1) described input picture is carried out to face critical point detection, obtain face key point information.
(2.2) key point information of existing standard faces figure and described face key point information are shone upon, obtainMapping matrix.
(2.3) by mapping matrix, external the pouch in standard faces figure quadrilateral area is mapped in input picture,Obtain the illiteracy plate figure in the pouch region in input picture.
(2.4) extract in input picture in the data of covering plate figure corresponding region, as pouch area image.
Further, described face key point information comprises informer's mid point, a left side under the left eye exterior angle, left eye of left face partInformer's mid point, right eye interior angle and right nasal fossa under angulus oculi medialis, left nasal fossa and right eye exterior angle, right eye.
Further, described standard faces figure adopts single channel standard faces figure, described single channel standard faces figure eyeBag region is through demarcating in advance, and being initialized as white and pixel value is 255, and other region is that black pixel value is 0.
Further, described step (4) comprises step:
(4.1) described passage L is carried out to statistics with histogram, obtain statistics.
(4.2) calculate four groups of mappings according to described statistics right.
(4.3) right according to described four groups of mappings, obtain brightness adjustment curve.
Further, described statistics comprises bright pixel value A and dark pixel values B; Described 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)。
Further, described step (4.3), comprises step:
(4.3.1) compute matrix H.
, wherein hi=Hi+1-Li,i=0,1,2。
(4.3.2) compute matrix M=[m1,m2]T。
(4.3.3) compute matrix Y.
Y=6×[(H2-H1)/h1-(H1–H0)/h0,(H3–H2)/h2-(H2–H1)/h1]T。
(4.3.4) solving equation H × M=Y, and make m0=m3=0, obtain m1,m2Value.
(4.3.5) calculate 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) according to cubic polynomial coefficient ai,bi,ci,di, respectively at interval [Li,Li+1] the upper y value of calculating, specifically publicFormula is:
y=ai+bi×(x-xi)+ci×(x-xi)2+di×(x-xi)3,i=0,1,2。
(4.3.7) be brightness adjustment curve by x to the mapping of y.
Further, in described step (7), described Gaussian Blur carries out convolution by Gauss's template to image, described inConvolution process adopts IIR filtering to be optimized.
Further, in described step (8), utilize composite formula to synthesize new pouch area image.
On the other hand, the present invention also provide a kind of based on face key point automatically go pouch system, comprising:
Image input module: for obtaining input picture.
Extraction module: for calculating and extract masking-out figure and the pouch area image in pouch region of described input picture.
LAB color space conversion module: described pouch area image is transformed into LAB color space, and isolates colorPassage L, passage A and channel B.
Brightness adjustment module: calculate and obtain brightness adjustment curve, and described brightness adjustment curve is reflected passage LPenetrate, obtain new tunnel L.
Rgb color space modular converter: new tunnel L, passage A and channel B are converted to rgb color space image.
Gaussian Blur module: the masking-out figure in described pouch region is carried out to Gaussian Blur and obtain new masking-out figure.
Synthesis module: synthetic described pouch area image, rgb color space image and new masking-out figure, obtain new pouch districtArea image.
Image output module, new pouch area image is replaced pouch area image, obtains final image.
Adopt the beneficial effect of the technical program:
Proposed by the invention a kind of based on face key point automatically go pouch method, by key point, take a mappingThe pouch region that mode obtains is accurate; By generating brightness curve, make the image after brightness adjustment more natural, and can reduceThe impact of isolated noise; By adjusting at LAB color space, reduce the color loss of former figure; One proposed by the inventionBased on face key point automatically go pouch system, can coordinate method proposed by the invention to realize the application of the method.
Detailed description of the invention
In order to make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, the present invention is done into oneStep is set forth.
In the present embodiment, shown in Figure 1, a kind ofly automatically go pouch method, described method based on face key pointComprise step:
(1) obtain input picture, described input picture can adopt 3 passage RGB images.
(2) extract masking-out figure and the pouch area image in the pouch region of described input picture.
As shown in Figure 2, described step (2) comprises step:
(2.1) described input picture is carried out to face critical point detection, obtain face key point information.
Described face key point information comprises informer's mid point, left eye interior angle, left nose under the left eye exterior angle, left eye of left face partInformer's mid point, 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 described face key point information are shone upon, obtainMapping matrix.
(2.3) by mapping matrix, external the pouch in standard faces figure quadrilateral area is mapped in input picture,Obtain the illiteracy plate figure in the pouch region in input picture.
Described standard faces figure adopts single channel standard faces figure, and described single channel standard faces figure pouch region is through thingFirst demarcate, being initialized as white and pixel value is 255, and other region is that black pixel value is 0.
(2.4) extract in input picture in the data of covering plate figure corresponding region, as pouch area image.
(3) described pouch area image is transformed into LAB color space, and isolates Color Channel L, passage A and passageB。
The concrete grammar of conversion is as follows:
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 is pixel value in pouch area image, L, A, B is respectively the picture in passage L, passage A and channel BElement value.
(4) calculate brightness adjustment curve by described passage L, as shown in Figure 3, comprise step:
(4.1) described passage L is carried out to statistics with histogram, obtain statistics.
Described statistics comprises bright pixel value A and dark pixel values B; Wherein A is front 30% the brightest partial pixel in passage LAverage, B is the average of front 30% dark-part pixel in passage L.
(4.2) calculate four groups of mappings according to described statistics right.
Described four groups of mappings are to being respectively (L0,H0),(L1,H1),(L2,H2),(L3,H3), for keeping highlights imageValue.
Wherein, L3=H3=255,L2=H2=A,L1=B,H1=A-0.4142×(A-B),L0=0,H0=H1–B×(A-H1)/(A-B);(Li,Hi) represent brightness value LiBe mapped as Hi(i=0,1,2,3)。
(4.3) right according to described four groups of mappings, obtain brightness adjustment curve.
As shown in Figure 4, comprise step:
(4.3.1) compute matrix H;
, wherein hi=Hi+1-Li,i=0,1,2;
(4.3.2) compute matrix M=[m1,m2]T;
(4.3.3) compute matrix Y;
Y=6×[(H2-H1)/h1-(H1–H0)/h0,(H3–H2)/h2-(H2–H1)/h1]T;
(4.3.4) solving equation H × M=Y, and make m0=m3=0, obtain m1,m2Value;
(4.3.5) calculate 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) according to cubic polynomial coefficient ai,bi,ci,di, respectively at interval [Li,Li+1] the upper y value of calculating, concrete formulaFor:
y=ai+bi×(x-xi)+ci×(x-xi)2+di×(x-xi)3,i=0,1,2;
(4.3.7) be brightness adjustment curve by x to the mapping of y.
(5) by described brightness adjustment curve, passage L is shone upon, obtain new tunnel L.
Described brightness adjustment curve mapping process is that the value on abscissa is mapped to ordinate, with function representation be y=f(x),x,y∈[0,255];
Be Channel_L_new (i)=f (Channel_L (i)), Channel_L_new (i) and Channel_L (i) show respectivelyShow the pixel value in new tunnel L and passage L.
(6) new tunnel L, passage A and channel B are converted to 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 is respectively the value of the pixel in image new tunnel L, passage A and channel B, and r, g, b are rgb color skyBetween the value of pixel in image.
(7) the masking-out figure in described pouch region is carried out to Gaussian Blur and obtain new masking-out figure.
Described Gaussian Blur carries out convolution by Gauss's template to image, and described convolution process adopts IIR filtering to enterRow is optimized.
Gauss's template can be described with following formula:
Convolution process is R_mask_new (i, j)=1/ ∑ w (x, y) * ∑ (w (x, y) * R_mask (i+x, j+y)); X, y ∈ [3 σ, 3 σ], be also the summation scope of ∑.
Wherein, R_mask_new (i, j) is the pixel value of the capable j row of i in new masking-out figure, and R_mask (i+x, j+y) is pouchThe pixel value of the capable j+y row of i+x in the masking-out figure in region, σ gets 10, and in order to accelerate arithmetic speed, convolution process adopts IIR filteringJourney is optimized.
(8) synthetic described pouch area image, rgb color space image and new masking-out figure, obtain new pouch area image.
Utilize composite formula to synthesize new pouch area image.
Composite formula is: (a × alpha+b × (255 – alpha))/255.
Wherein, a is the pixel in described rgb color space image, and b is the pixel in described pouch area image, alphaFor the pixel in new masking-out figure.
(9) new pouch area image is replaced pouch area image, obtains final image.
For coordinating the realization of the inventive method, based on identical inventive concept, shown in Figure 5, the present invention also providesBased on face key point automatically go a pouch system, comprising:
Image input module: for obtaining input picture.
Extraction module: for calculating and extract masking-out figure and the pouch area image in pouch region of described input picture.
LAB color space conversion module: described pouch area image is transformed into LAB color space, and isolates colorPassage L, passage A and channel B.
Brightness adjustment module: calculate and obtain brightness adjustment curve, and described brightness adjustment curve is reflected passage LPenetrate, obtain new tunnel L.
Rgb color space modular converter: new tunnel L, passage A and channel B are converted to rgb color space image.
Gaussian Blur module: the masking-out figure in described pouch region is carried out to Gaussian Blur and obtain new masking-out figure.
Synthesis module: synthetic described pouch area image, rgb color space image and new masking-out figure, obtain new pouch districtArea image.
Image output module, new pouch area image is replaced pouch area image, obtains final image.
More than show and described general principle of the present invention and principal character and advantage of the present invention. The technology of the industryPersonnel should understand, and the present invention is not restricted to the described embodiments, and the just explanation of describing in above-described embodiment and description originallyThe principle of invention, without departing from the spirit and scope of the present invention, the present invention also has various changes and modifications, these changesChange and improve and all fall in the claimed scope of the invention. The claimed scope of this reality invention by appending claims andIts equivalent defines.