Portrait skin color whitening processing method and device capable of processing image

Through deep learning skin segmentation model and distance weight compensation technology, the problem that existing whitening algorithms are difficult to accurately adjust the color of the skin area of ​​the portrait image is solved, and a natural and real whitening effect is achieved.

CN119722526AActive Publication Date: 2025-03-28BEIJING JINSHAJIANG TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411781985.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-03-28
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

Existing whitening algorithms are difficult to accurately adjust the color of the skin area in portrait images, resulting in a decrease in nature, and ignore the whitening effect of areas other than the face, making it difficult to maintain the consistency between the skin area and other areas.

Method used

The skin segmentation model based on deep learning is used to extract the skin area, calculate the average value of the RGB three-channel value in the skin area, set the preset target value to calculate the three-channel compensation value, and compensate through the distance weight to generate an automatic skin color whitening image.

Benefits of technology

Accurate color adjustment of the skin area in the portrait image is achieved, maintaining natural effects, avoiding excessive whitening, and the whitening effect is more realistic and natural.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119722526A_ABST
    Figure CN119722526A_ABST
Patent Text Reader

Abstract

The invention relates to a portrait skin color whitening processing method and equipment capable of processing an image, belongs to the technical field of image processing, and can perform adaptive adjustment according to local information of the image through an accurate color correction and compensation algorithm so as to realize directional optimization and whitening of a skin area and generate an automatic skin color whitening image. Through the concept of adding the distance weight, the color adjustment of the image can avoid excessive whitening while keeping the natural effect, so that the portrait whitening effect is more real and natural.
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 a method for whitening skin color of a portrait and a device capable of processing images. Background Art

[0002] With the rapid development of image processing and computer vision technology, whitening of portrait images has become a widely concerned research direction.

[0003] Most of the existing whitening algorithms are based on global adjustment of image brightness and contrast, and cannot make precise color adjustments for skin areas, which often reduces the naturalness of portrait images. Other algorithms are based on regions, such as facial regions, and are also unable to make precise color adjustments for other skin areas.

[0004] In addition, during the whitening process, existing technologies tend to ignore the whitening effects on areas other than the face. Even if some technologies can whiten the above-mentioned areas, it is difficult to maintain consistency in whitening the skin area and areas other than the skin. Summary of the invention

[0005] In order to alleviate or solve at least one aspect or at least one point of the above problems, the present invention is proposed. A human portrait skin color whitening processing method of the present invention is characterized by comprising the following steps:

[0006] S1: Input or collect the original portrait image, and extract the skin area based on the pre-trained deep learning skin segmentation model;

[0007] S2: Calculate the average value of the RGB three-channel values ​​of the pixel points in the skin area;

[0008] S3: Setting a preset target value, and calculating a three-channel compensation value according to the average value of the RGB three-channel values;

[0009] S4: traverse each pixel of the original portrait image, and calculate the distance weight between the RGB three-channel value of each pixel of the original portrait image and the average value of the RGB three-channel value according to the average value of the RGB three-channel value;

[0010] S5: Compensation is performed according to the RGB three-channel compensation values ​​and the distance weight to obtain an automatic skin color whitening image of the original image portrait.

[0011] Preferably, step S4 includes: S41: obtaining the RGB three-channel value of each pixel point, and calculating the distance value between the pixel point and the average value of the RGB three-channel of the skin area;

[0012] S42: According to the calculated distance value, the weight of each RGB channel of the pixel is calculated by using the inverse distance method, and normalized to generate a normalized distance weight. The normalized distance weight is calculated by the following formula: Where dR, dG, dB represent the absolute difference between the R, G, B channels of the pixel and the average value; ε represents a small constant used to avoid division by zero; wR, wG, wB represent the weight of each channel of the pixel obtained using inverse distance; wR′, wG′, wB′ represent the normalized distance weights.

[0013] Preferably, step S5 includes: according to the normalized distance weight, adding the compensation value of the three channels to the RGB three channel value of each pixel point in proportion to the distance weight, so as to form a whitened image.

[0014] Preferably, the processing method according to claim 1 is characterized in that: the step S1 further comprises: step S11: collecting a portrait image data set for skin segmentation model training and preprocessing the data set, the portrait image containing a complete face area;

