CN110852967B - Method for rapidly removing flaws in portrait photo - Google Patents
Method for rapidly removing flaws in portrait photo Download PDFInfo
- Publication number
- CN110852967B CN110852967B CN201911077634.6A CN201911077634A CN110852967B CN 110852967 B CN110852967 B CN 110852967B CN 201911077634 A CN201911077634 A CN 201911077634A CN 110852967 B CN110852967 B CN 110852967B
- Authority
- CN
- China
- Prior art keywords
- picture
- dot
- skin
- clamp
- blur
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 17
- 238000004364 calculation method Methods 0.000 claims abstract description 8
- 230000001815 facial effect Effects 0.000 claims abstract description 6
- 230000002950 deficient Effects 0.000 claims description 5
- 230000007547 defect Effects 0.000 claims description 4
- 230000000694 effects Effects 0.000 abstract description 3
- 208000007256 Nevus Diseases 0.000 abstract description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/77—Retouching; Inpainting; Scratch removal
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/73—Deblurring; Sharpening
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/90—Dynamic range modification of images or parts thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30196—Human being; Person
- G06T2207/30201—Face
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
Abstract
The invention discloses a method for rapidly removing flaws in a portrait photo, which comprises the steps of firstly blurring an image to obtain the most ideal skin state, calculating the initial image and the blurred image to obtain a high-frequency image, and performing superposition calculation on the high-frequency image, the initial image and the blurred image to obtain an optimized image, so that the situation of facial nevi and color spots of a person is improved aiming at self-timer software or portrait products, the skin is smoother and smoother, the algorithm speed is high, the rapid and real-time operation can be realized, and the effect is stable.
Description
Technical Field
The invention relates to the technical field of image processing, in particular to a method for rapidly removing flaws in portrait photos.
Background
At present, the defect removal is basically to remove spots and moles, carry out dark spot detection by adopting opencv, and then carry out Gaussian blur on the places. The whole process requires longer time, has large operation amount and is difficult to process in real time. This patent adopts a novel quick algorithm, and most adoption loader can be fine carry out real-time operation. Simple and quick, and good stability. And can effectively separate skin color parts, and the places outside the face are compared so as to treat the face only.
Disclosure of Invention
The invention aims to provide a method for rapidly removing flaws in a portrait photo, aiming at self-timer software or portrait products, the situations of facial nevi and color spots of people are improved, the skin is smoother and smoother, an ultra-rapid algorithm can be rapidly operated in real time, and the effect is stable.
In order to achieve the above purpose, the invention is realized by adopting the following technical scheme:
the invention discloses a method for rapidly removing flaws in portrait photos, which comprises the following steps:
s1, blurring processing is carried out on a picture A to obtain a picture B;
s2, traversing pixel points of the picture A and the picture B;
s3, calculating pixel values RGB corresponding to the picture A and the picture B under the current coordinates;
s4, calculating to obtain a high-frequency picture C according to the difference value of the green channel in the pixel values of the picture A and the picture B, wherein the aim is to amplify the edge information;
s5, blurring treatment is carried out on the high-frequency picture C, and a high-frequency part is reserved to obtain a picture D;
s6, calculating skin color probability masks according to the green channels and the red channels in the pixel values of the picture A and the picture B in the S3 to obtain a picture E;
s7, calculating flaw parts according to green channels and red channels in pixel values of the picture A and the picture B in the S3, and extracting darker spots in the skin to obtain a picture F;
s8, removing the facial outline in the picture F, shielding the non-skin color part, and obtaining a flaw picture G;
s9, removing the flaw in the picture A according to the picture G to obtain a final picture H.
Preferably, the blurring operation in step S1 and step S5 is gaussian blurring.
Preferably, the calculation formula in step S4 is,
DIFF=(ORG.G–BLUR.G)*(ORG.G-BLUR.G)*30,
DIFF=CLAMP(DIFF,0,1),
wherein the RGB values of picture a and picture B both use normalized values, i.e. the value range is 0,1,
ORG represents picture a, BLUR represents picture B, DIFF represents picture C, ".g" represents the green channel of the image, ".r" represents the red channel of the image,
the CLAMP (a, x, y) table defines a values between x and y.
Preferably, the formula for calculating the skin tone probability mask in step S6 is,
SKIN=(MIN(ORG.G,BLUR.R-0.1)-0.2)*4.0,
SKIN=CLAMP(SKIN,0,1),
SKIN=MAX(0,ORG.R-BLUR.G)*SKIN*10,
SKIN=CLAMP(SKIN,0,1),
where skun represents the SKIN tone probability mask, i.e., picture E.
Preferably, the flawed portions are calculated in step S7, and the formula for extracting the darker spots in the skin is,
DOT=MAX(0,BLUR.G–ORG.G)*15-0.2,
DOT=CLAMP(DOT,0,1),
wherein DOT represents a defect map, i.e., picture F.
Preferably, after DOT is obtained, the CLAMP operation is performed after more than one superposition algorithm operation is performed,
the superposition algorithm formula is expressed by OVERLAY, the superposition algorithm formula is,
preferably, the superposition algorithm operation is performed twice, specifically,
DOT=OVERLAY(DOT,DOT),
DOT=OVERLAY(DOT,DOT),
DOT=CLAMP(DOT,0,1)。
preferably, the calculation formula in step S8 is,
SPOT=DOT*SKIN–DIFF*DIFF*20,
SPOT=CLAMP(SPOT,0,1),
where SPOT represents a defective picture G.
Preferably, the calculation formula in step S9 is,
FINAL=ORG.RGB*(1-SPOT*DELTA)+BLUR.RGB*SPOT*DELTA,
wherein FLNAL represents final picture H, DELTA represents the degree of speckle removal, and DELTA has a value range of [0,1].
The invention has the beneficial effects that:
the invention firstly blurs the image to obtain the most ideal skin state, calculates the initial image and the blurred image to obtain the high-frequency image, and performs superposition calculation on the high-frequency image, the initial image and the blurred image to obtain the optimized image, thus aiming at self-timer software or portrait products, improving the facial mole and color spots of people, enabling the skin to be smoother and smoother, realizing fast algorithm speed, being capable of running in real time and having stable effect.
Drawings
Fig. 1 is an illustration of a picture a;
fig. 2 is an illustration of picture B;
fig. 3 is an illustration of a high frequency picture C;
fig. 4 is an illustration of picture D;
fig. 5 is an illustration of picture E;
fig. 6 is an illustration of picture F;
fig. 7 is an illustration of a defective picture G;
fig. 8 is an illustration of picture H.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent.
As shown in fig. 1 to 8, the present invention includes the steps of:
s1, carrying out Gaussian blur on a picture A to obtain a picture B, wherein the picture A is an original picture;
s2, traversing pixel points of the picture A and the picture B;
s3, calculating pixel values RGB corresponding to the picture A and the picture B under the current coordinates;
s4, calculating to obtain a high-frequency picture C according to the difference value of the green channel in the pixel values of the picture A and the picture B, aiming at amplifying the edge information,
DIFF=(ORG.G–BLUR.G)*(ORG.G-BLUR.G)*30,
DIFF=CLAMP(DIFF,0,1),
wherein the RGB values of picture a and picture B both use normalized values, i.e. the value range is 0,1,
ORG represents picture a, BLUR represents picture B, DIFF represents picture C, ".g" represents the green channel of the image, ".r" represents the red channel of the image,
the CLAMP (a, x, y) table defines a values between x and y;
s5, carrying out Gaussian blur on the high-frequency picture C, and reserving a high-frequency part to obtain a picture D;
s6, calculating skin color probability masks according to the green channels and the red channels in the pixel values of the picture A and the picture B in the S3 to obtain a picture E, wherein the formula for calculating the skin color probability masks is as follows,
SKIN=(MIN(ORG.G,BLUR.R-0.1)-0.2)*4.0,
SKIN=CLAMP(SKIN,0,1),
SKIN=MAX(0,ORG.R-BLUR.G)*SKIN*10,
SKIN=CLAMP(SKIN,0,1),
where sken represents the SKIN tone probability mask, i.e. picture E,
wherein MIN (X, Y) refers to the smaller value of X and Y,
MAX (X, Y) refers to taking the larger of X and Y;
s7, calculating flaw parts according to green channels and red channels in pixel values of the picture A and the picture B in the S3, extracting darker spots in the skin to obtain a picture F,
the formula for extracting the darker spots of skin is,
DOT=MAX(0,BLUR.G–ORG.G)*15-0.2,
DOT=CLAMP(DOT,0,1),
where DOT represents the defect map, i.e. picture F,
after DOT is obtained, the operation of a superposition algorithm is carried out twice,
the superposition algorithm formula is expressed by OVERLAY, the superposition algorithm formula is,
DOT=OVERLAY(DOT,DOT),
DOT=OVERLAY(DOT,DOT),
DOT=CLAMP(DOT,0,1);
s8, removing the facial outline in the picture F, shielding the non-skin color part to obtain a flaw picture G,
SPOT=DOT*SKIN–DIFF*DIFF*20,
SPOT=CLAMP(SPOT,0,1),
wherein SPOT represents a defective picture G;
s9, removing the flaw in the picture A according to the picture G to obtain a final picture H,
FINAL=ORG.RGB*(1-SPOT*DELTA)+BLUR.RGB*SPOT*DELTA,
wherein FLNAL represents final picture H, DELTA represents the degree of speckle removal, and DELTA has a value range of [0,1].
Of course, the present invention is capable of other various embodiments and its several details are capable of modification and variation in light of the present invention by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.
Claims (9)
1. A method for rapidly removing flaws in a portrait photo is characterized by comprising the following steps:
s1, blurring processing is carried out on a picture A to obtain a picture B, wherein the picture A is an original picture;
s2, traversing pixel points of the picture A and the picture B;
s3, calculating pixel values RGB corresponding to the picture A and the picture B under the current coordinates;
s4, calculating to obtain a high-frequency picture C according to the difference value of the green channel in the pixel values of the picture A and the picture B, wherein the aim is to amplify the edge information;
s5, blurring treatment is carried out on the high-frequency picture C, namely only a high-frequency part is reserved, and a picture D is obtained;
s6, calculating skin color probability masks according to the green channels and the red channels in the pixel values of the picture A and the picture B in the S3 to obtain a picture E;
s7, calculating flaw parts according to green channels and red channels in pixel values of the picture A and the picture B in the S3, and extracting darker spots in the skin to obtain a picture F;
s8, removing the facial outline in the picture F, shielding the non-skin color part, and obtaining a flaw picture G;
s9, removing the flaw in the picture A according to the picture G to obtain a final picture H.
2. The method for rapidly removing flaws in a portrait photo according to claim 1, wherein: the blurring operation in step S1 and step S5 is gaussian blurring.
3. The method for rapidly removing flaws in a portrait photo according to claim 1, wherein: the calculation formula in step S4 is as follows,
DIFF=(ORG.G–BLUR.G)*(ORG.G-BLUR.G)*30,
DIFF=CLAMP(DIFF,0,1),
wherein the RGB values of picture a and picture B both use normalized values, i.e. the value range is 0,1,
ORG represents picture a, BLUR represents picture B, DIFF represents picture C, ".g" represents the green channel of the image, ".r" represents the red channel of the image,
the CLAMP (a, x, y) table defines a values between x and y.
4. The method for rapidly removing flaws in a portrait photo according to claim 3, wherein: the formula for calculating the skin tone probability mask in step S6 is,
SKIN=(MIN(ORG.G,BLUR.R-0.1)-0.2)*4.0,
SKIN=CLAMP(SKIN,0,1),
SKIN=MAX(0,ORG.R-BLUR.G)*SKIN*10,
SKIN=CLAMP(SKIN,0,1),
where skun represents the SKIN tone probability mask, i.e., picture E.
5. The method for rapidly removing flaws in a portrait photo according to claim 3 or 4, wherein: in step S7, a defective portion is calculated, and the formula for extracting a darker spot portion of the skin is,
DOT=MAX(0,BLUR.G–ORG.G)*15-0.2,
DOT=CLAMP(DOT,0,1),
wherein DOT represents a defect map, i.e., picture F.
6. The method for rapidly removing flaws in a portrait photo according to claim 5, wherein:
after DOT is obtained, the CLAMP operation is carried out after more than one superposition algorithm operation is carried out,
the superposition algorithm formula is expressed by OVERLAY, the superposition algorithm formula is,
。
7. the method for rapidly removing flaws in a portrait photo according to claim 6, wherein: the operation of the superposition algorithm is carried out twice, and the specific operation is that,
DOT=OVERLAY(DOT,DOT),
DOT=OVERLAY(DOT,DOT),
DOT=CLAMP(DOT,0,1)。
8. the method for rapidly removing flaws in a portrait photo according to claim 7, wherein: the calculation formula in step S8 is as follows,
SPOT=DOT*SKIN–DIFF*DIFF*20,
SPOT=CLAMP(SPOT,0,1),
where SPOT represents a defective picture G.
9. The method for rapidly removing flaws in a portrait photo according to claim 8, wherein: the calculation formula in step S9 is as follows,
FINAL=ORG.RGB*(1-SPOT*DELTA)+BLUR.RGB*SPOT*DELTA,
wherein FLNAL represents final picture H, DELTA represents the degree of speckle removal, and DELTA has a value range of [0,1].
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911077634.6A CN110852967B (en) | 2019-11-06 | 2019-11-06 | Method for rapidly removing flaws in portrait photo |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911077634.6A CN110852967B (en) | 2019-11-06 | 2019-11-06 | Method for rapidly removing flaws in portrait photo |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110852967A CN110852967A (en) | 2020-02-28 |
CN110852967B true CN110852967B (en) | 2023-09-12 |
Family
ID=69599912
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911077634.6A Active CN110852967B (en) | 2019-11-06 | 2019-11-06 | Method for rapidly removing flaws in portrait photo |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110852967B (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH11275363A (en) * | 1998-03-25 | 1999-10-08 | Fuji Photo Film Co Ltd | Method for processing picture |
CN104134198A (en) * | 2014-07-28 | 2014-11-05 | 厦门美图之家科技有限公司 | Method for carrying out local processing on image |
CN104331868A (en) * | 2014-11-17 | 2015-02-04 | 厦门美图网科技有限公司 | Optimizing method of image border |
CN105354810A (en) * | 2015-12-07 | 2016-02-24 | 厦门美图之家科技有限公司 | Method, system and shooting terminal for removing speckles of image |
CN105608677A (en) * | 2015-12-28 | 2016-05-25 | 成都品果科技有限公司 | Image skin color beautifying method and system under any lighting conditions |
CN107274452A (en) * | 2017-05-31 | 2017-10-20 | 成都品果科技有限公司 | A kind of small pox automatic testing method |
CN109345470A (en) * | 2018-09-07 | 2019-02-15 | 华南理工大学 | Facial image fusion method and system |
CN109712095A (en) * | 2018-12-26 | 2019-05-03 | 西安工程大学 | A kind of method for beautifying faces that rapid edge retains |
CN110070502A (en) * | 2019-03-25 | 2019-07-30 | 成都品果科技有限公司 | The method, apparatus and storage medium of facial image mill skin |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7039222B2 (en) * | 2003-02-28 | 2006-05-02 | Eastman Kodak Company | Method and system for enhancing portrait images that are processed in a batch mode |
CN103927719B (en) * | 2014-04-04 | 2017-05-17 | 北京猎豹网络科技有限公司 | Picture processing method and device |
-
2019
- 2019-11-06 CN CN201911077634.6A patent/CN110852967B/en active Active
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH11275363A (en) * | 1998-03-25 | 1999-10-08 | Fuji Photo Film Co Ltd | Method for processing picture |
CN104134198A (en) * | 2014-07-28 | 2014-11-05 | 厦门美图之家科技有限公司 | Method for carrying out local processing on image |
CN104331868A (en) * | 2014-11-17 | 2015-02-04 | 厦门美图网科技有限公司 | Optimizing method of image border |
CN105354810A (en) * | 2015-12-07 | 2016-02-24 | 厦门美图之家科技有限公司 | Method, system and shooting terminal for removing speckles of image |
CN105608677A (en) * | 2015-12-28 | 2016-05-25 | 成都品果科技有限公司 | Image skin color beautifying method and system under any lighting conditions |
CN107274452A (en) * | 2017-05-31 | 2017-10-20 | 成都品果科技有限公司 | A kind of small pox automatic testing method |
CN109345470A (en) * | 2018-09-07 | 2019-02-15 | 华南理工大学 | Facial image fusion method and system |
CN109712095A (en) * | 2018-12-26 | 2019-05-03 | 西安工程大学 | A kind of method for beautifying faces that rapid edge retains |
CN110070502A (en) * | 2019-03-25 | 2019-07-30 | 成都品果科技有限公司 | The method, apparatus and storage medium of facial image mill skin |
Non-Patent Citations (1)
Title |
---|
Photoshop快速处理人像的方法;钱伟;王海旭;;计算机时代(第12期);68-72页 * |
Also Published As
Publication number | Publication date |
---|---|
CN110852967A (en) | 2020-02-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019091270A1 (en) | Image enhancement method and system | |
US8131084B2 (en) | Apparatus for improving sharpness of image | |
Li et al. | Image enhancement based on Retinex and lightness decomposition | |
CN108830800B (en) | Brightness improvement and enhancement method for image in dark scene | |
CN105654437A (en) | Enhancement method for low-illumination image | |
JP2006135745A5 (en) | ||
CN113808027B (en) | Human body image processing method and device, electronic equipment and storage medium | |
CN107369133B (en) | Face image beautifying method and device | |
CN107451963B (en) | Multispectral nasal endoscope real-time image enhancement method and endoscope imaging system | |
AU2014397095A1 (en) | Haze removal device and image generation method | |
CN104809694B (en) | Digital image processing method and device | |
CN107256539B (en) | Image sharpening method based on local contrast | |
CN108182671A (en) | Single image defogging method based on sky area identification | |
CN110852967B (en) | Method for rapidly removing flaws in portrait photo | |
CN111127350A (en) | Image enhancement method | |
CN106846271B (en) | Method for removing reticulate pattern in identity card photo | |
WO2018154965A1 (en) | Image processing device and imaging apparatus | |
CN114331896A (en) | Image enhancement method and system based on image decomposition and spectral transformation | |
CN112529800A (en) | Near-infrared vein image processing method for filtering hair noise | |
CN113191985B (en) | Intelligent freckle removing system based on infrared laser | |
CN111047619B (en) | Face image processing method and device and readable storage medium | |
JP3902887B2 (en) | Lip extraction method | |
CN111414877B (en) | Table cutting method for removing color frame, image processing apparatus and storage medium | |
CN113947535B (en) | Low-illumination image enhancement method based on illumination component optimization | |
CN110473295B (en) | Method and equipment for carrying out beautifying treatment based on three-dimensional face model |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |