Method and system for human and background fusion based on adaptive skin color protection
By using deep learning and adaptive correction techniques, the risk of skin color distortion is quantified, and an adaptive skin color protection fusion method is generated. This solves the problem of skin color distortion under different lighting conditions, and improves the success rate and visual realism of image synthesis.
Patent Information
- Application Number
- CN202511784744.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-01
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-12-01
AI Technical Summary
In existing technologies, when the skin tone of a person varies greatly under different lighting conditions, the distortion caused by a uniform color correction strategy affects the visual experience.
The system employs a deep learning-based segmentation model, an exposure repair network based on the UNet architecture, and a facial keypoint detection model to generate a foreground mask and a binarized mask. It quantifies the skin color distortion index, determines the level through a risk assessment threshold, triggers an adaptive correction strategy, and generates the final fused image.
It achieves the goal of ensuring a natural blend between the background and foreground while maximizing the preservation of the realism of skin tones, significantly improving the success rate and stability of image compositing, and avoiding distortion caused by color differences.
Smart Images

Figure CN121213428B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital image processing technology, specifically to a method and system for blending people and backgrounds based on adaptive skin tone protection. Background Technology
[0002] With the development of digital image processing technology, merging foreground images of people with new background images has become a common requirement. This process aims to create seamless and realistic visual effects.
[0003] Currently, most mainstream blending methods employ a uniform color correction strategy, attempting to forcibly match the overall color tone of the foreground figure to the target background in order to achieve so-called harmony and unity. However, when the original lighting environment of the figure differs significantly from the background, this one-size-fits-all color transfer method is prone to causing serious distortions in the figure's skin tone, which has the greatest impact on visual perception, such as appearing sallow or pale, thus destroying the realism of the subject. Therefore, how to ensure the natural blending of the foreground and background while adaptively protecting the figure's skin tone and avoiding the distortion problems caused by color correction has become a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0004] The purpose of this invention is to provide a method and system for blending people and backgrounds based on adaptive skin tone protection. This aims to avoid the serious distortion problem of unrealistic and unattractive skin tones caused by the uniform color correction strategy used in existing technologies when blending images with significant differences in lighting conditions. Furthermore, it can ensure a natural blending of foreground and background while intelligently assessing the risk of skin tone distortion and automatically adopting the optimal correction strategy based on the risk level, thereby maximizing the preservation of the realism of the skin tones. Specifically, the technical solution of this invention is as follows:
[0005] A method for blending people and backgrounds based on adaptive skin tone protection includes:
[0006] The input original image is processed based on a pre-defined deep learning segmentation model to generate a foreground mask;
[0007] Combine the foreground mask with the original image to obtain the initial foreground image;
[0008] The initial foreground image is processed using a pre-defined exposure repair network based on the UNet architecture, and the foreground image after exposure correction is output.
[0009] Based on the pre-set facial key point detection model, the foreground image after exposure correction is analyzed to generate a binary mask for the facial skin region.
[0010] The skin color distortion index, which characterizes the skin color compatibility between the foreground image and the target background image after exposure correction, is calculated.
[0011] Based on the comparison results of skin color distortion index, security risk assessment threshold and critical risk assessment threshold, the risk level of the fusion task is determined; among them, the critical risk assessment threshold is greater than the security risk assessment threshold.
[0012] Based on the skin color distortion index, a skin color protection constraint factor is generated.
[0013] Based on the risk level, a corresponding graded correction strategy is triggered, and the foreground image after exposure correction is adjusted in combination with the skin color protection constraint factor to generate the final foreground image;
[0014] Based on the foreground mask, the final foreground image is synthesized with the target background image to output the final fused image.
[0015] Preferably, the skin color distortion index is calculated, including:
[0016] The target background image is analyzed using the K-Means clustering algorithm, and the dominant color tone is extracted as the background reference color.
[0017] Within the area defined by the binarized mask, calculate the average saturation and average brightness of the foreground image after exposure correction;
[0018] Within the area defined by the binarized mask, calculate the cyclic average of all hue angles to obtain the average hue;
[0019] The skin color distortion index is obtained by weighting the background reference color, average saturation, average brightness, and average hue using preset weighting coefficients.
[0020] Preferably, the risk level of the fusion task is determined by:
[0021] If the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe.
[0022] If the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert level.
[0023] If the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical.
[0024] Preferably, the skin color protection constraint factor is generated by substituting the skin color distortion index into a preset Gaussian function model.
[0025] Preferred, graded correction strategies include:
[0026] If the risk level is set to safe, a quality-first strategy is triggered to correct the hue, saturation, and brightness of the foreground skin tone area.
[0027] In response to a risk level of alert, a balancing strategy is triggered to suppress the magnitude of the correction and impose a preset range limit on the saturation adjustment results.
[0028] In response to a critical risk level, a safety-first strategy is triggered to prohibit adjustments to the hue and saturation of the foreground skin tone area and to fine-tune the brightness.
[0029] Preferred, quality-first strategies also include:
[0030] The Poisson image editing algorithm is used to fuse the edges of the corrected skin-colored and non-skin-colored regions.
[0031] Preferred balancing strategies also include:
[0032] The Gaussian feathering algorithm is used to blend the edges of the corrected skin-colored and non-skin-colored regions.
[0033] A person-background blending system based on adaptive skin tone protection includes:
[0034] The image preprocessing module is used to process the input raw image based on a preset deep learning segmentation model, an exposure repair network based on the UNet architecture, and a facial key point detection model, in order to generate a foreground mask, an initial foreground image, an exposure-corrected foreground image, and a binarized mask of the facial skin region in sequence.
[0035] The risk quantification module is used to calculate the skin color distortion index, which characterizes the skin color compatibility between the foreground image and the target background image after exposure correction.
[0036] The decision and control module is used to determine the risk level of the fusion task based on the comparison results of the skin color distortion index, the safety risk assessment threshold, and the critical risk assessment threshold when the critical risk assessment threshold is greater than the safety risk assessment threshold, and to generate a skin color protection constraint factor based on the skin color distortion index.
[0037] The adaptive correction module is used to trigger corresponding graded correction strategies based on the risk level, and adjust the foreground image after exposure correction in combination with the skin color protection constraint factor to generate the final foreground image.
[0038] The image synthesis module is used to synthesize the final foreground image and the target background image based on the foreground mask to output the final fused image.
[0039] Preferably, the risk quantification module is configured to perform the following operations:
[0040] The target background image is analyzed using the K-Means clustering algorithm, and the dominant color tone is extracted as the background reference color.
[0041] Within the area defined by the binarized mask, calculate the average saturation and average brightness of the foreground image after exposure correction;
[0042] Within the area defined by the binarized mask, calculate the cyclic average of all hue angles to obtain the average hue;
[0043] The skin color distortion index is obtained by weighting the background reference color, average saturation, average brightness, and average hue using preset weighting coefficients.
[0044] Preferably, the decision-making and control module is configured to perform the following operations:
[0045] If the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe.
[0046] If the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert level.
[0047] If the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical.
[0048] Compared with the prior art, the present invention has the following beneficial effects:
[0049] 1. This invention achieves intelligent prediction and avoidance of fusion risks. By quantifying the skin color compatibility between the foreground face and the background, it can identify in advance the skin color distortion problem that may be caused by excessive color difference, such as sallow or pale skin, thereby avoiding catastrophic fusion failure and significantly improving the success rate and stability of image synthesis.
[0050] 2. This invention establishes a graded correction system that precisely matches risk levels. For different risk levels, the system can automatically trigger different strategies such as quality priority, balance priority, or safety priority, boldly optimizing in low-risk situations and adhering to the bottom line of skin color authenticity in high-risk situations. This differentiated approach greatly enhances the method's adaptability and robustness.
[0051] 3. This invention introduces a smooth adaptive control mechanism, which transforms the quantified risk index into a continuously changing constraint factor, thereby achieving stepless and dynamic adjustment of the color correction intensity. This avoids abrupt changes in image effects caused by strategy switching, ensuring that the correction effect transitions naturally and the decision-making is more reasonable when dealing with various complex scenarios.
[0052] 4. This invention significantly improves the visual realism and quality of the final fused image. Through a closed-loop process of intelligent evaluation and adaptive correction, it ensures the harmonious integration of the person and the background while maximizing the protection of the natural appearance of the person's skin tone. Compared with traditional methods, this method can produce fused images with more realistic skin tones and higher overall quality. Attached Figure Description
[0053] The present invention will be further explained below with reference to the accompanying drawings and embodiments:
[0054] Figure 1 This is a flowchart of the method of the present invention;
[0055] Figure 2 This is a structural diagram of the system of the present invention. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.
[0057] Example 1:
[0058] Please see Figure 1 A method for blending people and backgrounds based on adaptive skin tone protection includes:
[0059] The input original image is processed based on a pre-defined deep learning segmentation model to generate a foreground mask;
[0060] Combine the foreground mask with the original image to obtain the initial foreground image;
[0061] The initial foreground image is processed using a pre-defined exposure repair network based on the UNet architecture, and the foreground image after exposure correction is output.
[0062] Based on the pre-set facial key point detection model, the foreground image after exposure correction is analyzed to generate a binary mask for the facial skin region.
[0063] The skin color distortion index, which characterizes the skin color compatibility between the foreground image and the target background image after exposure correction, is calculated.
[0064] Based on the comparison results of skin color distortion index, security risk assessment threshold and critical risk assessment threshold, the risk level of the fusion task is determined; both the security risk assessment threshold and the critical risk assessment threshold are preset values greater than 0, and the critical risk assessment threshold is greater than the security risk assessment threshold.
[0065] Based on the skin color distortion index, a skin color protection constraint factor is generated.
[0066] Based on the risk level, a corresponding graded correction strategy is triggered, and the foreground image after exposure correction is adjusted in combination with the skin color protection constraint factor to generate the final foreground image;
[0067] Based on the foreground mask, the final foreground image is synthesized with the target background image to output the final fused image.
[0068] This embodiment provides a method for blending people and backgrounds based on adaptive skin color protection. When blending a foreground image of a person with a new background image, it can intelligently assess the risk of skin color distortion and automatically select the optimal color correction strategy according to the risk level. This ensures a natural and harmonious blending effect while minimizing unrealistic and unattractive skin color distortion.
[0069] In a specific application scenario, a user wants to seamlessly combine a portrait photo taken in dim indoor lighting with a sunny outdoor landscape photo. Traditional methods may directly perform color transfer, causing the subject's skin tone to appear sallow or pale due to over-matching the background tone, thus destroying the realism of the subject. The method of this invention solves this problem through a closed-loop evaluation-decision-correction process.
[0070] The input raw image is processed based on a pre-defined deep learning segmentation model to generate a foreground mask, the purpose of which is to accurately separate the core subject in the image from the original background. The deep learning segmentation model is a neural network model trained on a large amount of image data, capable of recognizing and outlining the contours of specific objects in an image, such as DeepLabv3+ or MaskR-CNN. In this embodiment, the model receives a raw image. As input, output a single-channel foreground mask. Its pixel values were normalized to interval; The value of each pixel represents the probability that the location belongs to a foreground person; the closer the value is to 1, the higher the probability that it belongs to the foreground.
[0071] By combining the foreground mask with the original image, an initial foreground image is obtained. This step aims to extract the main subject from the original image using the mask generated in the previous step. This is achieved by combining the original image... With foreground mask Perform pixel-by-pixel multiplication to obtain an initial foreground image containing only the person against a black background. ;
[0072] An initial foreground image is processed using a pre-defined UNet-based exposure correction network to output an exposure-corrected foreground image. This step aims to eliminate interference from the original shooting environment on the subject's colors, laying the foundation for accurate skin tone analysis later. The UNet-based exposure correction network is a deep learning network particularly suitable for image-to-image conversion tasks; its symmetrical encoder-decoder structure effectively corrects image exposure problems. In this embodiment, the network uses the initial foreground image... As input, output an exposure-corrected foreground image with proper exposure and clear details. The innovation of this step lies in treating exposure issues as an independent variable in advance, avoiding the coupling between exposure defects and skin color, thereby significantly improving the accuracy of subsequent skin color analysis and correction.
[0073] Based on a pre-defined facial landmark detection model, the foreground image after exposure correction is analyzed to generate a binary mask for the facial skin area. The core purpose of this step is to focus skin color protection on the most critical and visually impactful facial areas, eliminating interference from other skin areas or similar colors in the background. The facial landmark detection model is an algorithm that can automatically recognize faces and locate key contour points such as eyebrows, eyes, nose, and mouth. In this embodiment, by detecting these key points and connecting their outer contours, a binary mask that only covers the facial skin area can be accurately generated. The mask This area will subsequently serve as the region of interest for all skin-related calculations, ensuring the targeted and efficient nature of skin protection.
[0074] The skin color distortion index, used to characterize the skin color compatibility between the foreground image and the target background image after exposure correction, is calculated. This step is one of the core technological innovations of this invention, aiming to quantify the potential risk of skin color distortion after fusion into a specific numerical value. Skin color distortion index It is a dimensionless parameter. The higher its value, the greater the difference in hue, saturation and brightness between the skin tone of the foreground person and the target background. The higher the risk of producing an unnatural look after forced blending.
[0075] Based on the comparison results of skin color distortion index, security risk assessment threshold, and critical risk assessment threshold, the risk level of the fusion task is determined; this step aims to qualitatively classify the risk level of the current fusion task based on the quantitative results of the previous step; security risk assessment threshold. and critical risk assessment threshold These are two key judgment boundaries. Their setting is based on statistical analysis of the subjective quality score dataset of massive fused images to determine the key inflection points in the score distribution, thereby ensuring the objectivity of risk classification and consistency with human visual perception.
[0076] Based on the skin color distortion index, a skin color protection constraint factor is generated; the purpose of this step is to transform the quantified risk index into an adjustment parameter that can be directly used to control the correction intensity; skin color protection constraint factor. It is a range of values The parameters between these parameters act like a safety valve; when the skin color distortion index... When very low, A value close to 1 allows for significant color correction; when At a very high level, The value approaches 0, thus greatly suppressing or even prohibiting color correction to protect the original skin tone;
[0077] Based on the risk level, a corresponding graded correction strategy is triggered, and the foreground image after exposure correction is adjusted in conjunction with the skin color protection constraint factor to generate the final foreground image; this is the execution link of the closed-loop control logic of this invention; the system will automatically select one of the following strategies based on the determined risk level: quality priority, balance priority, or safety priority; the adjustment range of all strategies is affected by the skin color protection constraint factor generated in the previous step. Direct modulation of the risk level enables adaptive correction that precisely matches the risk level.
[0078] Based on the foreground mask, the final foreground image and the target background image are synthesized to output the final fused image; this step utilizes the initially generated foreground mask. The final foreground image after adaptive color correction is compared with the target background image provided by the user. Pixel-level compositing is performed to obtain a final merged image in which the person and the background are perfectly blended and the skin tone is natural and realistic.
[0079] This invention establishes a closed-loop control system of risk quantification, level decision-making, and graded correction to achieve intelligent and adaptive protection against skin color distortion during the blending of people and backgrounds. Compared to the one-size-fits-all color correction methods in existing technologies, this invention can pre-assess risks and adopt drastically different blending strategies based on the level of risk. In low-risk scenarios, it can boldly optimize colors to pursue the best artistic blending effect; in high-risk scenarios, it can prioritize protecting the original skin color of the person to avoid catastrophic distortion. This intelligent decision-making capability greatly improves the success rate of image fusion and the visual quality and realism of the final image.
[0080] Example 2:
[0081] The skin color distortion index is calculated, including:
[0082] The target background image is analyzed using the K-Means clustering algorithm, and the dominant color tone is extracted as the background reference color.
[0083] Within the area defined by the binarized mask, calculate the average saturation and average brightness of the foreground image after exposure correction;
[0084] Within the area defined by the binarized mask, calculate the cyclic average of all hue angles to obtain the average hue;
[0085] The skin color distortion index is obtained by weighting the background reference color, average saturation, average brightness, and average hue using preset weighting coefficients.
[0086] This embodiment is a specific implementation of the step of calculating the skin color distortion index described in Embodiment 1. Its purpose is to construct a risk quantification model that can accurately simulate human visual perception through in-depth analysis of the color space.
[0087] The target background image is analyzed using the K-Means clustering algorithm to extract the dominant color as the background reference color. The purpose of this step is to extract the most representative color from the complex target background as the benchmark for subsequent skin tone difference calculations. The K-Means clustering algorithm is a classic unsupervised learning algorithm that can divide data points into K clusters. In this embodiment, the target background image... All pixels are used as data, and cluster analysis is performed in the HSV color space. The color of the center point of the largest cluster is defined as the background reference color. Its HSV component is ;
[0088] Within the area defined by the binarized mask, the average saturation and average brightness of the foreground image after exposure correction are calculated; this step aims to obtain the key color attributes of the skin tone of the foreground person's face; the calculation is performed using the facial skin region mask generated in Example 1. The process is conducted within a defined range to ensure data accuracy; thus, the foreground image after exposure correction is obtained. Average saturation in the facial region and average brightness ;
[0089] Within the area defined by the binary mask, the cyclic average of all hue angles is calculated to obtain the average hue. Hue is a physical quantity that cycles on a color wheel from 0 to 360 degrees, and cannot be simply averaged arithmetically. Therefore, this embodiment uses a cyclic average calculation method to process hue. This method converts hue angles into two-dimensional vectors for summation and averaging, and then converts them back to angles, thereby correctly calculating the average hue of the facial region. ;
[0090] Based on the background reference color, average saturation, average brightness, and average hue, and weighted by preset weighting coefficients, the skin tone distortion index is obtained. This step integrates the differences between the foreground skin tone and the background reference color in the three dimensions of HSV to calculate the final skin tone distortion index. Its calculation formula is:
[0091] ;
[0092] in: The average hue, saturation, and brightness of the foreground skin color calculated from the preceding steps; The hue, saturation, and brightness of the background reference color are calculated from the previous steps; The hue is calculated to correctly handle the characteristics of the hue cycle. and The formula for calculating the shortest angular distance on the color wheel is as follows (assuming the hue has been normalized to ). ): ; These are the weighting coefficients corresponding to hue, saturation, and brightness, respectively. They are dimensionless parameters and satisfy the following conditions: The weighting coefficients were determined through logistic regression analysis on a database containing a large number of labeled fusion samples, with the optimization objective being the best match based on human subjective perception. Typically, the human eye is most sensitive to saturation distortion, followed by hue distortion; therefore, the weighting coefficients generally satisfy... ;
[0093] Compared to the general description of the skin color distortion index in Example 1, this example provides a specific, quantifiable, and perceptually effective calculation method. By calculating the weighted Euclidean distance in the HSV space and specifically handling the cyclical characteristics of hues, the calculated skin color distortion index becomes more accurate. It can more accurately reflect the human eye's true perception of the color difference between the foreground and the background; this high-precision quantification capability is a solid foundation for the accurate determination of subsequent risk levels and the effective implementation of correction strategies, thereby bringing about an overall improvement in fusion quality.
[0094] Example 3:
[0095] Determining the risk level of the fusion task includes:
[0096] If the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe.
[0097] If the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert level.
[0098] If the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical.
[0099] This embodiment is a concretization of the steps for determining the risk level of the fusion task described in Embodiment 1; its underlying logic lies in establishing a clear and unambiguous rule to convert the continuous skin color distortion index calculated in the previous step into a single rule. Mapped to discrete, clearly defined risk levels;
[0100] Safety risk assessment threshold With critical risk assessment threshold These are the core parameters of this embodiment; The physical meaning of the distortion index is the upper limit of tolerable skin tone differences. When the distortion index is below this value, it is considered that color correction will hardly produce any negative effects. The physical meaning of these two thresholds is the upper limit of acceptable skin tone differences. When the distortion index exceeds this value, any form of hue and saturation adjustment is considered highly likely to lead to catastrophic visual distortion. The values of these two thresholds were determined through large-scale user research: a large number of testers were invited to subjectively rate the quality of thousands of fused images that had undergone different degrees of color correction. Based on this rating dataset, statistical analysis was used to identify two key inflection points where the rating drops sharply, and these were defined as... and ;
[0101] The logic for determining the risk level is as follows: if the skin color distortion index... If so, the risk level is determined to be safe; if If so, the risk level is determined to be alert level; if If so, the risk level is determined to be critical.
[0102] This embodiment introduces two statistically validated thresholds. and This approach divides the complex problem of skin color distortion into three distinct and actionable levels. Compared to traditional binary decision-making, this hierarchical method provides a more refined control granularity. It enables subsequent correction strategies to be tailored to specific needs, matching the most appropriate processing intensity to tasks with different risk levels. This achieves a delicate balance between pursuing optimal results and avoiding serious errors, resulting in enhanced system robustness and intelligence.
[0103] Example 4:
[0104] The skin color protection constraint factor is generated by substituting the skin color distortion index into a preset Gaussian function model.
[0105] This embodiment is a specific implementation of the skin color protection constraint factor generation method described in Embodiment 1; its purpose is to design a mathematical model that can smoothly transition discrete risk level judgments into continuous correction intensity control.
[0106] This embodiment calculates the skin color distortion index by substituting it into a preset Gaussian function model. The Gaussian function is chosen because its smooth, non-linear decay characteristics perfectly implement a soft adjustment mechanism: the lower the risk, the smaller the adjustment constraint; as the risk increases, the adjustment constraint increases rapidly. This avoids abrupt changes in image processing results caused by hard switching of strategies near risk level switching points, thus ensuring the skin color protection constraint factor. The calculation formula is as follows: ;
[0107] in, The skin color distortion index is calculated based on the implementation method of Example 2; It is the standard deviation that controls the decay rate of the Gaussian function, and its physical meaning is the risk tolerance of the system. The value of is obtained through grid search optimization on the validation set. The optimization objective is to minimize skin color deviation in high-risk samples and minimize fusion inconsistency in low-risk samples. One feasible setting is... This makes when the distortion index Reaching the critical risk threshold When, constraint factor It has decayed to a very small value, thus effectively suppressing high-risk operations;
[0108] This embodiment upgrades the system's control method from a discrete step-like approach to a continuous ramp-like approach by introducing a constraint factor generation model based on Gaussian functions. The resulting gain is significant: it allows the intensity of color correction to adjust with the risk index. The system adjusts smoothly and dynamically to the continuous changes; this refined soft control mechanism ensures that the system can make more reasonable and natural decisions when dealing with various complex scenarios, especially fuzzy cases at the risk level boundary, thereby further improving the quality and stability of the final fused image.
[0109] Example 5:
[0110] Tiered correction strategies include:
[0111] If the risk level is set to safe, a quality-first strategy is triggered to correct the hue, saturation, and brightness of the foreground skin tone area.
[0112] In response to a risk level of alert, a balancing strategy is triggered to suppress the magnitude of the correction and impose a preset range limit on the saturation adjustment results.
[0113] In response to a critical risk level, a safety-first strategy is triggered to prohibit adjustments to the hue and saturation of the foreground skin tone area and to fine-tune the brightness.
[0114] This embodiment is a concrete elaboration of the graded correction strategy; its purpose is to design a set of image correction schemes with clear focuses and matched to the risk level for three different risk levels; all correction operations will be combined with the skin color protection constraint factor generated by the method in Embodiment 4. ;
[0115] In response to a risk level of safe, i.e. If this occurs, a quality-first strategy is triggered; at this low-risk level, the skin color distortion index... The calculated constraint factor is very small. The value is close to 1; the core objective of the system is to achieve the best visual fusion effect; therefore, this strategy corrects the hue, saturation, and brightness of the foreground skin color region; for any pixel within the skin color region, the HSV component... Its adjusted value Calculated using the following formula: Set hue The range of values is First, calculate the hue difference. To ensure correction along the shortest path on the color wheel, the corrected hue difference... The calculation is as follows:
[0116]
[0117] The final calculation methods for hue, saturation, and brightness are as follows: , as well as ;because The above corrections will make the foreground skin tone fully align with the background reference color. To achieve a harmonious color transition;
[0118] In response to a risk level of alert, i.e. If this occurs, a balancing strategy will be triggered; at this medium risk level, The value is significantly attenuated; the system aims to achieve a balance between blending effect and skin tone fidelity; this strategy suppresses the magnitude of correction and imposes a preset range limit on the saturation adjustment results; it still uses the above three formulas for color correction, but because... With smaller values, the correction amplitude is automatically and smoothly suppressed; furthermore, to prevent extreme cases of oversaturation or fading of foreground skin tones, the calculated saturation is adjusted. Apply an additional hard constraint to ensure that its final value falls within [the specified range]. Within the safe range;
[0119] The response level is critical, i.e. If this occurs, a safety-first strategy is triggered; at this high-risk level, the skin color distortion index... The maximum value leads to the constraint factor. The value approaches 0; the system's primary task is to avoid catastrophic skin tone distortion and preserve the authenticity of the subject's original skin tone. Therefore, the strategy prohibits adjustments to the hue and saturation of foreground skin tone areas and fine-tunes the brightness; specifically, it adjusts the hue... and saturation Adjustments are completely prohibited, that is ; only for brightness Fine-tuning is performed to adapt to the light and dark environment of the background; the adjustment formula remains the same. However, due to The adjustments to brightness are minimal; this strategy sacrifices some blending harmony in exchange for absolute safety in skin tone expression.
[0120] The graded correction strategy provided in this embodiment is the core embodiment of the adaptive control logic of this invention. It provides differentiated and goal-oriented solutions for tasks with different risk levels, enabling the entire fusion system to have both aggressive optimization capabilities and conservative protection capabilities. When the environment is suitable, the system can pursue the ultimate aesthetic fusion; when the environment is harsh, the system can adhere to the safety bottom line and ensure the availability of the results. This high degree of scenario adaptability is unmatched by traditional fixed strategies.
[0121] Example 6:
[0122] The quality-first strategy also includes:
[0123] The Poisson image editing algorithm is used to fuse the edges of the corrected skin-colored and non-skin-colored regions.
[0124] The balancing strategy also includes:
[0125] The Gaussian feathering algorithm is used to blend the edges of the corrected skin-colored and non-skin-colored regions.
[0126] This embodiment is a further optimization of the quality-first strategy and the balance strategy in detail. Its purpose is to deal with the edge transition problem between the skin-colored areas after color correction and the non-skin-colored areas that have not been processed, so as to improve the internal harmony of the final foreground image.
[0127] In the implementation of the quality-first strategy, due to the significant color correction performed on the skin-colored area, obvious color difference boundaries may appear between the skin-colored area and the adjacent non-skin-colored area. To solve this problem, this embodiment further includes: using the Poisson image editing algorithm to fuse the edges of the corrected skin-colored area and the non-skin-colored area. The Poisson image editing algorithm is an image fusion technique based on solving the Poisson equation. Its core advantage lies in its ability to maintain the gradient information of the source region while seamlessly matching the boundary pixel values of the target region. This makes the transition zone between the two regions smooth and preserves the texture details of the skin, achieving the highest quality edge fusion.
[0128] In the execution of the balancing strategy, the color correction amplitude itself has been suppressed, and the abruptness of the edges is relatively low. At the same time, considering that the balancing strategy aims to achieve a balance between efficiency and effect, this embodiment further includes: using a Gaussian feathering algorithm to blend the edges of the corrected skin-colored area and the non-skin-colored area. The Gaussian feathering algorithm is a fast algorithm that achieves a smooth transition by applying Gaussian blur to the edge area. Although it is not as good as Poisson editing in terms of detail preservation, it has low computational overhead and fast processing speed, which is sufficient to achieve an acceptable and natural edge blending effect in medium-risk scenarios.
[0129] This embodiment deeply integrates edge processing technology with risk levels, resulting in a synergistic gain effect. This is not only reflected in the refined visual effects of different strategies, but also in the intelligent allocation of computing resources. In the quality-first strategy that pursues ultimate quality, Poisson editing, which has a higher computational cost, is used to achieve the best results. In the balance strategy that emphasizes balance, Gaussian feathering, which is more efficient, is selected to match its strategy objective. This design of adaptively selecting post-processing algorithms based on risk levels makes the technical solution of this invention more complete, efficient, and intelligent overall.
[0130] Example 7:
[0131] Please see Figure 2 A person-background blending system based on adaptive skin tone protection includes:
[0132] The image preprocessing module is used to process the input raw image based on a preset deep learning segmentation model, an exposure repair network based on the UNet architecture, and a facial key point detection model, in order to generate a foreground mask, an initial foreground image, an exposure-corrected foreground image, and a binarized mask of the facial skin region in sequence.
[0133] The risk quantification module is used to calculate the skin color distortion index, which characterizes the skin color compatibility between the foreground image and the target background image after exposure correction.
[0134] The decision and control module is used to determine the risk level of the fusion task based on the comparison results of the skin color distortion index, the safety risk assessment threshold, and the critical risk assessment threshold when the critical risk assessment threshold is greater than the safety risk assessment threshold, and to generate a skin color protection constraint factor based on the skin color distortion index.
[0135] The adaptive correction module is used to trigger corresponding graded correction strategies based on the risk level, and adjust the foreground image after exposure correction in combination with the skin color protection constraint factor to generate the final foreground image.
[0136] The image synthesis module is used to synthesize the final foreground image and the target background image based on the foreground mask to output the final fused image.
[0137] This embodiment provides a person-background blending system based on adaptive skin tone protection. The system is designed with a modular structure to clearly execute the various technical steps described in this invention.
[0138] The system includes: an image preprocessing module for processing the input raw image based on a preset deep learning segmentation model, an exposure repair network based on the UNet architecture, and a facial keypoint detection model, to sequentially generate a foreground mask, an initial foreground image, an exposure-corrected foreground image, and a binary mask of the facial skin region; a risk quantization module for calculating a skin color distortion index to characterize the skin color compatibility between the exposure-corrected foreground image and the target background image; a decision and control module for determining the risk level of the fusion task based on the comparison results of the skin color distortion index, the safety risk assessment threshold, and the critical risk assessment threshold when the critical risk assessment threshold is greater than the safety risk assessment threshold, and generating a skin color protection constraint factor based on the skin color distortion index; an adaptive correction module for triggering a corresponding graded correction strategy according to the risk level and adjusting the exposure-corrected foreground image in combination with the skin color protection constraint factor to generate the final foreground image; and an image synthesis module for compositing the final foreground image and the target background image based on the foreground mask to output the final fused image.
[0139] The system architecture proposed in this embodiment clearly decouples the complex method process into five functionally independent modules. This modular design makes the implementation and maintenance of the system more convenient, and each module can be developed, tested, and upgraded independently. The clear module division and data flow ensure the efficiency and stability of the entire processing. This architecture also provides great flexibility for introducing more advanced algorithms to replace specific modules in the future, ensuring the scalability and long-term technical competitiveness of the system.
[0140] Example 8:
[0141] The risk quantification module is configured to perform the following operations:
[0142] The target background image is analyzed using the K-Means clustering algorithm, and the dominant color tone is extracted as the background reference color.
[0143] Within the area defined by the binarized mask, calculate the average saturation and average brightness of the foreground image after exposure correction;
[0144] Within the area defined by the binarized mask, calculate the cyclic average of all hue angles to obtain the average hue;
[0145] The skin color distortion index is obtained by weighting the background reference color, average saturation, average brightness, and average hue using preset weighting coefficients.
[0146] This embodiment describes a specific configuration of the risk quantification module in the system. This configuration ensures the accuracy and perceptual effectiveness of the risk quantification process. In this configuration, the risk quantification module is specifically configured to perform the following operations: analyze the target background image using the K-Means clustering algorithm and extract the dominant color tone as the background reference color; calculate the average saturation and average brightness of the foreground image after exposure correction within the area defined by the binarized mask; calculate the cyclic average of all color tone angles within the area defined by the binarized mask to obtain the average color tone; and calculate the skin color distortion index by weighting the background reference color, average saturation, average brightness, and average color tone using preset weighting coefficients.
[0147] By configuring the risk quantification module with the specific operational procedures described above, this system gains the ability to accurately quantify the risk of skin color distortion. It ensures that the core risk assessment process of the system is not a black box, but rather based on a clear algorithm that conforms to the principles of color science and human visual perception. This makes the system's decision-making foundation more solid and reliable, thereby directly improving the accuracy and effectiveness of all subsequent adaptive control behaviors.
[0148] Example 9:
[0149] The decision and control module is configured to perform the following operations:
[0150] If the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe.
[0151] If the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert level.
[0152] If the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical.
[0153] This embodiment describes a specific configuration of the decision-making and control module in the system. This configuration ensures the logical clarity and rule explicitness of the decision-making process. In this configuration, the decision-making and control module is specifically configured to perform the following operations: if the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe; if the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert; if the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical.
[0154] By configuring the decision-making and control modules with the specific operational logic described above, this system establishes a clear, rule-based decision-making core. It efficiently and unambiguously converts the continuous risk values calculated by the upstream modules into discrete instructions that the downstream modules can directly execute. This ensures the clarity and accuracy of the instruction transmission chain from risk perception to strategy execution, and guarantees that the system can make predictable and logically consistent responses to any input, greatly enhancing the stability and reliability of the system.
[0155] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for blending people and backgrounds based on adaptive skin tone protection, characterized in that, include: The input original image is processed based on a pre-defined deep learning segmentation model to generate a foreground mask; Combine the foreground mask with the original image to obtain the initial foreground image; The initial foreground image is processed using a pre-defined exposure repair network based on the UNet architecture, and the foreground image after exposure correction is output. Based on the pre-set facial key point detection model, the foreground image after exposure correction is analyzed to generate a binary mask for the facial skin region. The skin color distortion index, which characterizes the skin color compatibility between the foreground image and the target background image after exposure correction, is calculated. The skin color distortion index is compared with the preset security risk assessment threshold and the critical risk assessment threshold to determine the risk level of the fusion task; Based on the skin color distortion index, a skin color protection constraint factor is generated. Based on the risk level, a corresponding graded correction strategy is triggered, and the foreground image after exposure correction is adjusted in combination with the skin color protection constraint factor to generate the final foreground image; Based on the foreground mask, the final foreground image and the target background image are synthesized to output the final fused image; Determining the risk level of the fusion task includes: If the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe. If the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert level. If the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical. Graded correction strategies include: If the risk level is set to safe, a quality-first strategy is triggered to correct the hue, saturation, and brightness of the foreground skin tone area. In response to a risk level of alert, a balancing strategy is triggered to suppress the magnitude of the correction and impose a preset range limit on the saturation adjustment results. In response to a critical risk level, a safety-first strategy is triggered to prohibit adjustments to the hue and saturation of the foreground skin tone area and to fine-tune the brightness.
2. The method for blending people and backgrounds based on adaptive skin tone protection according to claim 1, characterized in that, The skin color distortion index is calculated, including: The target background image is analyzed using the K-Means clustering algorithm, and the dominant color tone is extracted as the background reference color. Within the area defined by the binarized mask, calculate the average saturation and average brightness of the foreground image after exposure correction; Within the area defined by the binarized mask, calculate the cyclic average of all hue angles to obtain the average hue; The skin color distortion index is obtained by weighting the background reference color, average saturation, average brightness, and average hue using preset weighting coefficients.
3. The method for blending people and backgrounds based on adaptive skin tone protection according to claim 1, characterized in that, The skin color protection constraint factor is generated by substituting the skin color distortion index into a preset Gaussian function model.
4. The method for blending a person and background based on adaptive skin tone protection according to claim 1, characterized in that, The quality-first strategy also includes: The Poisson image editing algorithm is used to fuse the edges of the corrected skin-colored and non-skin-colored regions.
5. The method for blending people and backgrounds based on adaptive skin tone protection according to claim 1, characterized in that, The balancing strategy also includes: The Gaussian feathering algorithm is used to blend the edges of the corrected skin-colored and non-skin-colored regions.
6. A person-background blending system based on adaptive skin tone protection, based on the person-background blending method based on adaptive skin tone protection according to any one of claims 1-5, characterized in that, include: The image preprocessing module is used to process the input raw image based on a preset deep learning segmentation model, an exposure repair network based on the UNet architecture, and a facial key point detection model, in order to generate a foreground mask, an initial foreground image, an exposure-corrected foreground image, and a binarized mask of the facial skin region in sequence. The risk quantification module is used to calculate the skin color distortion index, which characterizes the skin color compatibility between the foreground image and the target background image after exposure correction. The decision and control module is used to compare the skin color distortion index with the preset security risk assessment threshold and critical risk assessment threshold to determine the risk level of the fusion task, and generate skin color protection constraint factors based on the skin color distortion index. The adaptive correction module is used to trigger corresponding graded correction strategies based on the risk level, and adjust the foreground image after exposure correction in combination with the skin color protection constraint factor to generate the final foreground image. The image synthesis module is used to synthesize the final foreground image and the target background image based on the foreground mask to output the final fused image.
7. A person-background blending system based on adaptive skin tone protection according to claim 6, characterized in that, The risk quantification module is configured to perform the following operations: The target background image is analyzed using the K-Means clustering algorithm, and the dominant color tone is extracted as the background reference color. Within the area defined by the binarized mask, calculate the average saturation and average brightness of the foreground image after exposure correction; Within the area defined by the binarized mask, calculate the cyclic average of all hue angles to obtain the average hue; The skin color distortion index is obtained by weighting the background reference color, average saturation, average brightness, and average hue using preset weighting coefficients.
8. A person-background blending system based on adaptive skin tone protection according to claim 6, characterized in that, The decision and control module is configured to perform the following operations: If the skin color distortion index is not greater than the safety risk assessment threshold, the risk level is determined to be safe. If the skin color distortion index is greater than the safety risk assessment threshold but not greater than the critical risk assessment threshold, the risk level is determined to be alert level. If the skin color distortion index is greater than the critical risk assessment threshold, the risk level is determined to be critical.
Citation Information
Patent Citations
Human face and body fusion processing method and system
CN107680071A
Shooting method and device
CN115589526A