[0015] Step S12: Building a skin segmentation model, the skin segmentation model adopts a lightweight semantic segmentation model based on a convolutional neural network;

[0016] Step S13: Optimizing the skin segmentation model based on convolutional neural network analysis;

[0017] Step S14: inputting the input or collected original portrait image into the trained skin segmentation model to generate the required skin segmentation map and extract the skin area.

[0018] Preferably, step S12 also includes: extracting high-level semantic features from the input image, gradually reducing the spatial dimension of the image through a series of convolutional layers, pooling layers and activation functions, and enhancing the semantic information in the image.

[0019] Preferably, step S12 also includes: during training, calculating the loss of the feature maps outputted in the first few stages to improve the ability of low-layer convolution to extract image details.

[0020] Preferably, step S12 further includes: during inference, directly fusing the low-level convolution feature map with the high-level convolution feature map containing more semantic information. The calculation process is represented by formula (1): detail (p d ,g d )=L dice (p d ,g d )+L bce(p d ,g d )

[0021]

[0022] L detail represents the detail loss function; p d Represents the detailed information of each pixel or region in the predicted distribution or feature map; g d represents the true label or target value; L dice represents the Dice loss function; L bce represents the binary cross entropy loss; Represents the predicted value of the i-th pixel position; The true label value of the i-th pixel position; d represents the detail layer; H×W represents the resolution of the feature map; ε represents the smoothing term to prevent the denominator from being zero.

[0023] Preferably, step S13 also includes: using the sorted portrait images and annotated pictures as training data, combining the learning rate and batch size to accelerate model convergence, and adopting a dynamic learning rate adjustment strategy to adapt to the training stage; combining random cropping, rotation and flipping data enhancement techniques to increase the diversity of training data and improve the generalization ability of the model.

[0024] Preferably, step S14 includes: inputting the original portrait image into the trained skin segmentation model, the model uses a convolutional neural network structure to perform forward reasoning on the image, extracts multi-scale features of the image through multiple convolutional layers, and highlights the details of edges and skin areas.

[0025] Preferably, step S14 includes: the skin segmentation model reduces the resolution of the feature map by downsampling to obtain broader context information, and then restores it to the resolution of the original image by upsampling to accurately locate the skin area.

[0026] Preferably, step S2 comprises: step S21: according to a preset condition, accurately locating pixels representing skin areas in the skin segmentation map; finding pixel coordinates satisfying the preset condition according to the preset condition; creating a Boolean mask map according to these coordinates to mark the skin area in the segmentation map;

[0027] Step S22: By converting the mask image into a grayscale image, and then using the conditional selection function to find the pixel position of the grayscale value in the original image; in RGB mode, extract all pixel values ​​in the skin area and calculate the average value of the three channel values ​​of R, G, and B of the pixels in the skin area.

[0028] The present invention also provides a device capable of processing images, wherein a readable storage medium is provided therein, on which a computer program is stored, and when the computer program is executed by a processor, any of the above-mentioned methods is implemented.

[0029] The present invention proposes an automatic skin color whitening method based on portrait images. The precise color correction and compensation algorithm can be adaptively adjusted according to the local information of the image, thereby achieving directional optimization and whitening of the skin area. Thus, an automatic skin color whitening image is generated. By adding the concept of distance weight, the color adjustment of the image can avoid over-whitening while maintaining the natural effect, making the portrait whitening effect more realistic and natural. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 The figure is a flowchart of a method for whitening skin color in a portrait according to an exemplary embodiment of the present invention.

[0031] Figure 2 A schematic diagram of a process for establishing and training a deep learning skin segmentation model according to an exemplary embodiment of the present invention.

[0032] Figure 3 The figure is a schematic diagram of a flow chart for calculating the average values ​​of RGB three-channel values ​​of pixel points in a skin area according to an exemplary embodiment of the present invention.

[0033] Figure 4 The present invention is a schematic diagram of a distance weighting process for calculating the distance between the RGB three-channel value and the average value of the RGB three-channel value at each pixel of the original portrait image according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following description of the embodiments of the present invention with reference to the accompanying drawings is intended to explain the overall inventive concept of the present invention, and should not be construed as a limitation of the present invention. In the present invention, the same reference numerals represent the same or similar components.

