Image skin color adjustment method, device, medium and equipment

By seizing the RGB image of the skin area in the face image of the ID photo and converting it into a LAB image, calculating the mean difference of each component and constructing a quadratic function, adjusting the L, A, and B components, solving the problems of gray and details loss in the image when adjusting the average skin color of the ID photo face in the existing technology, achieving high-quality skin color adjustment effect.

CN116468630BActive Publication Date: 2025-06-06CHANGSHA XIONGDI XINAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310391995.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2025-06-06
Estimated Expiration
2043-04-12

AI Technical Summary

Technical Problem

In the prior art, when adjusting the average skin color of the face of the ID photo, when the original photo LAB component value is largely deviating from the preset range, the output image is prone to graying, loss of details, discoloration, and distortion.

Method used

By seizing the RGB image of the skin area in the face image and converting it into a LAB image, the mean difference of each component is calculated, and a preset quadratic function is constructed based on these mean difference values, and the L, A, and B components in the LAB image are mapped and adjusted respectively to achieve the purpose of skin color adjustment.

Benefits of technology

It effectively avoids graying and details loss, retains bright details, and avoids obvious changes in the hue of the white area, ensuring the authenticity and quality of the output image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116468630B_ABST
    Figure CN116468630B_ABST
Patent Text Reader

Abstract

The present invention discloses an image skin color adjustment method, device, medium and equipment. First, the first RGB image in the skin area is converted into a first LAB image. Then, the mean difference of each component is calculated. Then, based on the first mean difference, a preset first quadratic function is constructed in the first histogram, and the L component of the pixel point in the first LAB image is mapped and adjusted using the first quadratic function; the adjustment amount of the first quadratic function to the L center area is greater than the adjustment amount to the L non-center area, which can well retain the bright details and avoid gray haze. At the same time, based on the second mean difference, a preset second quadratic function is constructed in the second histogram, and the A component of the pixel point in the first LAB image is mapped and adjusted using the second quadratic function. The second quadratic function can avoid obvious changes in the hue of the white area. The B component adjustment is consistent with the A component adjustment. Finally, the adjusted first LAB image is used as the second LAB image and converted into a second RGB image, thereby completing the skin color adjustment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to an image skin color adjustment method, device, medium and equipment. Background Art

[0002] Self-service photo taking equipment is a convenient ID tool that allows people to take their own ID photos. However, the imaging effect of ID photos, especially the average skin color of the face, must be within a certain range. If the skin color deviates from the standard, the ID photo cannot be used.

[0003] In order to solve this problem, the existing technical solution is to add or subtract the same value on the LAB color component so that the color component of the resulting image meets the preset range. However, this method also has defects. When the LAB component value of the original photo deviates greatly from the preset range, the output image will appear gray, lose details, discolor, distorted and other problems. Summary of the invention

[0004] Based on this, it is necessary to provide image skin color adjustment methods, devices, media and equipment to solve the problems of grayness, loss of details, discoloration, distortion, etc. in the output image when the LAB component value of the original photo deviates greatly from the preset range.

[0005] A method for adjusting skin color of an image, the method comprising:

[0006] intercepting a first RGB image in a skin area from the face image before skin color adjustment, and converting the first RGB image into a first LAB image;

[0007] In the first LAB image, a first mean difference is calculated based on the L components of all pixels, a second mean difference is calculated based on the A components of all pixels, and a third mean difference is calculated based on the B components of all pixels; wherein the mean difference indicates the difference between the component mean of all pixels in the same channel and the corresponding preset standard deviation;

[0008] Counting a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image; wherein the adjustment amount of the first quadratic function on the L central area is greater than the adjustment amount on the L non-central area, and the component covered by the central area is between the components covered by the non-central area;

[0009] Counting a second histogram of the first LAB image on the A component, constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; wherein the adjustment amount of the second quadratic function on the central area of ​​A is less than the adjustment amount on the non-central area of ​​A;

[0010] Counting a third histogram of the first LAB image on the B component, constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel point in the first LAB image; wherein the adjustment amount of the third quadratic function on the B central area is less than the adjustment amount on the B non-central area;

[0011] The first LAB image after mapping and adjusting the L component, the A component and the B component is used as the second LAB image, and the second LAB image is converted into a second RGB image to obtain a face image after skin color adjustment.

[0012] In one embodiment, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image includes:

[0013] Obtaining a starting value and an ending value on the first histogram; wherein the starting value is the lowest brightness value of the largest continuous interval in the first histogram, and the ending value is the highest brightness value of the largest continuous interval in the first histogram, and the largest continuous interval is the continuous interval with the largest number of pixels in the first histogram;

[0014] Selecting a plurality of first reference points passed by the first quadratic function on the first histogram according to the first mean difference, the starting value, and the ending value, and solving coefficients in the first quadratic function based on coordinates of the plurality of first reference points;

[0015] If the L component of the first pixel point is not within the range between the starting value and the ending value, the L component of the first pixel point is kept unchanged; wherein the first pixel point is any pixel point in the first LAB image;

[0016] If the L component of the first pixel point is within the range between the starting value and the ending value, the L component of the first pixel point is mapped and adjusted using the solved first quadratic function.

[0017] In one embodiment, selecting a plurality of first reference points passed by the first quadratic function on the first histogram according to the first mean difference, the starting value, and the ending value includes:

[0018] If ΔL≥0, then let:

[0019]

[0020] If ΔL<0, then let:

[0021]

[0022] In the above formula, He is the end value, Hs is the start value, n1, n2, n3 are preset coefficients, E and S are the zero point coordinates of the reference point, A1, B1, C1 are the first reference points, and ΔL is the first mean difference.

[0023] In one embodiment, constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel point in the first LAB image includes:

[0024] Selecting a plurality of second reference points passed by the second quadratic function on the second histogram according to any preset interval and the second mean difference, and solving coefficients in the second quadratic function based on coordinates of the plurality of second reference points;

[0025] If the A component of the second pixel point is not within the range of all preset intervals, adding the second mean difference to the A component of the second pixel point; wherein the second pixel point is any pixel point in the first LAB image;

[0026] If the A component of the second pixel point is within a preset interval, the A component of the second pixel point is mapped and adjusted using the solved second quadratic function.

[0027] In one embodiment, the formula for selecting the second reference point is:

[0028] If S 2 =X1,E 2 =X2, then:

[0029]

[0030] If S 2 =X2,E 2 =X3, then:

[0031]

[0032] In the above formula, E 2 and S 2 is the preset value, X1<X2<X3; if S 2 =X1,E2 =X2, then (S 2 *2-E 2 , E 2 ) is the preset interval; if S 2 =X2,E 2 =X3, then (S 2 , E 2 *2-S 2 ) is a preset interval; A2, B2, C2, A3, B3, C3 are second reference points, and ΔA is the second mean difference.

[0033] In one embodiment, constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel point in the first LAB image includes:

[0034] Selecting a plurality of third reference points passed by the third quadratic function on the third histogram according to any preset interval and the third mean difference, and solving coefficients in the third quadratic function based on coordinates of the plurality of third reference points;

[0035] If the B component of the third pixel point is not within the range of all preset intervals, adding the third mean difference to the B component of the third pixel point; wherein the third pixel point is any pixel point in the first LAB image;

[0036] If the B component of the third pixel point is within the range of the preset interval, the B component of the third pixel point is mapped and adjusted using the solved third quadratic function.

[0037] In one embodiment, the formula for selecting the third reference point is:

[0038] If S 3 =X4,E 3 =X5, then:

[0039]

[0040] If S 3 =X5,E 3 =X6, then:

[0041]

[0042] In the above formula, E 3 and S 3 is the preset value, X4<X5<X6; if S 3 =X4,E 3 =X5, then (S 3 *2-E 3 , E3 ) is the preset interval; if S 3 =X5,E 3 =X6, then (S 3 , E 3 *2-S 3 ) is a preset interval; A4, B4, C4, A5, B5, C5 are third reference points, and ΔB is the third mean difference.

[0043] An image skin color adjustment device, the device comprising:

[0044] A first conversion module, configured to capture a first RGB image in a skin area from a face image before skin color adjustment, and convert the first RGB image into a first LAB image;

[0045] A preprocessing module, configured to calculate, in the first LAB image, a first mean difference according to the L components of all pixels, a second mean difference according to the A components of all pixels, and a third mean difference according to the B components of all pixels; wherein the mean difference indicates a difference between a component mean of all pixels in the same channel and a corresponding preset standard deviation;

[0046] An L component adjustment module, used for counting a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image; wherein the adjustment amount of the first quadratic function on the L central area is greater than the adjustment amount on the L non-central area, and the component covered by the central area is between the components covered by the non-central area;

[0047] An A component adjustment module, configured to calculate a second histogram of the first LAB image on the A component, construct a preset second quadratic function in the second histogram based on the second mean difference, and use the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; wherein the adjustment amount of the second quadratic function for the A central area is less than the adjustment amount for the A non-central area;

[0048] A B component adjustment module, configured to count a third histogram of the first LAB image on the B component, construct a preset third quadratic function in the third histogram based on the third mean difference, and use the third quadratic function to map and adjust the B component of the pixel point in the first LAB image; wherein the adjustment amount of the third quadratic function on the B central area is less than the adjustment amount on the B non-central area;

[0049] The second conversion module is used to use the first LAB image after mapping and adjusting the L component, the A component and the B component as the second LAB image, and convert the second LAB image into a second RGB image to obtain a face image after skin color adjustment.

[0050] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above-mentioned image skin color adjustment method.

[0051] An image skin color adjustment device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned image skin color adjustment method.

[0052] The present invention provides an image skin color adjustment method, device, medium and equipment. First, a first RGB image in the skin area of ​​a face image is intercepted, and the first RGB image is converted into a first LAB image. Then, the mean difference of each component is calculated. Then, a preset first quadratic function is constructed in the first histogram based on the first mean difference, and the L component of the pixel point in the first LAB image is mapped and adjusted using the first quadratic function; wherein, the adjustment amount of the first quadratic function to the L central area is greater than the adjustment amount of the L non-central area, and the component covered by the central area is between the components covered by the non-central area. Through the mapping adjustment of the first quadratic function, the bright details can be well preserved and gray haze can be avoided. At the same time, a preset second quadratic function is constructed in the second histogram based on the second mean difference, and the A component of the pixel point in the first LAB image is mapped and adjusted using the second quadratic function; wherein, the adjustment amount of the second quadratic function to the A central area is less than the adjustment amount of the A non-central area; through the second quadratic function, the hue of the white area can be avoided from changing significantly. The adjustment method of the B component is consistent with the adjustment method of the A component. Finally, the first LAB image after mapping and adjusting the L component, A component and B component is used as the second LAB image, and the second LAB image is converted into a second RGB image to obtain a face image after skin color adjustment. It can be seen that the present invention adopts a targeted adjustment method to solve the problems of gray, detail loss, color change, distortion, etc. in the output image when the LAB component value of the original photo deviates greatly from the preset range. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] 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.

[0054] in:

[0055] Figure 1 is a schematic flow chart of a method for adjusting skin color of an image in one embodiment;

[0056] Figure 2 A schematic diagram of a process for constructing a first quadratic function in one embodiment;

[0057] Figure 3 is a schematic diagram of a first histogram in one embodiment;

[0058] Figure 4 A schematic diagram of a process for constructing a second quadratic function in one embodiment;

[0059] Figure 5 A schematic diagram of a process for constructing a third quadratic function in one embodiment;

[0060] Figure 6 is a schematic diagram of the structure of an image skin color adjustment device in one embodiment;

[0061] Figure 7 FIG. 4 is a structural block diagram of an image skin color adjustment device in one embodiment. DETAILED DESCRIPTION

[0062] 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.

[0063] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0064] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0065] like Figure 1 As shown, Figure 1 FIG. 1 is a flow chart of a method for adjusting skin color of an image in an embodiment. The steps provided by the method for adjusting skin color of an image in this embodiment include:

[0066] S101, capturing a first RGB image in a skin area from a face image before skin color adjustment, and converting the first RGB image into a first LAB image.

[0067] Specifically, the first RGB image is obtained by first intercepting it through the following steps:

[0068] First, obtain the key points of the face.

[0069] First, the face image (usually including the neck or other background interference items) is analyzed through a deep learning-based algorithm to calibrate the key points of the face, including the eyes, nose, mouth and other key parts. Specifically, a face key point detection algorithm based on a convolutional neural network (CNN), such as MTCNN, can be used, or other existing algorithms, which will not be given as examples.

[0070] Second: remove the non-skin color part, the first RGB image in the skin area.

[0071] Next, according to the detected positions of the key points of the face, the non-skin color parts are removed, including the eyes, nostrils, mouth and other parts. Furthermore, the face image can be divided into multiple small blocks, and the skin color value of each small block is calculated, and a skin color detection algorithm based on a color space model, such as YCbCr, HSV, etc., is used. If the skin color value of the small block is significantly different from the average skin color value of the face area, the small block is further regarded as a non-skin color part. In this way, the skin area in the face image can be selected to obtain the first RGB image.

[0072] The first RGB image obtained in this way only contains the skin color part of the face, which can improve the accuracy and stability of face recognition.

[0073] The RGB image here is an image format that uses three color channels, red (R), green (G), and blue (B), to represent colors. In an RGB image, each pixel consists of intensity values ​​of three channels, representing the intensity of red, green, and blue.

