A method and system for portrait beautification
By using skin region segmentation based on consecutive frames and a self-developed algorithm, combined with HSL color space and Gamma correction technology, the problem of unnatural skin tone and lens flicker in images and videos has been solved, achieving a natural and cool white skin tone effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU GUANGZHUIYUAN INFORMATION TECH CO LTD
- Filing Date
- 2022-09-27
- Publication Date
- 2026-04-17
AI Technical Summary
Existing image and video editing software can easily cause images to appear bluish-white or skin to appear unnaturally white, and may also cause camera flickering issues that reveal flaws.
By segmenting skin regions based on previous and next frames, correcting color cast, adjusting skin tone, adjusting color temperature, and mixing light, a self-developed deep learning network and color cast correction algorithm are used, combined with HSL color space and Gamma correction technology, to achieve natural skin tone adjustment.
It achieves a natural cool white skin tone effect, avoids an overall bluish-white bias, ensures the continuity and naturalness of images and videos, and avoids camera flickering that could reveal flaws.
Smart Images

Figure CN115564675B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and specifically to an image processing method and system for portrait beautification. Background Technology
[0002] With the rapid development of mobile internet technology, various video software is emerging in increasing numbers. Ordinary users are also demanding more and more image and video enhancement. In the field of image and video post-processing, users are beginning to pursue a cool, fair skin tone texture to achieve the goal of beautifying portraits in videos.
[0003] However, most existing image and video editing software achieves this through skin color filtering, white balance adjustment, or overlaying color masks, while some use color lookup tables. These methods easily lead to an overall bluish-white tint in the image or video, or to make the skin appear unnaturally white. If the skin recognition model in the software is ineffective, it can also cause flickering in the portrait area, revealing the flaw. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide an image processing method and system for portrait beautification, so as to solve the problems of the overall blue-white bias of images and videos, unnatural white skin, and lens flickering in the prior art.
[0005] According to a first aspect of the present invention, an image processing method for portrait beautification is provided, comprising:
[0006] Step S1: Perform skin region segmentation on texture A of the original image based on the previous and next frames to obtain texture B;
[0007] Step S2: Perform color cast correction on textures A and B to obtain the corrected texture D;
[0008] Step S3: Convert the texture D and the hintRGB color to the HSL space for skin tone adjustment, obtain the tendency color value resultRGB of the input pixel, and output the texture E1.
[0009] Based on texture E1, texture B and texture D, update texture E1 to obtain texture E2;
[0010] Steps S4 and 4.1 involve correcting the texture E2 to a linear space using Gamma to obtain texture F;
[0011] 4.2 Based on the color temperature value K, the light color (lightRGB) is obtained;
[0012] 4.3 The texture F and the lighting color lightRGB are mixed to obtain the corrected lighting color correctedLightedRGB, which is then output to obtain the texture G;
[0013] 4.4 The textures G and E2 are blended using texture B to obtain texture H;
[0014] 4.5 Soft blend the texture A and the texture H to obtain texture J.
[0015] Preferably, the step of segmenting the skin region of texture A in the original image based on consecutive frames to obtain texture B specifically involves:
[0016] Skin region segmentation is performed on texture A of the input original image to obtain texture B; wherein, texture B is a single-channel 8-bit integer texture or a 16-bit half-floating-point precision texture.
[0017] Preferably, the method further includes:
[0018] The texture A is in YUV or RGB format.
[0019] Preferably, the step of performing color cast correction on textures A and B to obtain the corrected texture D specifically involves:
[0020] White balance correction is performed on texture A to obtain texture C;
[0021] Texture A and Texture C are color-corrected using Texture B to obtain Texture D, which is calculated as follows: D = A × (1.0 - B) + C × B.
[0022] Preferably, the step of converting the texture D and the hintRGB color to the HSL space for skin tone adjustment to obtain the tendency color value resultRGB of the input pixel and outputting the texture E1 specifically involves:
[0023] sourceHSL=rgb_to_hsl(sourceRGB);
[0024] hintHSL=rgb_to_hsl(hintRGB);
[0025] resultHSL.h = hintHSL.h;
[0026] resultHSL.s=sourceHSL.s×2.0;
[0027] resultHSL.l=sourceHSL.l+2.0×(hintHSL.l–0.5)×(sourceHSL.l×0.5+0.5);
[0028] resultRGB=hsl_to_rgb(resultHSL);
[0029] Here, rgb_to_hsl represents converting a certain RGB color value to an HSL color value; hsl_to_rgb represents converting a certain HSL color value to an RGB color value; hintHSL represents the coordinate values of hintRGB converted to HSL space using a color conversion formula; resultHSL represents the value of the resulting color in the HSL color space; resultHSL.h represents the h component value of the resulting color; resultHSL.s represents the s component value of the resulting color; resultHSL.l represents the l component value of the resulting color; and hsl_to_rgb represents converting an HSL color value back to an RGB color value.
[0030] Preferably, the step of updating texture E1 to obtain texture E2 based on texture E1, texture B and texture D specifically means: updating texture E1 to obtain texture E2 based on texture D, texture B and texture E1, and the calculation formula is: E2=D×(1.0-B)+E1×B.
[0031] Preferably, obtaining the light color (lightRGB) based on the color temperature value K specifically involves:
[0032] Based on the color temperature value K of cool light, the light color (lightRGB) is obtained using the following formula:
[0033] lightRGB=xyz_to_srgb(temperature_to_xyz(K));
[0034] The `temperature_to_xyz` function converts color temperature values to the XYZ standard color space; the `xyz_to_srgb` function converts values in the XYZ color space to the sRGB color space.
[0035] Preferably, the step of mixing the texture F and the lighting color lightRGB to obtain a corrected lighting color correctedLightedRGB and outputting it to obtain texture G is specifically as follows:
[0036] After obtaining the light color lightRGB, each pixel in the texture F is recorded as originRGB and then mixed with the light color lightRGB.
[0037] Light blending formula: luma = dot(originRGB, vector3(0.3, 0.4, 0.3));
[0038] shadow=0.28+0.72×clamp(luma, 0.0, 1.0);
[0039] lightedRGB=originRGB×0.2+0.8×originRGB×lightRGB×shadow;
[0040] correctedLightedRGB=lightedRGB0.4545;
[0041] The correctedLightedRGB is then used as the pixel output to obtain texture G;
[0042] The dot function performs a dot product of two vectors; vector3 creates a 3D vector from the numbers within the parentheses; and the clamp function truncates the vector if the first number is less than the second or greater than the third.
[0043] Preferably, the process of blending texture G and texture E2 using texture B to obtain texture H is specifically calculated using the following formula:
[0044] H = E × (1.0 - B) + G × B.
[0045] According to a second aspect of the present invention, an image processing system for portrait beautification is provided, comprising:
[0046] The skin region segmentation module is used to segment the skin region of the original image based on the texture A of the previous and next frames to obtain texture B;
[0047] A color cast correction module is used to perform color cast correction on textures A and B to obtain the corrected texture D.
[0048] The skin tone adjustment module is used to convert the texture D and the inspiration color hintRGB to the HSL space for skin tone adjustment, obtain the tendency color value resultRGB of the input pixel, and output the texture E1.
[0049] Based on texture E1, texture B and texture D, update texture E1 to obtain texture E2;
[0050] The mixing module is used to correct the texture E2 to a linear space using Gamma correction to obtain texture F;
[0051] Based on the color temperature value K, the light color (lightRGB) is obtained;
[0052] The texture F and the lighting color lightRGB are mixed to obtain the corrected lighting color correctedLightedRGB, which is then output to obtain the texture G;
[0053] The textures G and E2 are blended using texture B to obtain texture H;
[0054] Texture A and texture H are blended using a soft light technique to obtain texture J.
[0055] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects:
[0056] This invention first segments the skin region of the original image based on texture A from consecutive frames to obtain texture B. Then, it corrects the color cast of textures A and B to obtain corrected texture D. Texture D and the hintRGB color are converted to the HSL space for skin tone adjustment, resulting in the hintRGB color value of the input pixel, and texture E1 is output. Based on texture E1, texture B, and texture D, texture E1 is updated to obtain texture E2. Then, texture E2 is corrected using Gamma to obtain texture F. Based on the color temperature value K, the lighting color lightRGB is obtained. Texture F and the lighting color lightRGB are then compared... The RGB light is mixed to obtain the corrected lighting color (correctedLightedRGB) and output, resulting in texture G. Texture G and texture E2 are then mixed with texture B to obtain texture H. Finally, texture A and texture H are mixed with soft light to obtain texture J. The technical solution of this invention achieves a seamless overall image and video effect by segmenting the skin areas of consecutive frames. At the same time, it uses color cast correction, skin tone adjustment, color bias adjustment, and color temperature adjustment to achieve a cool white skin effect without an overall bluish-white bias, making the skin tone more transparent and natural.
[0057] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0058] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0059] Figure 1 This is a flowchart illustrating an image processing method for portrait beautification according to an exemplary embodiment;
[0060] Figure 2 This is a schematic block diagram illustrating an image processing system for portrait beautification according to an exemplary embodiment. Detailed Implementation
[0061] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0062] Example 1
[0063] Please see Figure 1 , Figure 1 This is a flowchart illustrating an image processing method for portrait beautification according to an exemplary embodiment, such as... Figure 1 As shown, the method includes:
[0064] Step S1: Perform skin region segmentation on texture A of the original image based on the previous and next frames to obtain texture B;
[0065] Step S2: Perform color cast correction on textures A and B to obtain the corrected texture D;
[0066] Step S3: Convert the texture D and the hintRGB color to the HSL space for skin tone adjustment, obtain the tendency color value resultRGB of the input pixel, and output the texture E1.
[0067] Based on texture E1, texture B and texture D, update texture E1 to obtain texture E2;
[0068] Steps S4 and 4.1 involve correcting the texture E2 to a linear space using Gamma to obtain texture F;
[0069] 4.2 Based on the color temperature value K, the light color (lightRGB) is obtained;
[0070] 4.3 The texture F and the lighting color lightRGB are mixed to obtain the corrected lighting color correctedLightedRGB, which is then output to obtain the texture G;
[0071] 4.4 The textures G and E2 are blended using texture B to obtain texture H;
[0072] 4.5 Soft blend the texture A and the texture H to obtain texture J.
[0073] It is understood that the technical solution provided in this embodiment first performs skin region segmentation on texture A of the original image based on the previous and next frames to obtain texture B. Then, color cast correction is performed on texture A and texture B to obtain the corrected texture D. Texture D and the heuristic color hintRGB are converted to HSL space for skin tone adjustment to obtain the hint color value resultRGB of the input pixel, and texture E1 is output. Based on texture E1, texture B, and texture D, texture E1 is updated to obtain texture E2. Then, texture E2 is corrected by Gamma to obtain texture F. Based on the color temperature value K, the illumination color lightRGB is obtained, and texture F is... The light color (lightRGB) is mixed with the corrected light color (correctedLightedRGB) and output to obtain texture G. Texture G and texture E2 are then mixed with texture B to obtain texture H. Finally, texture A and texture H are mixed with soft light to obtain texture J. The technical solution of this invention achieves the effect of seamless image and video overall by segmenting the skin area of consecutive frames. At the same time, color cast correction, skin tone adjustment, color tendency adjustment, and color temperature adjustment are used to make the skin tone have a cool white effect without the overall bluish-white effect, making the skin tone more transparent and natural.
[0074] In practice, the "skin region segmentation" step S1 can be implemented in several ways, including:
[0075] Skin region segmentation is performed on texture A of the input original image to obtain texture B; wherein, texture B is a single-channel 8-bit integer texture or a 16-bit half-floating-point precision texture.
[0076] Texture A is in YUV or RGB format.
[0077] It should be noted that there are multiple ways to implement skin region segmentation. Specifically, it can be achieved using deep learning network models, machine learning, or color images based on MATLAB. Currently, any skin region segmentation algorithm that meets real-time requirements can be used as an alternative to this module. However, depending on the accuracy of skin segmentation, different results will be achieved. In this invention, a self-developed deep learning network is used for skin region segmentation.
[0078] It should be noted that 16-bit half-floating precision textures and 8-bit integer textures can be interchanged. However, 16-bit half-floating precision textures require powerful device performance and memory, which places extremely high demands on the device. Therefore, considering device performance and memory, the output is an 8-bit integer texture.
[0079] It should be noted that the output texture value is directly proportional to the size of the skin region of that pixel. For example, the larger the output texture value, the greater the probability that the pixel is a skin region.
[0080] It's important to note that the method for obtaining texture B varies depending on the skin segmentation algorithm used. If it's obtained through deep learning or machine learning, it typically involves a pre-trained model that compresses the input texture to a fixed size before feeding it in. The model then performs calculations through layers of convolutions to determine the probability that a point is skin, ultimately outputting texture map B. If, due to platform limitations, performance constraints, or memory constraints, traditional image segmentation techniques are used, then each pixel of the input texture is typically converted to a specific color space for range determination. For example, it's determined whether the pixel lies within a pre-defined polygonal region within that color space. The result is then output as a probability value in texture B.
[0081] It should be noted that the embodiments of the present invention are applicable to real-time editing and previewing of images and videos, and can adapt to various lighting conditions and skin tones in real-world environments, while maintaining continuity between consecutive frames. If used in the field of real-time selfies, it may only require the previous frame.
[0082] In practice, the "color cast correction" step S2 can be implemented in several ways, including:
[0083] White balance correction is performed on texture A to obtain texture C;
[0084] Texture A and Texture C are color-corrected using Texture B to obtain Texture D, which is calculated as follows: D = A × (1.0 - B) + C × B.
[0085] It should be noted that this embodiment uses a self-developed color cast correction algorithm to correct potential color cast issues caused by factors such as ambient lighting, incorrect camera settings, and camera filters. In practice, the color cast correction algorithm in this embodiment can be replaced with algorithms such as the grayscale world algorithm, the perfect reflection algorithm, or the roll-up neural network model. Regarding the specific implementation of the color cast correction module, due to limitations in platform support, performance constraints, and application scenarios, different correction algorithms can be freely switched without affecting other parts of the algorithm flow in this embodiment. Of course, the final effect will vary slightly depending on the specific correction method selected.
[0086] It should be noted that machine learning has made significant progress in these traditional algorithm fields in recent years, so machine learning or deep learning solutions can also be used. Considering performance and the complexity of the lighting in the shooting scene, this embodiment uses a self-developed algorithm based on convolutional neural networks to perform white balance correction on texture A.
[0087] In practical application, step S3, "converting the texture D and the hintRGB color to the HSL space for skin tone adjustment to obtain the desired color value resultRGB of the input pixel, and outputting texture E1; updating texture E1 to obtain texture E2 based on texture E1, texture B, and texture D," can be implemented in several ways, specifically:
[0088] sourceHSL=rgb_to_hsl(sourceRGB);
[0089] hintHSL=rgb_to_hsl(hintRGB);
[0090] resultHSL.h = hintHSL.h;
[0091] resultHSL.s=sourceHSL.s×2.0;
[0092] resultHSL.l=sourceHSL.l+2.0×(hintHSL.l–0.5)×(sourceHSL.l×0.5+0.5);
[0093] resultRGB=hsl_to_rgb(resultHSL);
[0094] Here, rgb_to_hsl represents converting a certain RGB color value to an HSL color value; hsl_to_rgb represents converting a certain HSL color value to an RGB color value; hintHSL represents the coordinate values of hintRGB converted to HSL space using a color conversion formula; resultHSL represents the value of the resulting color in the HSL color space; resultHSL.h represents the h component value of the resulting color; resultHSL.s represents the s component value of the resulting color; resultHSL.l represents the l component value of the resulting color; and hsl_to_rgb represents converting an HSL color value back to an RGB color value.
[0095] The step of updating texture E1 to obtain texture E2 based on texture E1, texture B and texture D is specifically as follows: update texture E1 to obtain texture E2 based on texture D, texture B and texture E1, and the calculation formula is: E2=D×(1.0-B)+E1×B.
[0096] It should be noted that the reason for updating the texture value E2 is that the obtained skin tone adjustment result E1 is an adjustment made to the entire image. In order to avoid affecting non-skin areas, it is necessary to mix E1 and D through mask texture B to obtain E2. The image obtained by the technical solution in this embodiment will not be biased towards blue and white, and will be more realistic.
[0097] It should be noted that the inspiration color hintRGB is an RGB color value, which can be any legal color value, but is usually determined by designers or artists with relevant color theory knowledge through research and experimentation. In this embodiment, the RGB color value we ultimately adopted is: F5E15F1 (represented in industry-standard hexadecimal).
[0098] It should be noted that there are strict standard definitions and conversion formulas in color science for the rgb_to_hsl function and the hsl_to_rgb function. This invention will use these definitions and formulas without any additional modifications or changes, and they will not be elaborated on in this embodiment.
[0099] In practical application, step S4, "correcting the texture E2 to a linear space using Gamma to obtain texture F," can be implemented as follows:
[0100] The texture E2 is corrected to linear space using Gamma correction, specifically by applying the correction function corrected_x = x. 2.2 Then, make corrections.
[0101] In practical application, step S4, "obtaining the light color lightRGB based on the color temperature value K," can be implemented as follows:
[0102] Based on the color temperature value K of cool light, the light color (lightRGB) is obtained using the following formula:
[0103] lightRGB=xyz_to_srgb(temperature_to_xyz(K));
[0104] The `temperature_to_xyz` function converts color temperature values to the XYZ standard color space; the `xyz_to_srgb` function converts values in the XYZ color space to the sRGB color space. Both of these operations have clear definitions and conversion equations in color science. This invention will use these definitions and formulas without additional modifications or changes, and they will not be elaborated upon in this embodiment.
[0105] It should be noted that the color temperature value K is clearly defined in existing technologies. Theoretically, to achieve a cool, white skin effect, a high color temperature (i.e., greater than 6500K) is sufficient. This value can be freely chosen without affecting any other part of the algorithm. It can also be offered as an optional parameter for the user to select. In this embodiment, the specific color temperature value K used is within the range of 7800K to 8500K. This range is derived from practical experience, and within this average color temperature value, the skin will have a very good cool, white effect.
[0106] In practice, step S4, "mixing the texture F and the lighting color lightRGB to obtain the corrected lighting color correctedLightedRGB and outputting it to obtain the texture G," can be implemented in several ways, specifically:
[0107] After obtaining the light color lightRGB, each pixel in the texture F is recorded as originRGB and then mixed with the light color lightRGB.
[0108] Light blending formula: luma = dot(originRGB, vector3(0.3, 0.4, 0.3));
[0109] shadow=0.28+0.72×clamp(luma, 0.0, 1.0);
[0110] lightedRGB=originRGB×0.2+0.8×originRGB×lightRGB×shadow;
[0111] correctedLightedRGB=lightedRGB 0.4545 ;
[0112] The correctedLightedRGB is then used as the pixel output to obtain texture G;
[0113] The `dot` function performs a dot product of two vectors; `vector3` creates a 3D vector from the numbers within parentheses; and the `clamp` function truncates the vector if the first number is less than the second or greater than the third. The first, second, and third numbers represent the value to be processed, the minimum value, and the maximum value, respectively. The `clamp` function is a common computer function that takes three values as input, for example: `clamp(x, minVal, maxVal)`, where `x`, `minVal`, and `maxVal` represent the first, second, and third numbers, respectively. This function returns `minVal` if `x` is less than `minVal`; returns the current value of `x` if `x` is within the range [minVal, maxVal]; and returns `maxVal` if `x` is greater than `maxVal`.
[0114] In practice, in step S4, the texture G and texture E2 are mixed with texture B to obtain texture H, and the specific calculation formula is: H = E × (1.0 - B) + G × B.
[0115] Finally, texture A and texture H are blended with a soft light to obtain the final result texture J.
[0116] It's worth noting that Soft Light Mixing was invented by Adobe. Simply put, Soft Light Mixing is a method of blending the colors of two images to create a third image.
[0117] Example 2
[0118] Please see Figure 2 , Figure 2 This is a schematic block diagram illustrating an image processing system 200 for portrait beautification, as shown in an exemplary embodiment. Figure 2 As shown, the portrait beautification image processing system 200 includes:
[0119] The skin region segmentation module 201 is used to segment the skin region of the original image based on the texture A of the previous and next frames to obtain texture B;
[0120] The color cast correction module 202 is used to perform color cast correction on texture A and texture B to obtain the corrected texture D;
[0121] Skin tone adjustment module 203 is used to convert the texture D and the inspiration color hintRGB to the HSL space for skin tone adjustment, obtain the tendency color value resultRGB of the input pixel, and output texture E1;
[0122] Based on texture E1, texture B and texture D, update texture E1 to obtain texture E2;
[0123] The mixing module 204 is used to correct the texture E2 to a linear space using Gamma correction to obtain the texture F;
[0124] Based on the color temperature value K, the light color (lightRGB) is obtained;
[0125] The texture F and the lighting color lightRGB are mixed to obtain the corrected lighting color correctedLightedRGB, which is then output to obtain the texture G;
[0126] The textures G and E2 are blended using texture B to obtain texture H;
[0127] Texture A and texture H are blended using a soft light technique to obtain texture J.
[0128] It should be noted that since the implementation methods of each module in this embodiment can be found in the relevant description in Embodiment 1, this embodiment will not repeat them.
[0129] It is understood that the technical solution provided in this embodiment firstly involves the skin region segmentation module 201 performing skin region segmentation on texture A of the original image based on the preceding and following frames to obtain texture B. The color cast correction module 202 performs color cast correction on texture A and texture B to obtain the corrected texture D. The skin tone adjustment module 203 converts texture D and the hintRGB color to the HSL space for skin tone adjustment, obtaining the hint color value resultRGB of the input pixel, and outputs texture E1. Based on texture E1, texture B, and texture D, texture E1 is updated to obtain texture E2. The blending module 204 performs Gamma correction on texture E2 to obtain texture F, and then adjusts the texture based on the color temperature value... K is obtained as the light color lightRGB. The texture F and the light color lightRGB are mixed to obtain the corrected light color correctedLightedRGB, which is then output to obtain texture G. Texture G and texture E2 are mixed through texture B to obtain texture H. Finally, texture A and texture H are mixed with soft light to obtain texture J. The technical solution of this invention achieves the effect of not revealing the flaws in the overall image and video by segmenting the skin area of the previous and next frames. At the same time, color cast correction, skin tone adjustment, color tendency adjustment, and color temperature adjustment are used to make the skin tone have a cool white effect without the overall bluish-white effect, making the skin tone more transparent and natural.
[0130] The computer-readable storage media disclosed in this embodiment include, but are not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0131] It should be noted that since the implementation methods and beneficial effects of each module in this embodiment can be found in the relevant description in Embodiment 1, this embodiment will not repeat them here.
[0132] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0133] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0134] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0135] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0136] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0137] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.
[0138] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0139] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. An image processing method for portrait beautification, characterized in that, include: Step S1: Perform skin region segmentation on texture A of the original image based on the previous and next frames to obtain texture B; Step S2: Perform color cast correction on textures A and B to obtain the corrected texture D; Step S3: Convert the texture D and the hintRGB color to the HSL space for skin tone adjustment to obtain the desired color value resultRGB of the input pixel, and output texture E1, specifically: sourceHSL = rgb_to_hsl(sourceRGB); hintHSL = rgb_to_hsl(hintRGB); resultHSL.h = hintHSL.h; resultHSL.s = sourceHSL.s × 2.0; resultHSL.l = sourceHSL.l + 2.0 × (hintHSL.l – 0.5) × (sourceHSL.l ×0.5 + 0.5); resultRGB = hsl_to_rgb(resultHSL); Here, `rgb_to_hsl` represents converting a specific RGB color value to an HSL color value; `hsl_to_rgb` represents converting a specific HSL color value to an RGB color value; `hintHSL` represents the coordinate values of `hintRGB` converted to HSL space using a color conversion formula; `resultHSL` represents the value of the resulting color in the HSL color space; `resultHSL.h` represents the h component value of the resulting color; `resultHSL.s` represents the s component value of the resulting color; `resultHSL.l` represents the l component value of the resulting color; `hsl_to_rgb` represents converting an HSL color value back to an RGB color value; `sourceRGB` represents the input color value to be adjusted; `sourceHSL` represents the color value of `sourceRGB` converted to HSL space; `sourceHSL.s` represents the s component in `sourceHSL`; and `sourceHSL.l` represents the l component in `sourceHSL`. Based on texture E1, texture B and texture D, update texture E1 to obtain texture E2; Steps S4 and 4.1 involve correcting the texture E2 to a linear space using Gamma to obtain texture F; 4.2 Based on the color temperature value K, the light color (lightRGB) is obtained; 4.3 The texture F and the lighting color lightRGB are mixed to obtain the corrected lighting color correctedLightedRGB, which is then output to obtain the texture G; 4.4 The textures G and E2 are blended using texture B to obtain texture H; 4.5 Soft blend the texture A and the texture H to obtain texture J.
2. The method according to claim 1, characterized in that, The process of segmenting the skin region of texture A in the original image based on consecutive frames to obtain texture B is as follows: Skin region segmentation is performed on texture A of the input original image to obtain texture B; wherein, texture B is a single-channel 8-bit integer texture or a 16-bit half-floating-point precision texture.
3. The method according to claim 2, characterized in that, Also includes: The texture A is in YUV or RGB format.
4. The method according to claim 1, characterized in that, The process of correcting the color cast of textures A and B to obtain the corrected texture D is as follows: White balance correction is performed on texture A to obtain texture C; Texture A and Texture C are color-corrected using Texture B to obtain Texture D, which is calculated using the formula: D = A × (1.0 - B) + C × B.
5. The method according to claim 1, characterized in that, According to the texture E 1、 Textures B and D are used to update texture E1 to obtain texture E2, which is calculated as follows: E2 = D × (1.0 - B) + E1 × B.
6. The method according to claim 1, characterized in that, The process of obtaining the light color (lightRGB) based on the color temperature value (K) is as follows: Based on the color temperature value K of cool light, the light color (lightRGB) is obtained using the following formula: lightRGB = xyz_to_srgb(temperature_to_xyz(K)); The `temperature_to_xyz` function converts color temperature values to the XYZ standard color space; the `xyz_to_srgb` function converts values in the XYZ color space to the sRGB color space.
7. The method according to claim 6, characterized in that, The process of mixing the texture F and the lighting color lightRGB to obtain the corrected lighting color correctedLightedRGB and outputting it to obtain the texture G is as follows: After obtaining the light color lightRGB, each pixel in the texture F is recorded as originRGB and then mixed with the light color lightRGB. Light mixing formula: luma = dot(originRGB, vector3(0.3, 0.4, 0.3)); shadow = 0.28 + 0.72 × clamp(luma, 0.0, 1.0); lightedRGB = originRGB×0.2+0.8×originRGB×lightRGB×shadow; correctedLightedRGB = lightedRGB 0.4545 ; The correctedLightedRGB is then used as the pixel output to obtain texture G; The dot function represents the dot product of two vectors; vector3 represents the creation of a 3D vector from the numbers within parentheses.
8. The method according to claim 1, characterized in that, The process of blending texture G and texture E2 using texture B to obtain texture H is specifically calculated using the following formula: H = E ×(1.0 - B) + G ×B.
9. An image processing system for portrait beautification, characterized in that, include: The skin region segmentation module is used to segment the skin region of the original image based on the texture A of the previous and next frames to obtain texture B; A color cast correction module is used to perform color cast correction on textures A and B to obtain the corrected texture D. The skin tone adjustment module is used to convert the texture D and the inspiration color hintRGB to the HSL space for skin tone adjustment, obtain the tendency color value resultRGB of the input pixel, and output the texture E1, specifically: sourceHSL = rgb_to_hsl(sourceRGB); hintHSL = rgb_to_hsl(hintRGB); resultHSL.h = hintHSL.h; resultHSL.s = sourceHSL.s × 2.0; resultHSL.l = sourceHSL.l + 2.0 × (hintHSL.l – 0.5) × (sourceHSL.l ×0.5 + 0.5); resultRGB = hsl_to_rgb(resultHSL); Here, `rgb_to_hsl` represents converting a specific RGB color value to an HSL color value; `hsl_to_rgb` represents converting a specific HSL color value to an RGB color value; `hintHSL` represents the coordinate values of `hintRGB` converted to HSL space using a color conversion formula; `resultHSL` represents the value of the resulting color in the HSL color space; `resultHSL.h` represents the h component value of the resulting color; `resultHSL.s` represents the s component value of the resulting color; `resultHSL.l` represents the l component value of the resulting color; `hsl_to_rgb` represents converting an HSL color value back to an RGB color value; `sourceRGB` represents the input color value to be adjusted; `sourceHSL` represents the color value of `sourceRGB` converted to HSL space; `sourceHSL.s` represents the s component in `sourceHSL`; and `sourceHSL.l` represents the l component in `sourceHSL`. Based on texture E1, texture B and texture D, update texture E1 to obtain texture E2; The mixing module is used to correct the texture E2 to a linear space using Gamma correction to obtain texture F; Based on the color temperature value K, the light color (lightRGB) is obtained. The texture F and the lighting color lightRGB are mixed to obtain the corrected lighting color correctedLightedRGB, which is then output to obtain the texture G; The textures G and E2 are blended using texture B to obtain texture H; Texture A and texture H are blended using a soft light technique to obtain texture J.
Citation Information
Patent Citations
Skin color beautifying and correcting method and device
CN112541860A
Image processing method and device
CN113676715A