[0035] The features described herein can be implemented in different forms and should not be construed as being limited to the examples described herein. Rather, the examples described herein have been provided to illustrate only some of the many possible ways to implement the methods, devices, and / or systems described herein, which will be clear after understanding the disclosure of the present invention.

[0036] The terms used herein are only used to describe various examples and are not intended to limit the disclosure. Unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. The terms "comprise", "include" and "have" indicate the presence of the described features, quantities, operations, components, elements and / or combinations thereof, but do not exclude the presence or addition of one or more other features, quantities, operations, components, elements and / or combinations thereof.

[0037] In order to enable those skilled in the art to use the contents of the present invention, the following exemplary embodiments may be provided in combination with specific application scenarios, specific systems, parameters of devices and components, and specific connection methods. However, for those skilled in the art, these embodiments are only examples, and the general principles defined herein may be applied to other embodiments and application scenarios without departing from the spirit and scope of the present invention.

[0038] According to an exemplary embodiment of the present invention: Figure 1-4 As shown in FIG. 1 , a method for whitening the skin color of a portrait is shown. Figure 1 As shown, the method comprises the following steps: Step S1: inputting or collecting a portrait image; extracting the skin area based on a pre-trained deep learning skin segmentation model. The skin segmentation model is a computer vision model used to automatically detect and extract the skin area from the portrait image. The model can be trained on a large number of images with skin annotations so that the model can identify the pixel area belonging to the skin in the image.

[0039] Exemplary, combined Figure 2 A method for segmenting the skin area of ​​a portrait image based on a skin segmentation model according to an exemplary embodiment of the present invention is described. Step S11: First, the portrait image data set is collected and preprocessed, and the portrait image contains a complete face area. Use image standard tools on the portrait image to annotate the background, glasses, eyebrows, hair, skin, clothes, and mouth areas with the colors specified for the corresponding areas. This step ensures that the model can learn the characteristics of the skin area and save the annotation results. Process the annotated image, set the annotated image to the specified pixel value according to the corresponding color, and the mask image finally generated will be used to train the model. The original portrait image and the corresponding annotated image are organized into a training data set. In order to evaluate the performance of the model, the data set is divided into a training set and a validation set, which can be divided in a ratio of 8:2 to ensure that the training set contains enough samples to improve the generalization ability of the model.

[0040] Step S12: Building a skin segmentation model. According to the annotation accuracy and consistency of the training data set, the skin segmentation model of the present invention is optionally trained using real-time semantic segmentation technology to accurately extract the skin area. By adopting the real-time semantic segmentation model, real-time processing can be achieved while ensuring accuracy. During the training process, the model learns based on a large amount of annotated data, so that it can accurately identify and segment the boundaries of the skin area and adapt to different individuals and various postures. This design not only improves the efficiency of segmentation, but also ensures the fluency and reliability of the model in practical applications. Real-time semantic segmentation technology is a computer vision technology that aims to classify images pixel by pixel while maintaining sufficient processing speed to achieve real-time application. Semantic segmentation refers to dividing each pixel in the image into a certain class of objects and generating a corresponding segmented image. Real-time means that the segmentation processing speed of the model is fast enough to respond at the millisecond level.

[0041] The real-time semantic segmentation model is a lightweight semantic segmentation model based on convolutional neural networks. It achieves real-time segmentation through a streamlined network structure and an innovative combination of modules. The structure of the lightweight semantic segmentation model includes an encoder, a decoder, and a segmentation head. The lightweight semantic segmentation model uses a simple pyramid pooling module to aggregate global context information at a low computational cost, thereby improving the model's perception of the environmental background and enhancing the segmentation performance. At the same time, a flexible and lightweight decoder is used to reduce the computational burden of traditional decoders and improve reasoning efficiency. In addition, the lightweight semantic segmentation model also integrates a unified attention fusion module as a key component for enhanced feature representation. This module uses spatial and channel attention mechanisms to generate weights and fuses input features with these weights to help the model capture key semantic information more effectively.