[0074] LAB image is an image format that separates the color space into brightness (L) and chrominance (A and B) channels. LAB color space is a device-independent color space that can describe all possible colors. In LAB images, the L channel represents brightness, A includes colors from dark green to gray to bright pink; B ranges from bright blue to gray to yellow. Compared with RGB images, LAB images are more suitable for image processing and computer vision applications because they separate the brightness and chrominance of colors, making color information easier to understand and process. Since this conversion method is a prior art, it will not be described in detail.

[0075] S102, in the first LAB image, a first mean difference is calculated according to the L components of all the pixels, a second mean difference is calculated according to the A components of all the pixels, and a third mean difference is calculated according to the B components of all the pixels.

[0076] The mean difference indicates the difference between the component mean of all pixels in the same channel and the corresponding preset standard deviation. For example, the calculation of the first mean difference is taken as an example:

[0077]

[0078] ΔL=L src -L0

[0079] In the above formula, L src Indicates the L component mean of all pixels in the L channel, M indicates the total number of pixels, L i indicates the L component of the i-th pixel, ΔL indicates the first mean difference, and L0 indicates the preset standard deviation of the L channel.

[0080] The calculation method of the second mean difference ΔA and the third mean difference ΔB is the same as the calculation method of the first mean difference, and will not be described in detail.

[0081] S103, counting a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image.

[0082] The adjustment amount of the first quadratic function to the L center area is greater than the adjustment amount of the L non-center area, and the components covered by the center area are between the components covered by the non-center area. The specific range of the L center area can be set according to actual conditions. For example, it is set to start from a certain center line, and the area with an increase or decrease of 30 components is the center area, and the rest is the non-center area. Through the mapping adjustment of the first quadratic function, the bright details can be well preserved and gray haze can be avoided.

[0083] In a specific embodiment, Figure 2 As shown, the first quadratic function is constructed and mapping adjustment is performed through the following steps;

[0084] S1031, obtain the starting value and ending value on the first histogram.

[0085] The starting value is the lowest brightness value of the largest continuous interval in the first histogram, and the ending value is the highest brightness value of the largest continuous interval in the first histogram. The largest continuous interval is the continuous interval with the largest number of pixels in the first histogram. Figure 3 As shown, Figure 3 This is an example of the first histogram to be counted. First, the maximum continuous interval in the first histogram is determined. Since the number of continuous pixels in area B is the largest, area B is determined to be the maximum continuous interval. Further, b1 is used as the starting value and b2 is used as the ending value.

[0086] S1032: Select multiple first reference points that the first quadratic function passes through on the first histogram according to the first mean difference, the starting value and the ending value, and solve the coefficients in the first quadratic function based on the coordinates of the multiple first reference points.

[0087] In order to achieve differential adjustment, a quadratic function is constructed here, that is, y = ax 2 +bx+c(a≠0), of course, it can also be set to other functions according to needs, such as step function.

[0088] Optionally, the first reference point can be selected in the following way:

[0089] If ΔL≥0, then let:

[0090]

[0091] If ΔL<0, then let:

[0092]

[0093] In the above formula, He is the end value, Hs is the start value, n1, n2, n3 are preset coefficients, E and S are the zero point coordinates of the reference point, A1, B1, C1 are the first reference points, and ΔL is the first mean difference.

[0094] The following is an example of a practical application. Of course, you can also adjust the coefficients yourself:

[0095] If ΔL≥0, then let:

[0096]

[0097] If ΔL<0, then let:

[0098]

[0099] Then substitute the coordinates of A1, B1, and C1 calculated above into the quadratic function y=ax 2 +bx+c(a≠0) to calculate the coefficients a, b, c.

[0100] S1033: If the L component of the first pixel point is not within the range between the start value and the end value, the L component of the first pixel point is kept unchanged.

[0101] The first pixel is any pixel in the first LAB image, that is, the same operation is performed on all pixels in the first LAB image. It can be seen that the range between the start value and the end value here can also be understood as the range of the central area.

[0102] S1034: If the L component of the first pixel point is within the range between the starting value and the ending value, use the solved first quadratic function to map and adjust the L component of the first pixel point.

[0103] Therefore, S1033-S1034 can be expressed as:

[0104] L_dist=Li(Li≤Hs or L i ≥He)

[0105] L dist =L i +aL i 2 +bL i +c(Hs≤L i ≤He)

[0106] In the above formula, L_dist is the L component after mapping.

[0107] S104, counting a second histogram of the first LAB image on the A component, constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel points in the first LAB image.

[0108] The adjustment amount of the second quadratic function for the central area A is less than the adjustment amount for the non-central area A. Similarly, the range of the central area A can be set according to actual conditions. The second quadratic function can avoid obvious changes in the hue of the white area.

