Skin color beautification correction method and device
By performing illumination compensation and skin color model segmentation during the image beautification process, combined with convex curve transformation and double sideband filtering technology, the problem of distortion and user operation complexity in skin area processing in the existing technology is solved, and natural skin whitening and smoothing are achieved. The effect improves the beauty of the image.
Patent Information
- Application Number
- CN201910900282.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-23
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2039-09-23
AI Technical Summary
Existing technology is difficult to effectively distinguish and process skin areas such as faces during the image beautification process, resulting in excessive background contrast or beautification distortion, and users need a long period of learning to achieve natural skin beautification.
By converting the image into YCbCr space, the mean values of Cb and Cr are obtained for illumination compensation, a skin color model is established for segmentation, whitening and smoothing are performed in sequence, and brightness and detail features are adjusted using convex curve transformation and double sideband filtering technology.
Effectively reduce missed detections and false detections, improve image beauty, achieve natural skin whitening and smoothing effects, and simplify user operations.
Smart Images

Figure CN112541860B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image and video processing, and in particular to a skin color beautification correction method and device. Background Art
[0002] Skin color beautification is a new application of image enhancement in the field of human life. Its main purpose is to detect the skin area in the image and perform beautification operations such as whitening and smoothing on the skin pixels. As people use more and more electronic digital products, such demand is also increasing. As the image resolution of products such as digital cameras and mobile phones is getting higher and higher, spots, moles, wrinkles and other problems on the skin area such as the face in high-resolution images are also clearly displayed. In order to improve the beauty of images and videos, there is a demand for beautification of the skin area.
[0003] In the existing technology, you can use camera software to select different camera modes, so as to whiten the skin or improve color contrast. However, this type of software will process the entire image, that is, the background of the image and the skin area will be beautified in the same way, which will cause a certain degree of distortion, or the background contrast is too strong, which will lose the beauty. In addition, you can use image beautification software to process the details of the photo, but this type of software requires relatively high skills to use, and users need to learn and practice for a long time to achieve the natural beautification of the skin area. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a skin color beautification correction method, comprising:
[0005] Convert the image from RGB space to YCbCr space, and obtain the Cb mean and Cr mean of the entire image;
[0006] When the difference between the Cb mean and the Cr mean exceeds a preset value, performing illumination compensation processing on the image;
[0007] Establishing a skin color model and performing skin color segmentation to determine the skin color area in the image;
[0008] The skin color area is subjected to skin color whitening and skin color smoothing processing in sequence.
[0009] Furthermore, performing illumination compensation processing on the image specifically includes:
[0010] Converting the image into a grayscale image;
[0011] Count the pixels of each gray value and arrange them from high to low gray values to get the average value of the top 5% of pixels;
[0012] Determine a lighting compensation coefficient according to the average gray value;
[0013] Multiply the original pixel value by the illumination compensation coefficient to obtain the pixel value after illumination compensation processing.
[0014] Further, the conversion of the image from the RGB space to the YCbCr space uses the following conversion formula:
[0015]
[0016] Further, the whitening process for the skin color specifically includes:
[0017] Use the convex curve transformation formula Y' = 255 (1-c) ×Y c Adjust the brightness value, where 0 < c < 1, Y is the brightness value before adjustment, Y' is the brightness value after adjustment, and ΔY = Y' - Y is the increment of the skin color brightness;
[0018] Utilize the invariant ratio relationship between the brightness and hue before and after adjustment Determine the increment ΔCr of Cr and the increment ΔCb of Cb;
[0019] Use the formulas Cb' = Cb + α × (128 - Cb) and Determine the skin color adjustment coefficients α and β;
[0020] When the skin color adjustment coefficients α and β simultaneously meet the preset conditions, the YCbCr parameter adjustment ends.
[0021] Further, the value of c in the convex curve transformation formula is 0.7; the convex curve transformation formula is Y' = 5.27 × Y 0.7 .
[0022] Further, the smoothing process for the skin color specifically includes:
[0023] Perform skin color detection on the whitened image to obtain the first binary image Skin1;
[0024] Perform skin color detection on the original image without whitening to obtain the second binary image Skin2;
[0025] Determine the spot area SpotMap = (1 - Skin2).*Skin1 in the image according to the first binary image Skin1 and the second binary image Skin2;
[0026] Perform bilateral filtering on the skin color part of the original image without whitening, and subtract the RGB values of the original image and the filtered image to obtain the detail image Idetail;
[0027] According to the spot area SpotMap, the whitened image is subjected to double-side band filtering to obtain a filtered image Ifilter;
[0028] The detailed features in the skin area are restored to obtain the whitened and smoothed image Ifinal = (1-skin2).*Idetail+Ifilter.
[0029] Furthermore, the skin color model is a skin color cluster ellipse model, and its formula is:
[0030]
[0031] In the formula, (ecx, ecy) represents the coordinates of the center of the ellipse, a and b represent the major and minor semi-axes of the ellipse respectively, θ represents the rotation angle of the ellipse model coordinates, x and y represent the rotated blue chromaticity component and red chromaticity component; Cb' and Cr' represent the blue chromaticity component and red chromaticity component; cx and cy represent control parameters; among which, cx=109.38, cy=152.02, θ=2.53, ecx=1.60, ecy=2.41, a=25.39, b=14.03.
[0032] Furthermore, in the process of skin color detection using the skin color clustering model, for different brightness Y values, the major and minor axes a and b of the ellipse are adaptively adjusted to improve the recognition rate of skin color pixels; when the brightness value Y is less than 40, there is no skin color pixel; when the brightness value Y is in the interval [40,900), the major and minor axes a and b of the ellipse are reduced to half of the constant; when the brightness value Y is in the interval [90,220], the major and minor axes a and b remain unchanged; when the brightness value Y is greater than 220, the major and minor axes of the ellipse are adjusted to 1.2 times of the constant.
[0033] The embodiment of the present invention further provides a skin color beautification correction device, comprising:
[0034] The conversion acquisition module is used to convert the image from RGB space to YCbCr space and obtain the Cb mean and Cr mean of the whole image;
[0035] A judgment processing module, used for performing illumination compensation processing on the image when the difference between the Cb mean value and the Cr mean value exceeds a preset value;
[0036] A modeling and segmentation module, used for establishing a skin color model and performing skin color segmentation to determine the skin color area in the image;
[0037] The skin color processing module is used to perform skin color whitening and skin color smoothing processing on the skin color area in sequence.
[0038] Furthermore, the skin color processing module whitens the skin color by:
[0039] Using the convex curve transformation formula Y' = 255 (1-c) ×Y c Adjust the brightness value, where 0 < c < 1, Y is the brightness value before adjustment, Y' is the brightness value after adjustment, and ΔY = Y' - Y is the increment of skin color brightness;
[0040] Using the unchanged ratio relationship between brightness and hue before and after adjustment Determine the increment ΔCr of Cr and the increment ΔCb of Cb;
[0041] Using the formulas Cb' = Cb + α×(128 - Cb) and Determine the skin color adjustment coefficients α and β;
[0042] When the skin color adjustment coefficients α and β simultaneously meet the preset conditions, the YCbCr parameter adjustment ends.
[0043] Further, in the convex curve transformation formula, the value of c is 0.7; the convex curve transformation formula is Y' = 5.27×Y 0.7 .
[0044] Further, the specific process of the skin color processing module for smoothing the skin color includes:
[0045] Perform skin color detection on the whitened image to obtain the first binary image Skin1;
[0046] Perform skin color detection on the original image without whitening to obtain the second binary image Skin2;
[0047] Determine the spot area SpotMap = (1 - Skin2).*Skin1 in the image according to the first binary image Skin1 and the second binary image Skin2;
[0048] Perform bilateral filtering on the skin color part of the original image without whitening, and subtract the RGB values of the original image and the filtered image to obtain the detail image Idetail;
[0049] Perform bilateral filtering on the whitened image according to the spot area SpotMap to obtain the filtered image Ifilter;
[0050] Restore the detailed features in the skin area to obtain the whitened and smoothed image Ifinal = 1 - skin2).*Idetail + Ifilter.
[0051] The embodiment of the present invention also provides a computer device, including: a memory and a processor;
[0052] The memory is used to store computer programs;
[0053] The processor is used to execute the steps of the above skin color beautification correction method when running the computer program.
[0054] The embodiment of the present invention further provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above skin color beautification correction method are implemented.
[0055] The present invention performs illumination compensation judgment before skin color detection, and can effectively reduce missed detection and false detection through illumination compensation. The skin color model is used to perform skin color segmentation to determine the skin color area in the image, and the skin color is whitened and smoothed, while non-skin color pixels still retain the original color and brightness information. Only the brightness and hue of the skin color pixels in the image are adjusted, thereby improving the overall aesthetics. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0057] Figure 1 A schematic diagram of a process of a skin color beautification correction method provided by an embodiment of the present invention;
[0058] Figure 2 A schematic diagram of the composition of a skin color beautification and correction device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Figure 1 The figure is a flow chart of a skin color beautification correction method provided by an embodiment of the present invention. The method comprises the following steps:
[0061] S101, converting the image from RGB space to YCbCr space, and obtaining the Cb mean value and Cr mean value of the entire image.
[0062] In this embodiment, the following conversion formula may be used to convert an image from RGB space to YCbCr space:
[0063] Other similar transformation methods may also be used in other embodiments.
[0064] S102: When the difference between the Cb mean value and the Cr mean value exceeds a preset value, performing illumination compensation processing on the image.
[0065] In order to accurately segment the skin color pixels from the image, it is necessary to judge the illumination conditions of the image to avoid false or missed skin color detection due to uneven illumination distribution. The surface of the object has a high brightness area caused by mirror reflection or interface reflection. This part reflects the color of the light source, not the actual color of the surface of the object, so there is a certain color deviation. For skin detection in the image, it is generally difficult to accurately find all skin pixels when the lighting conditions are poor. When there is a large difference in light on the same image, it will cause uneven illumination distribution on the face and other parts of the body, resulting in missed skin color detection. Therefore, before establishing the skin color model, illumination compensation processing is required. The detection of skin color areas is generally based on information such as skin color, so it is sensitive to illumination and will be affected by factors such as light source color, strength, and distribution. When the color tone is warm, it is easy to misdetect, and when the color tone is cold, it is easy to miss. First, it is necessary to determine whether the lighting conditions of the image require lighting compensation. The image needs to be converted from GRB space to YCbCr space, and the mean Cb and Cr values of the entire image need to be analyzed. When the difference between the two exceeds a certain threshold, it means that the blue chromaticity component and the red chromaticity component in the image are quite different, and there is a hue imbalance in the image, so lighting compensation processing is required.
[0066] The illumination compensation processing of the image may specifically include:
[0067] S1021, converting the image into a grayscale image.
[0068] Convert the image that needs to be compensated for illumination into a grayscale image.
[0069] S1022. Count the pixels of each gray value and arrange them from high to low gray values to obtain the average value of the top 5% of the pixels.
[0070] Count the number of pixels at each grayscale value, obtain the number of pixels in the top 5% of the grayscale order of the pixels in the image (the grayscale values are arranged from large to small) and the minimum grayscale value of this part. If the number of these pixels reaches a certain number, it means that there are a large number of pixels affected by the illumination deviation and illumination compensation is required. The minimum grayscale value is set as the critical grayscale value. For pixels whose grayscale values exceed the critical grayscale value, they are considered as reference points to adjust the color information of the entire image. It is necessary to calculate the RGB three-channel color average of the pixels exceeding the critical grayscale value. The average value is used. The sum of the RGB three-channel color values of the pixels exceeding the critical grayscale value is divided by the number of pixels exceeding the critical grayscale value to obtain the RGB three-channel color averages averageR, averageG and averageB.
[0071] S1023. Determine a light compensation coefficient according to the average value.
[0072] According to the average values of RGB channels averageR, averageG and averageB, the illumination compensation coefficients η of the RGB channels are obtained respectively. r , η g , η b .
[0073]
[0074] S1024: Multiply the original pixel value by the illumination compensation coefficient to obtain the pixel value after illumination compensation processing.
[0075] The RGB values of the original image are multiplied by the corresponding illumination compensation coefficients to obtain an RGB image after illumination compensation.
[0076] In other embodiments, other illumination compensation methods may also be used, such as GrayWorld color balancing algorithm.
[0077] S103: Establish a skin color model and perform skin color segmentation to determine the skin color area in the image.
[0078] Establish a skin color model and perform skin color segmentation. Establishing a skin color model is to find the skin color clustering area through statistical analysis in a color space with good skin color clustering, determine the model parameters, and then analyze each pixel in the image. According to whether it falls in the skin color clustering area, the pixel is judged as skin color or non-skin color. The skin color difference between different people is mainly affected by brightness, and is less affected by hue and saturation. Therefore, the image is mapped to the YCbCr space, the brightness Y component is separated, and a better skin color clustering model is formed mainly based on the Cb and Cr components.
[0079] The projection of skin color pixels in the YCbCr space is a spindle shape with a thick middle and pointed ends. That is, in places where the Y value is larger or smaller, the clustering of skin color in the CbCr plane shrinks significantly and the difference is large. Therefore, when segmenting skin color, the influence of different Y values needs to be considered.
[0080] The upper and lower limits are set for the Y value. Within the limit range, the brightness change has little effect on the skin color clustering, and the skin color can be determined only by the Cb and Cr values. In the part exceeding the limit, the clusters are described by trapezoidal geometry in the Y-Cb and Y-Cr planes. By stretching the scales of the Cb and Cr axes, the skin color clusters are columnar, and the shape of the skin color clusters does not change with the Y value.
[0081] For the upper and lower thresholds Kl and Kh of Y, the values are generally 125 and 188. In the part outside the upper and lower limits, the central axis of Cb and Cr and the width of the skin color area need to be corrected, and the Cb and Cr values of this part are linearly transformed according to the ratio of the skin color area width outside the range to the skin color area width within the limit.
[0082]
[0083] Among them, Y min and Y max are the minimum and maximum values of the brightness component in the skin color cluster, which are 16 and 255 respectively. cb (Y) and W cr (Y) is the width of the projection of the upper and lower limits of brightness in the Y-Cb and Y-Cr space, and the other constants are W cb =46.97,WL cb =23, WH cb =14,W cr =38.76, WL cr =20, WH cr =10
[0084] Thus, the nonlinear piecewise transformation formula is obtained:
[0085]
[0086] After nonlinear transformation, the projection of skin color point clusters on the Cb'-Cr' plane is similar to an ellipse, and the skin color model is a skin color cluster ellipse model, and its formula is:
[0087]
[0088] In the formula, (ecx, ecy) represents the coordinates of the center of the ellipse, a and b represent the major and minor semi-axes of the ellipse respectively, θ represents the rotation angle of the ellipse model coordinates, x and y represent the rotated blue chromaticity component and red chromaticity component; Cb' and Cr' represent the blue chromaticity component and red chromaticity component; cx and cy represent control parameters; among which, cx=109.38, cy=152.02, θ=2.53, ecx=1.60, ecy=2.41, a=25.39, b=14.03.
[0089] In the process of skin color detection performed by the skin color clustering model, for different brightness Y values, the major and minor axes a and b of the ellipse are adaptively adjusted to improve the recognition rate of skin color pixels; when the brightness value Y value is less than 40, there is no skin color pixel; when the brightness value Y value is in the interval [40,900), the major and minor axes a and b of the ellipse are reduced to half of the constant; when the brightness value Y value is in the interval [90,220], the major and minor axes a and b remain unchanged; when the brightness value Y value is greater than 220, the major and minor axes of the ellipse are adjusted to 1.2 times of the constant.
[0090] For each pixel in the entire image, the skin color model is used to determine whether it falls within the corresponding range. If it is within the range, the point is identified as a skin color pixel, otherwise it is a non-skin color pixel.
[0091] In this embodiment, the skin color clustering model uses an ellipse model. In other embodiments, the skin color clustering model may also use other skin color clustering models.
[0092] S104, performing skin color whitening and skin color smoothing processing on the skin color area in sequence.
[0093] Skin color beautification mainly includes skin color whitening and skin color smoothing. The skin color area is optimized and corrected. The background and other non-skin color points in the image or video will not be distorted in color or lose details. The skin color areas such as the face can be more beautiful after optimization.
[0094] In an image, skin color points and non-skin color points are adjacent, such as the lip position of a face. The outer edge of the lip may be judged as a skin color point or a non-skin color point. In order to avoid the unnatural transition between skin color and non-skin color caused by the optimization process, it is necessary to generate a beautification weight template so that the skin color area can achieve a gradual whitening effect. For the skin color pixel points of a picture, the weight is set to 1, and the weight value of the non-skin color pixel points at the junction of skin color and non-skin color is set between 0 and 1 to form a skin color template with a natural transition. For the weight value of this part, you can choose to determine it by means of mean or Gaussian distribution. The skin color template thus obtained has a weight value of 1 for the pixel points detected as skin color, and a weight of non-skin color pixel points within the skin color junction range between 0-1, and the weight is greater the closer to the skin color area. The weight of other non-skin color pixels is 0.
[0095] The skin color processing module performs whitening processing on the skin color, specifically including:
[0096] S1041, using the convex curve transformation formula Y' = 255 (1-c) ×Y c Adjust the brightness value, where Y is the brightness value before adjustment, Y' is the brightness value after adjustment, and ΔY=Y'-Y is the increment of skin color brightness.
[0097] The purpose of skin beautification is to brighten the skin color and get a fair and natural effect. By gradually increasing the brightness Y value, it is possible to avoid excessive enhancement of the skin color in the high or low parts, which would cause highlight distortion. x Convex curves gradually increase the Y value.
[0098] In this embodiment, the c value in the convex curve transformation formula is 0.7; the convex curve transformation formula is Y'=5.27×Y 0.7 The convex curve transformation formula has the best skin whitening effect. In other embodiments, the c value can take any value greater than 0 and less than 1; for example: when the c value in the convex curve transformation formula is 0.6; the corresponding convex curve transformation formula is Y′=9.18×Y. The c value in the convex curve transformation formula is 0.6; the convex curve transformation formula is Y'=9.18×Y 0.6 .
[0099] S1042, using the ratio of brightness and hue before and after adjustment to remain unchanged An increase ΔCr of Cr and an increase ΔCb of Cb are determined.
[0100] Regarding the adjustment of hue, in order to ensure that the brightness of the skin color is increased but the skin color is not distorted, it is necessary to ensure the proportional relationship between brightness and hue.
[0101] S1043, using the formula Cb'=Cb+α×(128-Cb) and Determine skin color adjustment coefficients α and β.
[0102] When the red component of the skin color of the image is high, Cr / Cb is greater than 1, and the increment of Cr ΔCr will become smaller. Among them, α and β are adjustment coefficients for skin color, which are used to control the required degree of whiteness and redness of skin color beautification.
[0103] S1044: When the skin color adjustment coefficients α and β simultaneously meet the preset conditions, the YCbCr parameter adjustment ends.
[0104] The skin color processing module performs smoothing processing on the skin color, specifically including:
[0105] S1051 . Perform skin color detection on the whitened image to obtain a first binary image Skin1 .
[0106] Skin color detection is performed on the image Iwhite that has been whitened. The range of the ellipse model is expanded to a certain extent so that spots, moles and other defects that are close to the skin color can be detected, and a binary image Skin1 is obtained. The Skin1 binary image includes spots as much as possible, and the spot and skin color values are both 1, and the background is 0.
[0107] S1052: Perform skin color detection on the original image that has not been whitened to obtain a second binary image Skin2.
[0108] Skin color detection is performed on the original image I, and the range of the ellipse model is reduced to a certain extent, so that spots, moles and other defects that are different from the skin color are not detected, and a binary image Skin2 is obtained. The Skin2 binary image does not include spots as much as possible, that is, the skin color area value is 1, the spot area value is 0, and the background is 0.
[0109] S1053 . Determine a spot area SpotMap=(1-Skin2).*Skin1 in the image according to the first binary image Skin1 and the second binary image Skin2 .
[0110] Correspondingly, spots=(1-0)*1=1, skin color=(1-1)*1=0, background=(1-0)*0=0.
[0111] S1054, performing double-sideband filtering on the skin color part of the original image that has not been whitened, and subtracting the RGB values of the original image from the image after the filtering process to obtain a detail image Idetail.
[0112] The kernel function of the double-sideband filter takes into account both the pixel difference and the spatial distance relationship, thus filtering the skin area while protecting the edge of the skin color area.
[0113] Double-sideband filter kernel function
[0114] Among them, w represents the weight, f is the pixel value, (i, j) is all the elements in the window with (x, y) as the center and r as the radius, σ d Controls the influence of the pixel difference between the neighboring point and the current point on filtering, σ r Controls the influence of the spatial distance between the neighborhood point and the current point on filtering.
[0115] S1055, performing double-sideband filtering on the whitened image according to the spot area SpotMap to obtain a filtered image Ifilter;
[0116] S1056. Restore the detailed features in the skin area to obtain the whitened and smoothed image Ifinal = (1 - skin2).*Idetail + Ifilter.
[0117] The smoothing process of the skin color is based on the RGB image.
[0118] Figure 2 The embodiment of the present invention further provides a skin color beautification and correction device, including:
[0119] A conversion and acquisition module, configured to convert the image from the RGB space to the YCbCr space and acquire the Cb mean value and the Cr mean value of the entire image;
[0120] A judgment and processing module, configured to perform light compensation processing on the image when the difference between the Cb mean value and the Cr mean value exceeds a preset value;
[0121] A modeling and segmentation module, configured to establish a skin color model and perform skin color segmentation to determine the skin color area in the image;
[0122] A skin color processing module, configured to sequentially perform skin color whitening and skin color smoothing processing on the skin color area.
[0123] The specific steps for the skin color processing module to whiten the skin color include:
[0124] Use the convex curve transformation formula Y' = 255 (1-c) ×Y c Adjust the brightness value, where 0 < c < 1, Y is the brightness value before adjustment, Y' is the brightness value after adjustment, and ΔY = Y' - Y is the increment of the skin color brightness; the c value in the convex curve transformation formula is preferably 0.7; the corresponding convex curve transformation formula is Y' = 5.27×Y 0.7 .
[0125] Use the unchanged proportional relationship between the brightness and hue before and after adjustment Determine the increment ΔCr of Cr and the increment ΔCb of Cb;
[0126] Use the formulas Cb' = Cb + α×(128 - Cb) and Determine the skin color adjustment coefficients α and β;
[0127] When the skin color adjustment coefficients α and β simultaneously meet the preset conditions, the YCbCr parameter adjustment ends.
[0128] The specific steps for the skin color processing module to smooth the skin color include:
[0129] Perform skin color detection on the whitened image to obtain the first binary image Skin1;
[0130] Perform skin color detection on the original image that has not been whitened to obtain a second binary image Skin2;
[0131] Determine the spot area SpotMap in the image according to the first binary image Skin1 and the second binary image Skin2 = (1-Skin2).*Skin1;
[0132] Double-side band filtering is performed on the skin color part of the original image that has not been whitened, and the detail image Idetail is obtained by subtracting the RGB values of the original image from the image after filtering.
[0133] According to the spot area SpotMap, the whitened image is subjected to double-side band filtering to obtain a filtered image Ifilter;
[0134] Restore the detailed features in the skin area to obtain the whitened and smoothed image Ifinal=1-skin2)*Idetail+Ifilter.
[0135] It should be noted that: the skin color beautification correction device provided in the above embodiment only uses the division of the above program modules as an example when performing correction. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the skin color beautification correction device provided in the above embodiment and the skin color beautification correction method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment. The beneficial effects are the same as the method embodiment and will not be repeated here.
[0136] The embodiment of the present invention further provides a computer device, comprising: a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the steps of the skin color beautification correction method of the present invention when running the computer program.
[0137] The embodiment of the present invention further provides a computer storage medium, which is a computer-readable storage medium, on which a computer program is stored, and the computer program can be executed by a processor of a computer device to complete the steps of the aforementioned skin color beautification correction method. The computer-readable storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM).
[0138] In the several embodiments provided by the present invention, it should be understood that the disclosed methods and intelligent devices can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0139] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0140] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A skin color beautification correction method, characterized in that: include: Convert the image from RGB space to YCbCr space and obtain the Cb mean and Cr mean of the entire image; When the difference between the Cb mean and the Cr mean exceeds a preset value, performing illumination compensation processing on the image; Establishing a skin color model and performing skin color segmentation to determine the skin color area in the image; performing skin color whitening and skin color smoothing processing on the skin color area in sequence; The skin color smoothing process specifically includes: Perform skin color detection on the whitened image to obtain the first binary image Skin1; Perform skin color detection on the original image that has not been whitened to obtain the second binary image Skin2; Determine the spot area SpotMap=(1-Skin2).*Skin1 in the image according to the first binary image Skin1 and the second binary image Skin2; Double-side band filtering is performed on the skin color part of the original image that has not been whitened, and the RGB values of the original image and the filtered image are subtracted to obtain the detail image Idetail; According to the spot area SpotMap, the whitened image is subjected to double-side band filtering to obtain a filtered image Ifilter; The detailed features in the skin area are restored to obtain the whitened and smoothed image Ifinal = (1-Skin2).*Idetail+Ifilter.
2. The method according to claim 1, characterized in that Performing illumination compensation processing on the image specifically includes: Converting the image into a grayscale image; Count the pixels of each grayscale value and arrange them from high to low grayscale values to get the average value of the top 5% of pixels; Determine the illumination compensation coefficient according to the average gray value; Multiply the original pixel value by the illumination compensation coefficient to obtain the pixel value after illumination compensation.
3. The method according to claim 1, characterized in that The skin color whitening treatment specifically includes: Using the convex curve transformation formula Y' = 255 (1-c) ×Y c Adjust the brightness value, where 0 < c < 1, Y is the brightness value before adjustment, Y' is the brightness value after adjustment, and ΔY = Y' - Y is the increment of skin color brightness; The ratio of brightness and hue remains unchanged before and after adjustment Determine the increment ΔCr of Cr and the increment ΔCb of Cb; Using the formula Cb'=Cb+α×(128-Cb) and Determine skin color adjustment coefficients α and β; When the skin color adjustment coefficients α and β simultaneously meet the preset conditions, the YCbCr parameter adjustment is completed.
4. The method according to claim 3, characterized in that The c value in the convex curve transformation formula is 0.7; the convex curve transformation formula is Y'=5.27×Y 0.7 .
5. The method according to claim 1, wherein The skin color model is a skin color cluster ellipse model, and its formula is: In the formula, (ecx, ecy) represents the coordinates of the center of the ellipse, a and b represent the major and minor semiaxes of the ellipse respectively, θ represents the rotation angle of the ellipse model coordinates, x and y represent the rotated blue and red chromaticity components; Cb' and Cr' represent the blue and red chromaticity components; cx and cy represent control parameters; among them, cx = 109.38, cy = 152.02, θ = 2.53, ecx = 1.60, ecy = 2.41, a = 25.39, b = 14.
03.
6. The method according to claim 5, characterized in that In the process of skin color detection using the skin color clustering ellipse model, for different brightness Y values, the major and minor axes a and b of the ellipse are adaptively adjusted to improve the recognition rate of skin color pixels; when the brightness value Y value is less than 40, there are no skin color pixels; when the brightness value Y value is in the interval [40,900), the major and minor axes a and b of the ellipse are reduced to half of the constant; when the brightness value Y value is in the interval [90,220], the major and minor axes a and b remain unchanged; when the brightness value Y value is greater than 220, the major and minor axes of the ellipse are adjusted to 1.2 times the constant.
7. A skin color beautification and correction device, characterized in that: include: The conversion acquisition module is used to convert the image from RGB space to YCbCr space and obtain the Cb mean and Cr mean of the entire image; a judgment processing module, configured to perform illumination compensation processing on the image when the difference between the Cb mean value and the Cr mean value exceeds a preset value; A modeling and segmentation module, used for establishing a skin color model and performing skin color segmentation to determine the skin color area in the image; The skin color processing module is used to perform skin color whitening and skin color smoothing processing on the skin color area in sequence; the skin color processing module performs skin color smoothing processing specifically including: Perform skin color detection on the whitened image to obtain the first binary image Skin1; Perform skin color detection on the original image that has not been whitened to obtain the second binary image Skin2; Determine the spot area SpotMap=(1-Skin2).*Skin1 in the image according to the first binary image Skin1 and the second binary image Skin2; Double-side band filtering is performed on the skin color part of the original image that has not been whitened, and the RGB values of the original image and the filtered image are subtracted to obtain the detail image Idetail; According to the spot area SpotMap, the whitened image is subjected to double-side band filtering to obtain a filtered image Ifilter; The detailed features in the skin area are restored to obtain the whitened and smoothed image Ifinal = (1-Skin2).*Idetail+Ifilter.
8. The device according to claim 7, characterized in that The skin color processing module whitens the skin color by: Using the convex curve transformation formula Y' = 255 (1-c) ×Y c Adjust the brightness value, where 0 < c < 1, Y is the brightness value before adjustment, Y' is the brightness value after adjustment, and ΔY = Y' - Y is the increment of skin color brightness; The ratio of brightness and hue remains unchanged before and after adjustment Determine the increment ΔCr of Cr and the increment ΔCb of Cb; Using the formula Cb'=Cb+α×(128-Cb) and Determine skin color adjustment coefficients α and β; When the skin color adjustment coefficients α and β simultaneously meet the preset conditions, the YCbCr parameter adjustment is completed.