[0042] Exemplary: The encoder uses the backbone network as the basic backbone network to extract high-level semantic features from the input image. Through a series of convolutional layers, pooling layers and activation functions, the spatial dimensions [H, W] of the image are gradually reduced, H and W represent the height and width information respectively, and the semantic information in the image is enhanced, that is, the number of channels of the feature map is increased. The task of the encoder is to convert the original image into a low-resolution feature map with rich semantic information, including information such as the object, texture and structure of the image. The backbone network is a short-term densely connected network, which is a lightweight convolutional neural network designed to improve the model inference speed while ensuring the effectiveness of feature extraction. The backbone network of the short-term densely connected network is divided into 6 stages, of which the first 5 stages are mainly used as the backbone for feature extraction and segmentation. The output feature map of each stage gradually decreases in size, while the number of channels gradually increases. The size of the output feature map of the i-th stage is H×W of the original input. The number of channels of the feature map increases with the number of stages, and the number of channels in the i-th stage is 16×2 i. The number of channels is gradually increased in each stage to enhance the network's ability to represent features. When the number of channels of the output feature map of the second stage is greater than 64, a "final convolution layer" is added to the output of the fifth stage. The function of this layer is to ensure that the number of channels of the feature map output by the fifth stage is not less than 1024, so as to better perform subsequent processing. A short dense connection module is used inside each stage. The core design of this module is to achieve more effective information transfer through dense connections. The receptive field of the low-level convolution in the module is small, so more channels are required to extract detailed information. The receptive field of the high-level convolution is larger, and only a small number of channels are required to extract sufficient semantic information. A detailed guidance training branch is added. Preferably, when the model is trained, the loss of the feature maps output by the previous stages is calculated to improve the ability of the low-level convolution to extract image details. When the model is inferring, the feature map of the low-level convolution is directly fused with the high-level convolution feature map containing more semantic information. The calculation process is represented by formula (1):

[0043] L detail (p d ,g d )=L dice (p d ,g d )+L bce (p d ,g d )

[0044]

[0045] L detail represents the detail loss function; p d Represents the detailed information of each pixel or region in the predicted distribution or feature map; g d represents the true label or target value; L dice represents the Dice loss function; L bce represents the binary cross entropy loss; Represents the predicted value of the i-th pixel position; The true label value of the i-th pixel position; d represents the detail layer; H×W represents the resolution of the feature map; ε represents the smoothing term to prevent the denominator from being zero.

[0046] Exemplarily, the decoder is the part corresponding to the encoder, which is responsible for restoring the low-resolution feature map generated by the encoder to the resolution of the original image and performing pixel-level classification. The decoder usually includes upsampling layers and convolution layers to gradually restore the details of the feature map and generate a feature map of the same size as the input image. The decoder maps the semantic features extracted by the encoder to the pixel level in order to classify each pixel.

[0047] Exemplarily, the segmentation head is a fully connected layer or a convolutional layer, which is used to convert the feature map output by the decoder into the final segmentation structure. The simple pyramid pooling module generates feature maps of various sizes by performing pooling operations on feature maps at different scales. The simple pyramid pooling module uses two pooling operations of different scales, namely average pooling and maximum pooling. These pooled feature maps are then fused to provide rich contextual information and enhance the robustness of the network to changes in target shape and size. The flexible lightweight decoder is a module for generating high-quality output feature maps, which aims to accelerate the reasoning of the model by reducing the amount of calculation and the amount of parameters, and can adapt to various input conditions and task requirements. The main function of the flexible lightweight decoder is to gradually reduce the number of channels of the feature while gradually increasing the spatial size [H, W] of the feature map during the operation of the decoder, balancing the computational complexity of the encoder and the decoder, and making the overall model more efficient. Exemplarily, the model also includes a unified attention fusion module, which is a structure for fusing multiple feature maps, using spatial and channel attention mechanisms to generate a weight matrix α, and multiplying the input features with the weight matrix to obtain the fused features. This enables the model to better capture the key semantic information in the image and improve segmentation accuracy. Formula (2) represents its calculation process:

[0048] F high represents the output of the deep module; F low Indicates the corresponding part of the encoder; F up It is represented by the upsampled features; α represents the attention weight coefficient; Upsample(F high ) represents the high-resolution feature map F high The upsampling operation; (1-α) reverse attention weight represents the low-resolution feature map F during the fusion process low The importance weight of Attention(F up ,F high ) represents the attention formula. The attention mechanism is a dynamic selection process of important information of the image input, which is realized by adaptive weights for features. When using attention to process tasks, the importance of different information is reflected by weights. The distinction of attention to different information by the attention mechanism is reflected in the weight allocation. The attention mechanism can be regarded as a multi-layer perceptron composed of query matrix, key and weighted average. The spatial attention mechanism uses the spatial relationship between pixels to generate a weight, which indicates the importance of each pixel in the input feature. The channel attention mechanism uses the relationship between channels to generate weights, which indicates the importance of each channel in the input feature. The channel attention module uses average pooling and maximum pooling operations to compress the spatial dimension of the input feature.