[0109] In a specific embodiment, Figure 4 As shown, the second quadratic function is constructed and mapping adjustment is performed through the following steps;

[0110] S1041: Select multiple second reference points that the second quadratic function passes through on the second histogram according to any preset interval and the second mean difference, and solve the coefficients of the second quadratic function based on the coordinates of the multiple second reference points.

[0111] Optionally, the second reference point can be selected in the following way:

[0112] If S 2 =X1,E 2 =X2, then:

[0113]

[0114] If S 2 =X2,E 2 =X3, then:

[0115]

[0116] In the above formula, E 2 and S 2 is the preset value, X1<X2<X3; if S 2 =X1,E 2 =X2, then (S 2 *2-E 2 , E 2 ) is the preset interval; if S 2 =X2,E 2 =X3, then (S 2 , E 2 *2-S 2 ) is a preset interval; A2, B2, C2, A3, B3, C3 are second reference points, and ΔA is the second mean difference.

[0117] The following is an example of a practical application. Of course, you can also adjust the coefficients yourself:

[0118] If S 2 =-20, E 2 =0, then:

[0119]

[0120] If S 2 =0,E 2 =20, then:

[0121]

[0122] Then substitute the three points A2, B2, and C2 obtained from the above calculation into the quadratic function y=a1x 2 +b1x+c1(a1≠0), to calculate the coefficients a1, b1, c1.

[0123] Or, substitute the three points A3, B3, and C3 obtained from the above calculation into the quadratic function y=a2x 2 +b2x+c2(a2≠0), to calculate the coefficients a2, b2, c2.

[0124] S1042: If the A component of the second pixel point is not within the range of all preset intervals, add the second mean difference to the A component of the second pixel point.

[0125] The second pixel is any pixel in the first LAB image, that is, the same operation is performed on all the pixels in the first LAB image.

[0126] S1043: If the A component of the second pixel point is within the range of the preset interval, use the solved second quadratic function to map and adjust the A component of the second pixel point.

[0127] Therefore, S1043-S1044 can be expressed as:

[0128] A dist =A+a 1 A 2 +b 1 A+c 1 (X1≤A≤X2)

[0129] A dist =A+a 2 A 2 +b 2 A+c 2 (X2≤A≤X3)

[0130] A dist =A+ΔA(A≤X1 or A≥X3)

[0131] In the above formula, A_dist is the A component after mapping.

[0132] The following is an example of a practical application. Of course, you can also adjust the coefficients yourself:

[0133] A dist =A+a 1 A 2 +b 1 A+c 1 (-20≤A≤0)

[0134] A dist =A+a 2 A 2 +b 2 A+c 2 (0≤A≤20)

[0135] A dist =A+ΔA(A≤-20 or A≥20)

[0136] S105, counting a third histogram of the first LAB image on the B component, constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel point in the first LAB image.

[0137] The adjustment amount of the third quadratic function for the central area of ​​B is less than that for the non-central area of ​​B. Similarly, the range of the central area of ​​B can be set according to actual conditions. The third quadratic function can avoid obvious changes in the hue of the white area.

[0138] In a specific embodiment, Figure 5 As shown, the third quadratic function is constructed and mapping adjustment is performed through the following steps;

[0139] S1051: Select multiple third reference points passed by the third quadratic function on the third histogram according to any preset interval and the third mean difference, and solve the coefficients in the third quadratic function based on the coordinates of the multiple third reference points.

[0140] Optionally, the third reference point can be selected in the following way:

[0141] If S 3 =X4,E 3 =X5, then:

[0142]

[0143] If S 3 =X5,E 3 =X6, then:

[0144]

[0145] In the above formula, E 3 and S 3 is the preset value, X4<X5<X6; if S 3 =X4,E 3 =X5, then (S 3 *2-E 3 , E 3 ) is the preset interval; if S 3 =X5,E 3 =X6, then (S 3 , E 3 *2-S 3 ) is a preset interval; A4, B4, C4, A5, B5, C5 are third reference points, and ΔB is the third mean difference.

[0146] The following is an example of a practical application. Of course, you can also adjust the coefficients yourself:

[0147] If S 3 =-20, E 3 =0, then:

[0148]

[0149] If S 3 =0,E 3 =20, then:

[0150]

[0151] Then substitute the three points A4, B4, and C4 obtained from the above calculation into the quadratic function y=a3x 2 +b3x+c3(a1≠0), to calculate the coefficients a3, b3, c3.

[0152] Or, substitute the three points A5, B5, and C5 obtained from the above calculation into the quadratic function y=a4x 4 +b4x+c4(a4≠0), to calculate the coefficients a4, b4, c4.

[0153] S1052: If the B component of the third pixel is not within the range of all preset intervals, add the third mean difference to the B component of the third pixel.

[0154] The third pixel is any pixel in the first LAB image, that is, the same operation is performed on all the pixels in the first LAB image.

[0155] S1053: If the B component of the third pixel point is within the range of the preset interval, use the solved third quadratic function to map and adjust the B component of the third pixel point.

[0156] Therefore, S1053-S1054 can be expressed as:

[0157] B dist =B+b 3 B 4 +b 3 B+c 3 (X4≤B≤X5)

[0158] B dist =B+b 4 B 4 +b 4 B+c 4 (X5≤B≤X6)

[0159] Bdist =B+ΔB(B≤X4 or B≥X6)

[0160] In the above formula, B dist That is the mapped B component.

[0161] The following is an example of a practical application. Of course, you can also adjust the coefficients yourself:

[0162] B dist =B+b 3 B 4 +b 3 B+c 3 (-20≤B≤0)

[0163] B dist =B+b 4 B 4 +b 4 B+c 4 (0≤B≤20)

[0164] B dist =B+ΔB(B≤-20 or B≥20)

[0165] S106, using the first LAB image after mapping and adjusting the L component, the A component and the B component as the second LAB image, and converting the second LAB image into a second RGB image to obtain a face image after skin color adjustment.

[0166] Since this conversion method is a prior art, it will not be described in detail.

[0167] The above-mentioned image skin color adjustment method first intercepts the first RGB image in the skin area of ​​the face image, and converts the first RGB image into the first LAB image. Then calculate the mean difference of each component. Then, based on the first mean difference, a preset first quadratic function is constructed in the first histogram, and the L component of the pixel point in the first LAB image is mapped and adjusted using the first quadratic function; wherein, the adjustment amount of the first quadratic function to the L central area is greater than the adjustment amount of the L non-central area, and the component covered by the central area is between the components covered by the non-central area. Through the mapping adjustment of the first quadratic function, the bright details can be well preserved and gray haze can be avoided. At the same time, based on the second mean difference, a preset second quadratic function is constructed in the second histogram, and the A component of the pixel point in the first LAB image is mapped and adjusted using the second quadratic function; wherein, the adjustment amount of the second quadratic function to the A central area is less than the adjustment amount of the A non-central area; through the second quadratic function, the hue of the white area can be avoided from changing significantly. The adjustment method of the B component is consistent with the adjustment method of the A component. Finally, the first LAB image after mapping and adjusting the L component, A component and B component is used as the second LAB image, and the second LAB image is converted into a second RGB image to obtain a face image after skin color adjustment. It can be seen that the present invention adopts a targeted adjustment method to solve the problems of gray, detail loss, color change, distortion, etc. in the output image when the LAB component value of the original photo deviates greatly from the preset range.

[0168] In one embodiment, Figure 6 As shown, a device for adjusting skin color of an image is proposed, the device comprising:

[0169] A first conversion module 601 is used to capture a first RGB image in a skin area in the face image before skin color adjustment, and convert the first RGB image into a first LAB image;

[0170] A preprocessing module 602 is used to calculate a first mean difference value according to the L components of all pixels in the first LAB image, calculate a second mean difference value according to the A components of all pixels, and calculate a third mean difference value according to the B components of all pixels; wherein the mean difference value indicates a difference between a component mean value of all pixels in the same channel and a corresponding preset standard deviation;

[0171] An L component adjustment module 603 is used to count a first histogram of the first LAB image on the L component, construct a preset first quadratic function in the first histogram based on the first mean difference, and use the first quadratic function to map and adjust the L component of the pixel point in the first LAB image; wherein the adjustment amount of the first quadratic function to the L central area is greater than the adjustment amount to the L non-central area, and the component covered by the central area is between the components covered by the non-central area;

[0172] A component adjustment module 604, used to count the second histogram of the first LAB image on the A component, construct a preset second quadratic function in the second histogram based on the second mean difference, and use the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; wherein the adjustment amount of the second quadratic function to the A central area is less than the adjustment amount to the A non-central area;

[0173] The B component adjustment module 605 is used to count the third histogram of the first LAB image on the B component, construct a preset third quadratic function in the third histogram based on the third mean difference, and use the third quadratic function to map and adjust the B component of the pixel point in the first LAB image; wherein the adjustment amount of the third quadratic function to the B central area is less than the adjustment amount to the B non-central area;

[0174] The second conversion module 606 is used to use the first LAB image after mapping and adjusting the L component, the A component and the B component as the second LAB image, and convert the second LAB image into a second RGB image to obtain a face image after skin color adjustment.