[0049] Step S13: This method is a method for optimizing the skin segmentation model based on convolutional neural network analysis. This method evaluates the size and computational efficiency of the overall model by calculating the number of parameters and floating-point operations for each layer. In addition, the sorted portrait images and annotated images are used as training data, combined with optimized hyperparameters such as learning rate and batch size to accelerate model convergence, and a dynamic learning rate adjustment strategy is adopted to adapt to the training stage. Combined with data enhancement techniques such as random cropping, rotation, and flipping, the diversity of training data is increased and the generalization ability of the model is improved. Through the above convolutional network parameter analysis method, the present invention can effectively optimize the performance of the skin segmentation model in the skin segmentation task, reduce computational complexity, and improve segmentation accuracy, thereby achieving real-time and efficient skin segmentation.

[0050] Step S14: Input the portrait image into the trained skin segmentation model. The model uses a convolutional neural network structure to perform forward reasoning on the image, extracts multi-scale features of the image through multiple convolutional layers, and highlights the details of the edges and skin areas. The skin segmentation model reduces the resolution of the feature map by downsampling to obtain a wider range of contextual information, and then restores it to the resolution of the original image by upsampling to accurately locate the skin area. After a series of convolution, downsampling, and upsampling operations, the model outputs a segmentation map of the same size as the input image, in which the value of each pixel represents the probability that the location belongs to the skin area. Finally, the probability map is converted into a binary segmentation map by setting a threshold to generate the required skin segmentation map.

[0051] Step S2: Calculate the average value of the three RGB channels in the skin area. Specifically: Step S21: Define a preset condition for accurately locating the pixels representing the skin area in the skin segmentation map. Exemplarily, the above preset condition is usually implemented by comparing the color channel value of each pixel. For example, knowing that the skin area is represented by a specific color value in the segmentation map, the pixels in the image can be filtered by setting such a condition. Using the conditional selection function, find the pixel coordinates that meet the condition according to the previously defined condition. The function returns the indexes of all pixels that meet the condition. These indexes will provide us with the specific location of the skin area in the image. Based on these coordinates, create a Boolean mask to mark the skin area in the segmentation map. Initialize an all-zero array of the same size as the segmentation map, and use the pixel coordinates found previously to set the value of the corresponding position to 255 to mark the skin area. The above conditional selection function is a function used to select or find array elements based on conditions.

[0052] Step S22: Detect the pixel values ​​that meet the conditions in the mask, and convert the mask image into a grayscale image to facilitate detection. Then find the pixel position of the grayscale value in the original image. Among them, the conditional selection function can be used to find the above pixel position. In RGB mode, we extract all pixel values ​​in the skin area and calculate the average value of the three channel values ​​of R, G, and B of the pixels in the skin area.

[0053] Step S3: Set a preset target value, and calculate the RGB three-channel compensation value according to the average value of the RGB three-channel. For example, the preset target value can be selected from the better skin in the manual screening as a standard.

[0054] Step S31: First, set the target value of the standard skin color after whitening, which represents the ideal skin color characteristics. Step S32: Obtain the R channel compensation value, G channel compensation value, and B channel compensation value according to the difference between the R channel average value, G channel average value, and B channel average value of the skin area and the set target value. For each channel, calculate the difference between the target value and the current channel average value to obtain the R channel compensation value, G channel compensation value, and B channel compensation value.

[0055] The adjustment intensity is controlled by calculating the multiple relationship of the color value of the current skin area relative to the target skin color. After obtaining the compensation value, in order to achieve a more adaptive whitening effect, it is also necessary to calculate the multiple relationship of the color value of the current skin area relative to the target skin color. This is to understand the degree of deviation of the current skin area from the target skin color, thereby controlling the adjustment intensity. By appropriately scaling the compensation value through the multiple relationship, the problem of over-whitening or uneven whitening of the skin color can be avoided.