[0175] Figure 7 FIG. 2 shows an internal structure diagram of an image skin color adjustment device in one embodiment. Figure 7 As shown, the image skin color adjustment device includes a processor, a memory, and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the image skin color adjustment device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor may implement the image skin color adjustment method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor may implement the image skin color adjustment method. Those skilled in the art will understand that Figure 7 The structure shown in the figure is merely a block diagram of a portion of the structure related to the scheme of the present application, and does not constitute a limitation on the image skin color adjustment device to which the scheme of the present application is applied. The specific image skin color adjustment device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0176] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented: intercepting a first RGB image in a skin area in a face image before skin color adjustment, and converting the first RGB image into a first LAB image; in the first LAB image, calculating a first mean difference according to the L component of all pixels, calculating a second mean difference according to the A component of all pixels, and calculating a third mean difference according to the B component of all pixels; counting a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the first LAB image. The method comprises the following steps: calculating the L component of the pixel points in the B image; calculating a second histogram of the first LAB image on the A component, constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; calculating a third histogram of the first LAB image on the B component, constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel points in the first LAB image; using the first LAB image after mapping and adjusting the L component, the A component and the B component as the second LAB image, and converting the second LAB image into a second RGB image to obtain a face image after skin color adjustment.

[0177] An image skin color adjustment device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: intercepting a first RGB image in a skin area in a face image before skin color adjustment, and converting the first RGB image into a first LAB image; in the first LAB image, calculating a first mean difference according to the L component of all pixels, calculating a second mean difference according to the A component of all pixels, and calculating a third mean difference according to the B component of all pixels; statistically calculating a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function Mapping and adjusting the L component of the pixel points in the first LAB image; counting the second histogram of the first LAB image on the A component, constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; counting the third histogram of the first LAB image on the B component, constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel points in the first LAB image; using the first LAB image after mapping and adjusting the L component, the A component and the B component as the second LAB image, and converting the second LAB image into a second RGB image to obtain a face image after skin color adjustment.

[0178] It should be noted that the above-mentioned image skin color adjustment method, device, equipment and computer-readable storage medium belong to a general inventive concept, and the contents in the embodiments of the image skin color adjustment method, device, equipment and computer-readable storage medium are applicable to each other.

[0179] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0180] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0181] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for adjusting skin color of an image, It is characterized in that The method comprises: intercepting a first RGB image in a skin area from the face image before skin color adjustment, and converting the first RGB image into a first LAB image; In the first LAB image, a first mean difference is calculated based on the L components of all pixels, a second mean difference is calculated based on the A components of all pixels, and a third mean difference is calculated based on the B components of all pixels; wherein the mean difference indicates the difference between the component mean of all pixels in the same channel and the corresponding preset standard deviation; Counting a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image; wherein the adjustment amount of the first quadratic function on the L central area is greater than the adjustment amount on the L non-central area, and the component covered by the central area is between the components covered by the non-central area; Counting a second histogram of the first LAB image on the A component, constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; wherein the adjustment amount of the second quadratic function on the central area of ​​A is less than the adjustment amount on the non-central area of ​​A; Counting a third histogram of the first LAB image on the B component, constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel point in the first LAB image; wherein the adjustment amount of the third quadratic function on the B central area is less than the adjustment amount on the B non-central area; The first LAB image after mapping and adjusting the L component, the A component and the B component is used as the second LAB image, and the second LAB image is converted into a second RGB image to obtain a face image after skin color adjustment.

2. The method according to claim 1, It is characterized in that The step of constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image includes: Obtaining a starting value and an ending value on the first histogram; wherein the starting value is the lowest brightness value of the largest continuous interval in the first histogram, and the ending value is the highest brightness value of the largest continuous interval in the first histogram, and the largest continuous interval is the continuous interval with the largest number of pixels in the first histogram; Selecting a plurality of first reference points passed by the first quadratic function on the first histogram according to the first mean difference, the starting value, and the ending value, and solving coefficients in the first quadratic function based on coordinates of the plurality of first reference points; If the L component of the first pixel point is not within the range between the starting value and the ending value, the L component of the first pixel point is kept unchanged; wherein the first pixel point is any pixel point in the first LAB image; If the L component of the first pixel point is within the range between the starting value and the ending value, the L component of the first pixel point is mapped and adjusted using the solved first quadratic function.

3. The method according to claim 2, It is characterized in that The selecting, on the first histogram according to the first mean value difference, the starting value, and the ending value, a plurality of first reference points passed by the first quadratic function comprises: If ΔL≥0, then let: If ΔL<0, then let: In the above formula, He is the end value, Hs is the start value, n1, n2, n3 are preset coefficients, E and S are the zero point coordinates of the reference point, A1, B1, C1 are the first reference points, and ΔL is the first mean difference.

4. The method according to claim 1, It is characterized in that The step of constructing a preset second quadratic function in the second histogram based on the second mean difference, and using the second quadratic function to map and adjust the A component of the pixel point in the first LAB image includes: Selecting a plurality of second reference points passed by the second quadratic function on the second histogram according to any preset interval and the second mean difference, and solving coefficients in the second quadratic function based on coordinates of the plurality of second reference points; If the A component of the second pixel point is not within the range of all preset intervals, adding the second mean difference to the A component of the second pixel point; wherein the second pixel point is any pixel point in the first LAB image; If the A component of the second pixel point is within a preset interval, the A component of the second pixel point is mapped and adjusted using the solved second quadratic function.

5. The method according to claim 4, It is characterized in that The formula for selecting the second reference point is: If S 2 =X1,E 2 =X2, then: If S 2 =X2,E 2 =X3, then: In the above formula, E 2 and S 2 is the preset value, X1<X2<X3; if S 2 =X1,E 2 =X2, then (S 2 *2-E 2 , E 2 ) is the preset interval; if S 2 =X2,E 2 =X3, then (S 2 , E 2 *2-S 2 ) is a preset interval; A2, B2, C2, A3, B3, C3 are second reference points, and ΔA is the second mean difference.

6. The method according to claim 1, It is characterized in that The step of constructing a preset third quadratic function in the third histogram based on the third mean difference, and using the third quadratic function to map and adjust the B component of the pixel point in the first LAB image includes: Selecting a plurality of third reference points passed by the third quadratic function on the third histogram according to any preset interval and the third mean difference, and solving coefficients in the third quadratic function based on coordinates of the plurality of third reference points; If the B component of the third pixel point is not within the range of all preset intervals, adding the third mean difference to the B component of the third pixel point; wherein the third pixel point is any pixel point in the first LAB image; If the B component of the third pixel point is within the range of the preset interval, the B component of the third pixel point is mapped and adjusted using the solved third quadratic function.

7. The method according to claim 6, It is characterized in that The formula for selecting the third reference point is: If S 3 =X4,E 3 =X5, then: If S 3 =X5,E 3 =X6, then: In the above formula, E 3 and S 3 is the preset value, X4<X5<X6; if S 3 =X4,E 3 =X5, then (S 3 *2-E 3 , E 3 ) is the preset interval; if S 3 =X5,E 3 =X6, then (S 3 , E 3 *2-S 3 ) is a preset interval; A4, B4, C4, A5, B5, C5 are third reference points, and ΔB is the third mean difference.

8. An image skin color adjustment device, It is characterized in that The device comprises: A first conversion module, configured to capture a first RGB image in a skin area in the face image before skin color adjustment, and convert the first RGB image into a first LAB image; A preprocessing module, configured to calculate, in the first LAB image, a first mean difference according to the L components of all pixels, a second mean difference according to the A components of all pixels, and a third mean difference according to the B components of all pixels; wherein the mean difference indicates a difference between a component mean of all pixels in the same channel and a corresponding preset standard deviation; An L component adjustment module, used for counting a first histogram of the first LAB image on the L component, constructing a preset first quadratic function in the first histogram based on the first mean difference, and using the first quadratic function to map and adjust the L component of the pixel point in the first LAB image; wherein the adjustment amount of the first quadratic function on the L central area is greater than the adjustment amount on the L non-central area, and the component covered by the central area is between the components covered by the non-central area; An A component adjustment module, configured to calculate a second histogram of the first LAB image on the A component, construct a preset second quadratic function in the second histogram based on the second mean difference, and use the second quadratic function to map and adjust the A component of the pixel points in the first LAB image; wherein the adjustment amount of the second quadratic function for the A central area is less than the adjustment amount for the A non-central area; A B component adjustment module, configured to count a third histogram of the first LAB image on the B component, construct a preset third quadratic function in the third histogram based on the third mean difference, and use the third quadratic function to map and adjust the B component of the pixel point in the first LAB image; wherein the adjustment amount of the third quadratic function on the B central area is less than the adjustment amount on the B non-central area; The second conversion module is used to use the first LAB image after mapping and adjusting the L component, the A component and the B component as the second LAB image, and convert the second LAB image into a second RGB image to obtain a face image after skin color adjustment.

9. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.

10. An image skin color adjustment device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Skin color enhancement processing method and device and image processing device

    CN107507144A

  • Image processing method and device, computer equipment and computer-readable storage medium

    CN107862657A