[0056] Step S4: traverse each pixel of the original portrait image, and calculate the distance weight between the RGB three channels at each pixel and the average value according to the average value of the RGB three channels.

[0057] Step S41: When traversing each pixel of the original portrait image, firstly, it is necessary to obtain the RGB value of each pixel and calculate the distance between it and the average value of the three channels of RGB in the skin area. For each pixel in the image, obtain its RGB value, calculate the absolute difference between the RGB value of the pixel and the average value of the skin area, and obtain the distance of the three channels. Formula (3) represents the calculation process:

[0058]

[0059] dR, dG, dB represent the absolute difference between the R, G, B channels of the pixel and the average value; R, G, B represent the values ​​corresponding to the R, G, B of the pixel; R avg , G avg , B avgIt represents the average value of the three channels R, G, and B in the skin area shown;

[0060] Step S42: Generate a weight for each RGB channel of the pixel according to the calculated distance value of the pixel. Use the inverse distance method to calculate the weight of each channel, and use normalized weights to ensure that the smaller the distance, the larger the weight. Use the sum of the inverse distances to be 1 so that the influence can be reasonably distributed in the subsequent compensation calculation. Obtain the distance weights of the three RGB channels of the pixel and the average value. The inverse distance is commonly used to calculate weighting coefficients in image processing. In this example, it is used to measure the distance weight of each pixel from the average value, so as to give higher weights to pixels with close distances; the normalized weight is a method of adjusting a set of weights and normalizing their sum to 1. This ensures that the relative proportion of each weight remains consistent, but the value is in the range of 0 to 1. The normalized weights are often used to calculate weighted averages or balance the contributions of multiple influencing factors. When using the inverse distance to calculate the weights in this example, normalization can ensure that the sum of the weights of all channels is 1 to avoid a single channel from having too much influence on the adjustment effect; formula (4) represents its calculation process:

[0061]

[0062] Where dR, dG, dB represent the absolute difference between the R, G, and B channels of the pixel and the average value; ε represents a small constant used to avoid division by zero, and its exemplary value can be 0.1-0.9, preferably 0.9.; wR, wG, wB represent the weight of each channel of the pixel obtained by using the inverse distance; wR′, wG′, wB′ represent the normalized weights;

[0063] Step S5: Compensation is performed according to the distance weights between the compensation values ​​of the RGB three channels and the average value, so as to obtain the automatic skin color whitening image of the final original image portrait.

[0064] Step S51: weighted adjustment is performed according to the distance weight between the compensation value of each channel of each pixel and the average value. According to the distance weight from the average value, the compensation value of each channel is added to the original value of the pixel in proportion. This method of allocating compensation values ​​according to distance weight can effectively adjust the whitening effect of the skin color, making the skin color adjustment more delicate and uniform. The whitening adjustment of each pixel is performed according to the distance weight from the average value, which helps to achieve delicate progressive whitening. In order to prevent the compensated pixel value from exceeding the image display range, ensure that the final value of each channel is limited to between 0 and 255 to avoid overflow or undercut. This restriction ensures that the generated image maintains integrity in the color space and avoids oversaturation or incomplete color. The compensated R, G, and B three-channel values ​​of each pixel are combined to generate a processed image. Since the concept of distance weight is introduced in the adjustment process, the entire whitening effect is more uniform and natural visually, and no obvious hue mutation occurs. The distance weight is a weighting factor used to measure the degree of influence of each pixel relative to the reference value during the adjustment process. The size of the distance weight is usually based on the distance between the pixel value and the reference value. The smaller the distance, the greater the weight, indicating that the pixel is closer to the target color value and requires more compensation or adjustment; the larger the distance, the smaller the weight, indicating that the pixel is more different from the target value and may require less adjustment; in addition, this weighted compensation method not only optimizes the whitening effect, but also improves the computational efficiency and speeds up the processing. The final output image will present a portrait image that has been automatically whitened, showing a more uniform and natural skin tone effect.

[0065] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes may be made to the embodiments and combinations of elements may be made without departing from the principles and spirit of the invention, the scope of the invention being defined by the appended claims and their equivalents.

Claims

1. A method for whitening skin color of a portrait, characterized in that: The method comprises the following steps: S1: Input or collect the original portrait image, and extract the skin area based on the pre-trained deep learning skin segmentation model; S2: Calculate the average value of the RGB three-channel values ​​of the pixel points in the skin area; S3: Setting a preset target value, and calculating a three-channel compensation value according to the average value of the RGB three-channel values; S4: traverse each pixel of the original portrait image, and calculate the distance weight between the RGB three-channel value of each pixel of the original portrait image and the average value of the RGB three-channel value according to the average value of the RGB three-channel value; S5: Compensation is performed according to the RGB three-channel compensation values ​​and the distance weight to obtain an automatic skin color whitening image of the original image portrait.

2. The processing method according to claim 1, characterized in that: Step S4 includes: S41: obtaining the RGB three-channel value of each pixel point, and calculating the distance value between the pixel point and the average value of the RGB three-channel value of the skin area; S42: According to the calculated distance value, the weight of each RGB channel of the pixel is calculated by using the inverse distance method, and normalized to generate a normalized distance weight. The normalized distance weight is calculated by the following formula: Where dR, dG, dB represent the absolute difference between the R, G, B channels of the pixel and the average value; ε represents a small constant used to avoid division by zero; wR, wG, wB represent the weight of each channel of the pixel obtained using inverse distance; wR′, wG′, wB′ represent the normalized distance weights.

3. The processing method according to claim 2, characterized in that: Step S5 includes: according to the normalized distance weight, adding the compensation value of the three channels to the RGB three channel value of each pixel point in proportion to the distance weight, so as to form a whitened image.

4. The processing method according to claim 1, characterized in that: The step S1 also includes: Step S11: collecting and preprocessing a portrait image data set for training a skin segmentation model, wherein the portrait image includes a complete face area; Step S12: Building a skin segmentation model, the skin segmentation model adopts a lightweight semantic segmentation model based on a convolutional neural network; Step S13: Optimizing the skin segmentation model based on convolutional neural network analysis; Step S14: inputting the input or collected original portrait image into the trained skin segmentation model to generate the required skin segmentation map and extract the skin area.

5. The processing method according to claim 4, characterized in that: Step S12 also includes: extracting high-level semantic features from the input image, gradually reducing the spatial dimension of the image through a series of convolutional layers, pooling layers and activation functions, and enhancing the semantic information in the image.

6. The processing method according to claim 4, characterized in that: Step S13 also includes: using the sorted portrait images and annotated pictures as training data, combining the learning rate and batch size to accelerate model convergence, and adopting a dynamic learning rate adjustment strategy to adapt to the training stage; combining random cropping, rotation and flipping data enhancement technology to increase the diversity of training data and improve the generalization ability of the model.

7. The processing method according to claim 4, characterized in that: Step S14 includes: inputting the original portrait image into the trained skin segmentation model, the model uses a convolutional neural network structure to perform forward reasoning on the image, extracts multi-scale features of the image through multiple convolutional layers, and highlights the details of the edges and skin areas.

8. The processing method according to claim 7, characterized in that: Step S14 includes: the skin segmentation model reduces the resolution of the feature map by downsampling to obtain broader context information, and then restores it to the resolution of the original image by upsampling to accurately locate the skin area.

9. The processing method according to claim 1, characterized in that: Step S2 includes: Step S21: according to a preset condition, accurately locating the pixels representing the skin area in the skin segmentation map; finding the pixel coordinates satisfying the preset condition according to the preset condition; creating a Boolean mask map according to these coordinates to mark the skin area in the segmentation map; Step S22: By converting the mask image into a grayscale image, and then using the conditional selection function to find the pixel position of the grayscale value in the original image; in RGB mode, extract all pixel values ​​in the skin area and calculate the average value of the three channel values ​​of R, G, and B of the pixels in the skin area.

10. A device capable of processing an image, wherein a readable storage medium is provided therein and a computer program is stored thereon, characterized in that: When the computer program is executed, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Automatic white balance method and device for portrait image

    CN110012277A

  • Human face skin color correction method and device, computer equipment and readable storage medium

    CN111583127A

  • Skin color beautifying and correcting method and device

    CN112541860A

  • Color correction method and device, electronic equipment and storage medium

    CN115965541A

  • Image automatic white balance processing method, system and device

    CN118870207A