Image processing method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202310007350.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-04
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-01-04
AI Technical Summary
[0004]由于设计师人工修图所得的没有抬头纹的图像,可能存在不真实自然的情况,导致实际应用中,从训练后的深度模型所输出的图像的去抬头纹效果不够真实自然
[0102]本公开实施例提供的技术方案,获取人脸图像,该人脸图像包括待平滑皱纹的目标区域;通过不同的图像模糊算法对目标区域中属于皮肤且属于皱纹的目标像素点进行不同程度的模糊处理,得到目标像素点对应的第一低频信息和第二低频信息;并基于目标像素点对应的第一低频信息和第二低频信息,确定目标像素点对应的皱纹强度,以及目标像素点第一平滑皱纹后的像素点;最终基于目标像素点在目标区域的原始像素值,以及目标像素点第一平滑皱纹后的像素值的加权结果,得到目标像素点第二平滑皱纹后的目标像素值。计算所得的目标像素值实现了将平滑皱纹后对应的像素值与原始像素值进行结合。
Smart Images

Figure CN115909466B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and in particular to an image processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Because beautification technology can enhance the appearance of people in images, it has been widely used in image processing. In portraits, wrinkles such as forehead wrinkles are a very obvious sign of facial aging. Therefore, in the beautification process, it is common to encounter situations where wrinkles such as forehead wrinkles are removed.
[0003] Taking forehead wrinkles as an example, related technologies can remove them by training a deep learning model. However, training a deep learning model requires collecting a large number of paired training samples; for example, it requires collecting paired images of the same face with and without forehead wrinkles. In practical applications, designers need to manually edit images to process a large number of faces with forehead wrinkles to obtain images without them, so that a deep learning model for removing forehead wrinkles can be trained using images of the same face with and without forehead wrinkles.
[0004] Because images without forehead wrinkles obtained through manual retouching by designers may appear unnatural, the effect of removing forehead wrinkles from images output by trained deep learning models is not realistic or natural in practical applications. Summary of the Invention
[0005] To address the aforementioned technical problems in related technologies, the technical solution disclosed herein is as follows:
[0006] In a first aspect, embodiments of this disclosure provide an image processing method, including:
[0007] Acquire a face image; the face image includes the target area for smoothing wrinkles;
[0008] Different image blurring algorithms are used to blur the target pixels to different degrees to obtain the first low-frequency information and the second low-frequency information corresponding to the target pixels; the target pixels are those belonging to the skin and wrinkles in the target region.
[0009] Based on the first low-frequency information and the second low-frequency information corresponding to the target pixel, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined.
[0010] Based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the target pixel, the target pixel value after the second smoothing of the target pixel is obtained; the weighting coefficient of the pixel value after the first smoothing of the target pixel is positively correlated with the wrinkle intensity, and the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity.
[0011] Optionally, after acquiring the face image, the process further includes:
[0012] Obtain the first probability and the second probability corresponding to each pixel in the target area; the first probability corresponding to a pixel is the probability that the pixel belongs to a wrinkle, and the second probability corresponding to a pixel is the probability that the pixel belongs to skin;
[0013] Based on the first probability and the second probability corresponding to each pixel, the target pixel in the target region is determined; the first probability corresponding to the target pixel is greater than a first threshold, and the second probability corresponding to the target pixel is greater than a second threshold.
[0014] Optionally, determining the wrinkle intensity corresponding to the target pixel and the pixel value of the target pixel after smoothing the first wrinkle, based on the first low-frequency information and the second low-frequency information corresponding to the target pixel, includes:
[0015] The wrinkle intensity corresponding to the target pixel is determined based on the difference between the first low-frequency information and the second low-frequency information corresponding to the target pixel.
[0016] Based on the first low-frequency information corresponding to the target pixel, the high-frequency information corresponding to the target pixel is determined, and the sum of the high-frequency information and the second low-frequency information corresponding to the target pixel is determined as the pixel value of the target pixel after the first smoothing wrinkle.
[0017] Optionally, the target pixel is blurred using an image blurring algorithm to obtain the first low-frequency information corresponding to the target pixel, including:
[0018] Determine the first target window;
[0019] For the first center pixel of the first target window, when the first center pixel is the target pixel, the pixel values corresponding to multiple first neighborhood pixels are determined respectively; the multiple first neighborhood pixels are the pixels in the first target window other than the first center pixel.
[0020] Based on the pixel value of the first center pixel and the pixel values corresponding to the plurality of first neighboring pixels, Gaussian blurring is performed on the first center pixel to obtain the first low-frequency information of the first center pixel.
[0021] Move the first target window. If the first center pixel of the moved first target window is the target pixel, return to the step of determining the pixel values corresponding to the multiple first neighborhood pixels, until the first low-frequency information of each target pixel in the target area is obtained.
[0022] Optionally, determining the pixel values corresponding to the plurality of first neighborhood pixels includes:
[0023] For each first neighboring pixel, based on the first probability and the second probability corresponding to the first neighboring pixel, determine whether the first neighboring pixel is the target pixel;
[0024] When the first neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target region is determined as the pixel value of the first neighboring pixel.
[0025] If the first neighboring pixel is not the target pixel, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel.
[0026] Optionally, the target pixel is blurred using an image blurring algorithm to obtain the second low-frequency information corresponding to the target pixel, including:
[0027] Determine the second target window;
[0028] For the second center pixel of the second target window, when the second center pixel is the target pixel, the mean-weighted blur processing step size is determined based on the width ratio coefficient and the height ratio coefficient; wherein, the width ratio coefficient is the ratio of the width of the face region to the width of the face image, the height ratio coefficient is the ratio of the height of the face region to the height of the face image, and the mean-weighted blur processing step size is proportional to both the width ratio coefficient and the height ratio coefficient;
[0029] Based on the mean-weighted fuzzing step size, a plurality of second neighboring pixels of the second center pixel are determined;
[0030] Determine the pixel values corresponding to the plurality of second-domain pixels respectively;
[0031] Based on the pixel value of the second center pixel and the pixel values of the plurality of second neighboring pixels, the second center pixel is subjected to mean-weighted blurring processing to obtain the second low-frequency information of the second center pixel;
[0032] Move the second target window. If the second center pixel of the moved second target window is the target pixel, return to perform the determination of multiple second neighboring pixels of the second center pixel based on the mean-weighted fuzzing step size, until the second low-frequency information of each target pixel in the target area is obtained.
[0033] Optional, also includes:
[0034] Obtain the coordinates of facial key points in the face image, including the face center point, eyebrow key points, and cheek key points;
[0035] Based on the coordinates of the face center point and the eyebrow key point, the coordinates of the forehead key point in the target area are calculated, and based on the coordinates of the face center point and the cheek key point, the coordinates of the pixel points located on the outer border of the face in the face image are calculated.
[0036] Determine the target bounding rectangle of the face region in the face image, wherein the target bounding rectangle is the smallest bounding rectangle used to enclose the face outline pixels and the forehead key points;
[0037] Based on the width of the target bounding rectangle and the width of the face image, calculate the proportion coefficient of the face region to the width of the face image, and based on the height of the target bounding rectangle and the height of the face image, calculate the proportion coefficient of the face region to the height of the face image.
[0038] Optionally, determining the pixel values corresponding to the plurality of second neighborhood pixels includes:
[0039] Obtain the first probability and the second probability corresponding to the plurality of second neighboring pixels respectively;
[0040] For each second neighboring pixel, based on the first probability and the second probability corresponding to the second neighboring pixel, determine whether the second neighboring pixel is the target pixel;
[0041] When the second neighboring pixel is the target pixel, the original pixel value of the second neighboring pixel in the target region is determined as the pixel value of the second neighboring pixel.
[0042] If the second neighboring pixel is not the target pixel, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel.
[0043] Optionally, determining the high-frequency information corresponding to the target pixel based on the first low-frequency information corresponding to the target pixel includes:
[0044] The first high-frequency information corresponding to the target pixel is calculated using the first low-frequency information corresponding to the target pixel.
[0045] In the face image, skin pixels belonging to the skin are selected, and based on the first low-frequency information corresponding to the skin pixels, the second high-frequency information corresponding to the skin pixels is determined.
[0046] Calculate the first information intensity of the first high-frequency information corresponding to the target pixel, and calculate the second information intensity of the second high-frequency information corresponding to the skin pixel;
[0047] When the intensity of the first information is less than the intensity of the second information, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel; when the intensity of the first information is greater than the intensity of the second information, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel.
[0048] Optionally, obtaining the first probability corresponding to each pixel in the target region includes:
[0049] The face image is input into a pre-trained probability detection model to obtain the initial first probability corresponding to each pixel in the target region;
[0050] For a pixel whose initial first probability is less than the third threshold, the initial first probability corresponding to the pixel is increased to obtain the first probability corresponding to the pixel; the third threshold is less than the first threshold, and the first probability corresponding to the pixel is greater than the first threshold.
[0051] In a second aspect, embodiments of this disclosure provide an image processing apparatus, comprising:
[0052] A face image acquisition module is configured to acquire a face image; the face image includes a target area for smoothing wrinkles;
[0053] The image blurring module is configured to perform different degrees of blurring on the target pixel using different image blurring algorithms to obtain first low-frequency information and second low-frequency information corresponding to the target pixel; the target pixel is a pixel in the target region that belongs to the skin and wrinkles.
[0054] The information determination module is configured to perform an operation based on the first low-frequency information and the second low-frequency information corresponding to the target pixel to determine the wrinkle intensity corresponding to the target pixel and the pixel value of the target pixel after the first smoothing of the wrinkles.
[0055] The target pixel value determination module is configured to perform a weighted result based on the original pixel value of the target pixel in the target region and the pixel value of the target pixel after the first smoothing wrinkle, to obtain the target pixel value after the second smoothing wrinkle; the weighting coefficient of the pixel value of the target pixel after the first smoothing wrinkle is positively correlated with the wrinkle intensity, and the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity.
[0056] Optional, also includes:
[0057] The probability acquisition module is configured to, after the face image acquisition module acquires the face image, acquire the first probability and the second probability corresponding to each pixel in the target region; the first probability corresponding to a pixel is the probability that the pixel belongs to a wrinkle, and the second probability corresponding to a pixel is the probability that the pixel belongs to skin;
[0058] The target pixel determination module is configured to determine the target pixel in the target region based on the first probability and the second probability corresponding to each pixel; wherein the first probability corresponding to the target pixel is greater than a first threshold, and the second probability corresponding to the target pixel is greater than a second threshold.
[0059] Optionally, the information determination module is specifically configured to execute:
[0060] The wrinkle intensity corresponding to the target pixel is determined based on the difference between the first low-frequency information and the second low-frequency information corresponding to the target pixel.
[0061] Based on the first low-frequency information corresponding to the target pixel, the high-frequency information corresponding to the target pixel is determined, and the sum of the high-frequency information and the second low-frequency information corresponding to the target pixel is determined as the pixel value of the target pixel after the first smoothing wrinkle.
[0062] Optionally, the image blurring module shown is configured to perform:
[0063] Determine the first target window;
[0064] For the first center pixel of the first target window, when the first center pixel is the target pixel, the pixel values corresponding to multiple first neighborhood pixels are determined respectively; the multiple first neighborhood pixels are the pixels in the first target window other than the first center pixel.
[0065] Based on the pixel value of the first center pixel and the pixel values corresponding to the plurality of first neighboring pixels, Gaussian blurring is performed on the first center pixel to obtain the first low-frequency information of the first center pixel.
[0066] Move the first target window. If the first center pixel of the moved first target window is the target pixel, return to the step of determining the pixel values corresponding to the multiple first neighborhood pixels, until the first low-frequency information of each target pixel in the target area is obtained.
[0067] Optionally, the image blurring module shown is configured to perform:
[0068] For each first neighboring pixel, based on the first probability and the second probability corresponding to the first neighboring pixel, determine whether the first neighboring pixel is the target pixel;
[0069] When the first neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target region is determined as the pixel value of the first neighboring pixel.
[0070] If the first neighboring pixel is not the target pixel, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel.
[0071] Optionally, the image blurring module shown is configured to perform:
[0072] Determine the second target window;
[0073] For the second center pixel of the second target window, when the second center pixel is the target pixel, the mean-weighted blur processing step size is determined based on the width ratio coefficient and the height ratio coefficient; wherein, the width ratio coefficient is the ratio of the width of the face region to the width of the face image, the height ratio coefficient is the ratio of the height of the face region to the height of the face image, and the mean-weighted blur processing step size is proportional to both the width ratio coefficient and the height ratio coefficient;
[0074] Based on the mean-weighted fuzzing step size, a plurality of second neighboring pixels of the second center pixel are determined;
[0075] Determine the pixel values corresponding to the plurality of second-domain pixels respectively;
[0076] Based on the pixel value of the second center pixel and the pixel values of the plurality of second neighboring pixels, the second center pixel is subjected to mean-weighted blurring processing to obtain the second low-frequency information of the second center pixel;
[0077] Move the second target window. If the second center pixel of the moved second target window is the target pixel, return to perform the determination of multiple second neighboring pixels of the second center pixel based on the mean-weighted fuzzing step size, until the second low-frequency information of each target pixel in the target area is obtained.
[0078] Optional, also includes:
[0079] The coordinate determination module is configured to obtain the coordinates of facial key points in the face image, including the face center point, eyebrow key points, and cheek key points.
[0080] The coordinate calculation module is configured to calculate the coordinates of the forehead key point in the target area based on the coordinates of the face center point and the eyebrow key point, and to calculate the coordinates of the pixel points located on the outer border of the face in the face image based on the coordinates of the face center point and the cheek key point.
[0081] The bounding rectangle determination module is configured to determine the target bounding rectangle of the face region in the face image, wherein the target bounding rectangle is the smallest bounding rectangle used to enclose the face outline pixels and the forehead key points;
[0082] A width and height determination module is configured to determine the width and height of the target bounding rectangle;
[0083] The scaling factor determination module is configured to calculate the width scaling factor of the face region to the face image based on the width of the target bounding rectangle and the width of the face image, and to calculate the height scaling factor of the face region to the face image based on the height of the target bounding rectangle and the height of the face image.
[0084] Optionally, the image blurring module is configured to perform:
[0085] For each second neighboring pixel, based on the first probability and the second probability corresponding to the second neighboring pixel, determine whether the second neighboring pixel is the target pixel;
[0086] When the second neighboring pixel is the target pixel, the original pixel value of the second neighboring pixel in the target region is determined as the pixel value of the second neighboring pixel.
[0087] If the second neighboring pixel is not the target pixel, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel.
[0088] Optionally, the information determination module is specifically configured to execute:
[0089] The first high-frequency information corresponding to the target pixel is calculated using the first low-frequency information corresponding to the target pixel.
[0090] In the face image, skin pixels belonging to the skin are selected, and based on the first low-frequency information corresponding to the skin pixels, the second high-frequency information corresponding to the skin pixels is determined.
[0091] Calculate the first information intensity of the first high-frequency information corresponding to the target pixel, and calculate the second information intensity of the second high-frequency information corresponding to the skin pixel;
[0092] When the intensity of the first information is less than the intensity of the second information, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel; when the intensity of the first information is greater than the intensity of the second information, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel.
[0093] Optionally, the probability acquisition module is configured to execute:
[0094] The face image is input into a pre-trained probability detection model to obtain the initial first probability corresponding to each pixel in the target region;
[0095] For a pixel whose initial first probability is less than the third threshold, the initial first probability corresponding to the pixel is increased to obtain the first probability corresponding to the pixel; the third threshold is less than the first threshold, and the first probability corresponding to the pixel is greater than the first threshold.
[0096] Thirdly, embodiments of this disclosure provide an electronic device, including:
[0097] processor;
[0098] Memory used to store the processor's executable instructions;
[0099] The processor is configured to execute the instructions to implement the method as described in the first aspect.
[0100] Fourthly, embodiments of this disclosure provide a computer-readable storage medium that, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method described in the first aspect.
[0101] Fifthly, embodiments of this disclosure provide a computer program product that, when run on a computer, causes the computer to perform the method described in the first aspect.
[0102] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0103] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural. Attached Figure Description
[0104] Figure 1 This is a flowchart illustrating an image processing method according to an exemplary embodiment;
[0105] Figure 2 This is a flowchart illustrating another image processing method according to an exemplary embodiment;
[0106] Figure 3 yes Figure 1 A flowchart of one embodiment of step S130 in the illustrated example;
[0107] Figure 4 yes Figure 3 A flowchart of one embodiment of step S132 in the illustrated example;
[0108] Figure 5 yes Figure 1 A flowchart of one embodiment of step S120 in the illustrated example;
[0109] Figure 6 yes Figure 5A flowchart of one embodiment of step S520 in the illustrated example;
[0110] Figure 7 This is a flowchart illustrating an implementation method for determining the height ratio coefficient of a face region in a face image, as provided in this disclosure.
[0111] Figure 8 yes Figure 1 A flowchart of another implementation of step S120 in the illustrated embodiment;
[0112] Figure 9 yes Figure 8 A flowchart of another implementation of step S840 in the illustrated embodiment;
[0113] Figure 10 This is a block diagram illustrating an image processing apparatus according to an exemplary embodiment;
[0114] Figure 11 This is a block diagram illustrating another image processing apparatus according to an exemplary embodiment. Detailed Implementation
[0115] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0116] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0117] Because beautification technology can enhance the appearance of people in images, it has been widely used in image processing. In portraits, wrinkles such as forehead wrinkles are a very obvious sign of facial aging. Therefore, in the beautification process, it is common to encounter situations where wrinkles such as forehead wrinkles are removed.
[0118] Taking forehead wrinkles as an example, related technologies can remove them by training a deep learning model. However, training a deep learning model requires collecting a large number of paired training samples; for example, it requires collecting paired images of the same face with and without forehead wrinkles. In practical applications, designers need to manually edit images to process a large number of faces with forehead wrinkles to obtain images without them, so that a deep learning model for removing forehead wrinkles can be trained using images of the same face with and without forehead wrinkles.
[0119] Because images without forehead wrinkles obtained through manual retouching by designers may appear unnatural, the wrinkle-removing effect of images output from trained deep learning models in practical applications may not be realistic enough. Furthermore, training a deep learning model for forehead wrinkle removal requires significant resources.
[0120] Therefore, embodiments of this disclosure provide an image processing method, apparatus, electronic device, and storage medium.
[0121] Firstly, a detailed description of an image processing method provided by an embodiment of this disclosure will be given.
[0122] like Figure 1 As shown in the embodiments of this disclosure, an image processing method may include the following steps:
[0123] S110, acquire face image.
[0124] The facial image includes the target area for smoothing wrinkles.
[0125] Specifically, the face image can be any image including a person's frontal face. The face image can be acquired in real time or from an existing face image obtained from a terminal or server; this disclosure does not specifically limit the method.
[0126] Furthermore, the facial image can include the target area for smoothing wrinkles, meaning the texture features of the target area include wrinkle texture features. In practical applications, this target area can be the forehead area with forehead wrinkles, etc., and the forehead area can be the area above the eyebrows and below the hairline on the face.
[0127] S120: Different image blurring algorithms are used to blur the target pixels to different degrees to obtain the first low-frequency information and the second low-frequency information corresponding to the target pixels.
[0128] The target pixel is a pixel in the target region that belongs to the skin and is a wrinkle.
[0129] Specifically, in order to weaken or remove wrinkles such as forehead lines in facial images, after acquiring the facial image, target pixels belonging to skin and wrinkles in the target area can be identified so that wrinkle weakening or removal operations can be performed on these target pixels. For clarity, the specific implementation methods for determining target pixels will be described in detail in the following embodiments.
[0130] After determining the target pixel to be processed, different image blurring algorithms can be used to blur the target pixel to different degrees to obtain the first low-frequency information and the second low-frequency information corresponding to the target pixel.
[0131] Specifically, the target pixel can be blurred using a first image blurring algorithm to obtain the first low-frequency information D corresponding to the target pixel. f1 The first image blurring algorithm can be a Gaussian blurring algorithm. The target pixel can be blurred using a second image blurring algorithm to obtain the second low-frequency information D corresponding to the target pixel. f2 The second image blurring algorithm can be a mean-weighted blurring algorithm.
[0132] By applying different degrees of blurring to the target pixels using two different image blurring algorithms, the resulting first low-frequency information D... f1 Second low frequency information D f2 Essentially, these are fuzzy information of varying degrees of fuzziness, reflecting image features of different frequency bands. In subsequent steps, subtracting the image features of different frequency bands can yield some structural information, such as the location and intensity of forehead wrinkles in a face image.
[0133] To ensure clarity, the specific implementation of S120 will be described in detail in the following embodiments.
[0134] S130, based on the first low-frequency information and the second low-frequency information corresponding to the target pixel, determine the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkle.
[0135] As described above, the first low-frequency information and the second low-frequency information are obtained by blurring the target pixel to different degrees. Therefore, the first low-frequency information and the second low-frequency information reflect the image features of the target pixel in different frequency bands. By subtracting the first low-frequency information and the second low-frequency information, the wrinkle intensity corresponding to the target pixel can be obtained. Furthermore, the pixel value of the target pixel after smoothing the wrinkles can be obtained through the first low-frequency information and the second low-frequency information. For clarity, the obtained pixel value of the target pixel after smoothing the wrinkles is referred to as the first smoothed wrinkle pixel value of the target pixel.
[0136] To ensure clarity, the specific implementation of S130 will be described in detail in the following embodiments.
[0137] S140: Based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing wrinkle of the target pixel, the target pixel value after the second smoothing wrinkle is obtained.
[0138] Among them, the weighting coefficient of the pixel value after the first smoothing of the target pixel is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity.
[0139] In this step, the final output pixel value of the processed target pixel is determined, i.e., the target pixel value in the processed face image. Specifically, the original pixel value of the target pixel in the target region can be weighted and calculated with the pixel value after the first smoothing of wrinkles. Furthermore, the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity. In practical applications, the wrinkle intensity calculated in S130 can be determined as the weighting coefficient of the pixel value after the first smoothing of wrinkles, and the difference between a preset value and the wrinkle intensity can be determined as the weighting coefficient of the original pixel value, where the preset value can be 1.
[0140] For example, taking forehead wrinkles as an example, the target pixel value is denoted as I. out The pixel value corresponding to the first smoothed wrinkle of the target pixel is denoted as I. tmp The original pixel value is I, I diff For wrinkle intensity, then,
[0141] I out =(1-I diff )*I+I diff *I tmp
[0142] The target pixel value calculated using this formula achieves the pixel value I obtained after smoothing the first forehead wrinkles. tmp Combine it with the pixel value I in the original face image.
[0143] For the relatively strong dark areas of forehead wrinkles, i.e., the areas where the forehead wrinkles are deeper, at this time, I diff It can be 1, in which case, I out =I tmp Evenly brightening while preserving texture details, using I tmp To replace the pixel values of the original face image.
[0144] For target pixels in relatively bright areas, i.e., areas with shallower forehead wrinkles, I out =(1-Idiff )*I+I diff *I tmp That is, using a certain proportion of I diff I after uniform darkening tmp This is combined with the pixel values in the original face image to darken relatively bright areas, resulting in a smoother, more natural-looking forehead wrinkle area after processing.
[0145] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0146] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural.
[0147] In the above Figure 1 Based on the illustrated embodiment, in one implementation, after acquiring the face image, as shown... Figure 2 As shown, the image processing method may further include the following steps:
[0148] S120a, obtain the first probability and the second probability corresponding to each pixel in the target area.
[0149] Among them, the first probability corresponding to a pixel is the probability that the pixel belongs to a wrinkle, and the second probability corresponding to a pixel is the probability that the pixel belongs to skin.
[0150] Specifically, after obtaining a face image, the face image can be input into a pre-trained probability detection model. The probability detection model outputs the first probability and the second probability corresponding to each pixel in the face image, thereby obtaining the first probability and the second probability corresponding to each pixel in the target region.
[0151] The first probability for a pixel is the probability that the pixel belongs to a wrinkle. The magnitude of the first probability is between 0 and 1. For example, if a pixel is located in a forehead wrinkle area of the target region, and the forehead wrinkle at that location is relatively deep, then the first probability for that pixel is relatively high, for example, it can be 1. As another example, if a pixel is located in a forehead wrinkle area of the target region, and the forehead wrinkle at that location is relatively shallow, then the first probability for that pixel is relatively low, for example, it can be 0.6.
[0152] The second probability for a pixel is the probability that the pixel belongs to the skin region. The magnitude of the second probability is also between 0 and 1. Specifically, the second probability for a given pixel can be understood as the probability that the pixel belongs to the skin. If the pixel is located on the skin, then the second probability for that pixel is relatively high, for example, it can be 1; if the pixel is not located on the skin, for example, a pixel located in the eyeball region, then the second probability for that pixel is relatively low, for example, it can be 0.
[0153] The training process of the above-mentioned probability detection model can be as follows: collect a large number of sample face images including the target region, and calibrate the first probability and second probability of the pixels in the sample face images. Output the calibrated sample face images to the probability detection model to be trained, train the probability detection model to be trained, and calculate the loss function value of the probability detection model based on the output probability and the calibrated probability. When the loss function value is less than a preset threshold, the trained probability detection model is obtained.
[0154] In one implementation, obtaining the first probability corresponding to each pixel in the target region may include the following steps, namely step a and step b:
[0155] Step a: Input the face image into the pre-trained probability detection model to obtain the initial first probability corresponding to each pixel in the target region.
[0156] Specifically, by inputting a face image into a pre-trained probability detection model, the probability of each pixel in the target region belonging to a wrinkle is obtained. For clarity, the probability output from the probability detection model is called the initial first probability.
[0157] Step b: For pixels whose initial first probability is less than the third threshold, increase the initial first probability corresponding to the pixel to obtain the first probability corresponding to the pixel.
[0158] Where the third threshold is less than the first threshold, the first probability corresponding to the pixel is greater than the first threshold.
[0159] Specifically, in practical applications, some wrinkle regions have relatively shallow wrinkles. For pixels located in these wrinkle regions, the initial probability output by the probability detection model is low; that is, the initial probability of these pixels is less than the third threshold, which is also less than the first threshold. However, these pixels still need to undergo wrinkle weakening or removal processing. Therefore, for pixels with an initial probability less than the third threshold, a dilation operation can be performed. Specifically, the initial probability of these pixels can be increased, resulting in a final probability greater than the first threshold. This allows for subsequent image processing of these pixels.
[0160] As can be seen, the technical solution provided in this embodiment, for pixels with a low initial first probability, can increase the final first probability of the pixel by increasing the initial first probability of that pixel, making the final first probability of the pixel greater than the first threshold. Thus, in subsequent steps, wrinkle reduction or removal can be performed on that pixel, thereby better achieving the purpose of weakening or removing facial wrinkles.
[0161] S120b determines the target pixel in the target region based on the first probability and the second probability corresponding to each pixel.
[0162] Among them, the first probability of the target pixel is greater than the first threshold, and the second probability of the target pixel is greater than the second threshold.
[0163] Specifically, since the first probability corresponding to a pixel is the probability that the pixel belongs to a wrinkle, and the second probability corresponding to a pixel is the probability that the pixel belongs to skin, pixels with both the first probability and the second probability being greater than a first threshold are considered to be wrinkle-removing pixels in the target area. Therefore, pixels with both the first and second probabilities being greater than the first threshold are identified as target pixels so that wrinkle-removing processing can be applied to target pixels in the target area in subsequent steps.
[0164] Taking forehead wrinkles as an example, the location of the target pixel should belong to both the target area (forehead wrinkle area) and the skin area. Therefore, the first probability corresponding to the target pixel is greater than the first threshold t1, and the second probability corresponding to the target pixel is greater than the second threshold t2. In other words, in this embodiment, image processing is performed on pixels with a first probability greater than t1 and a second probability greater than t2, while other pixels may not be processed. The values of t1 and t2 can be determined according to actual conditions, and this embodiment does not impose specific limitations on them.
[0165] As can be seen, by obtaining the first probability and the second probability corresponding to each pixel in the target area, and determining the pixel with the first probability greater than the first threshold and the second probability greater than the second threshold as the target pixel, that is, the pixel belonging to wrinkles and skin is determined as the target pixel, the subsequent steps can accurately perform image processing on the target pixels belonging to wrinkles and skin, thereby achieving the purpose of weakening or removing wrinkles.
[0166] In one implementation, S130, based on the first low-frequency information and the second low-frequency information corresponding to the target pixel, the wrinkle intensity corresponding to the target pixel and the pixel value corresponding to the target pixel after smoothing the wrinkles are determined; for example... Figure 3 As shown, it may include the following steps:
[0167] S131, determine the wrinkle intensity corresponding to the target pixel based on the difference between the first low-frequency information and the second low-frequency information corresponding to the target pixel.
[0168] As described above, by using two different image blurring algorithms to blur the target pixels in the target region, the resulting first low-frequency information D... f1 Second low frequency information D f2 Essentially, these are fuzzy information of varying degrees of blurriness, reflecting image features at different frequency bands. Subtracting these frequency band features yields structural information. Specifically, forehead wrinkles are relatively dark areas in a face image. By calculating D... f1 and D f2 By observing the difference in depth, we can obtain the brightness and darkness of forehead wrinkles, and thus determine the wrinkle intensity corresponding to the target pixel. Furthermore, the wrinkle intensity corresponding to a target pixel is directly proportional to the depth of that target pixel.
[0169] In one implementation, determining the wrinkle intensity corresponding to a target pixel based on the difference between a first low-frequency information and a second low-frequency information corresponding to the target pixel may include the following steps:
[0170] The sub-wrinkle intensity corresponding to the target pixel in the target region is calculated using the following formula:
[0171] I diff =alpha*(D f2 -D f1 )+255
[0172] Normalize the sub-wrinkle intensity corresponding to the target pixel to (0,1) to obtain the wrinkle intensity corresponding to the target pixel.
[0173] Where alpha is a preset parameter; D f2 As the second lowest frequency information, D f1 This is the first low-frequency information.
[0174] It should be noted that alpha is an empirical value for adjustment, and I... diff First adjust to [0, 255], then normalize to [0, 1]. Furthermore, in areas with deeper wrinkles, i.e., the relatively strong dark areas in forehead wrinkles, the target pixel value corresponding to I... diff It can be 1, the area where the wrinkles are shallower, that is, the relatively bright part of the forehead wrinkles, I diff It can be 0.
[0175] S132, determine the high-frequency information corresponding to the target pixel based on the first low-frequency information corresponding to the target pixel, and determine the sum of the high-frequency information and the second low-frequency information corresponding to the target pixel as the pixel value after the first smoothing wrinkle of the target pixel.
[0176] Specifically, the high-frequency information of the target pixel can be obtained based on its first low-frequency information. For example, the high-frequency information is denoted as I. high The first low-frequency information is D. f1 So, I high It can be equal to ID f1 .
[0177] Then, the sum of the high-frequency information and the second low-frequency information can be determined as the pixel value of the target pixel after the first smoothing of wrinkles. By adding high-frequency information to the face image after smoothing forehead wrinkles, the pixel value of the target pixel after the first smoothing of wrinkles can retain texture details and appear more realistic and natural. For example, the pixel value of the target pixel after the first smoothing of wrinkles is denoted as I. tmp So, I tmp =D f2 +I high .
[0178] To ensure clarity of the solution, the specific implementation of S132 will be described in detail in the following embodiments.
[0179] As can be seen, the technical solution provided in this embodiment uses two different image blurring algorithms to blur the target pixels in the target region. The resulting first and second low-frequency information are essentially blurry information of different degrees, reflecting image features of different frequency bands. By subtracting the image features of different frequency bands, some structural information can be obtained, thus accurately obtaining the wrinkle intensity corresponding to each target pixel in the target region. This wrinkle intensity can then be used to weaken or remove wrinkles in subsequent steps. Furthermore, by determining the sum of the high-frequency information and the second low-frequency information as the pixel value of the target pixel after the first smoothing of wrinkles, the obtained pixel value of the target pixel after the first smoothing of wrinkles can retain texture details, resulting in a more realistic and natural appearance.
[0180] To ensure clarity of the solution, the specific implementation of S132 will be described in detail in the following embodiments.
[0181] exist Figure 3 Based on the illustrated embodiments, in one embodiment, based on the above embodiments, in another embodiment, such as Figure 4 As shown, S132, determining the high-frequency information corresponding to the target pixel based on the first low-frequency information corresponding to the target pixel may include the following steps:
[0182] S1321, calculate the first high-frequency information corresponding to the target pixel using the first low-frequency information corresponding to the target pixel.
[0183] Specifically, the first high-frequency information can be denoted as I. high1 The first low-frequency information can be denoted as D. f1 So, I high1 =ID f1 , where I is the original pixel value of the target pixel in the target region.
[0184] S1322, Select skin pixels belonging to the skin in the face image, and determine the second high-frequency information corresponding to the skin pixels based on the first low-frequency information corresponding to the skin pixels.
[0185] Specifically, a skin pixel R can be randomly selected from the set of pixels belonging to the skin region in a face image, and the second high-frequency information of this skin pixel can be calculated. This second high-frequency information is I. highR =ID fR ,
[0186] S1323, calculate the first information intensity corresponding to the first high-frequency information corresponding to the target pixel, and calculate the second information intensity corresponding to the second high-frequency information corresponding to the skin pixel.
[0187] Specifically, since the first high-frequency information and the second high-frequency information usually represent the high-frequency information of multiple color channels, such as the R channel, G channel and B channel, the first high-frequency information and the second high-frequency information can be regarded as a three-dimensional vector to calculate the magnitude of the first high-frequency information, which is the first information intensity; and the magnitude of the second high-frequency information, which is the second information intensity.
[0188] S1324, if the first information intensity is less than the second information intensity, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel; if the first information intensity is greater than the second information intensity, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel.
[0189] Specifically, after calculating the first information intensity and the second information intensity, the magnitudes of the first information intensity and the second information intensity are compared. If the first information intensity is less than the second information intensity, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel. If the first information intensity is greater than the second information intensity, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel.
[0190] As can be seen, by using the technical solution provided in this embodiment, when determining the high-frequency information corresponding to the target pixel, the first high-frequency information is first calculated using the first low-frequency information corresponding to the target pixel, and the second high-frequency information corresponding to any skin pixel in the skin region is calculated. The information intensity of the first high-frequency information and the second high-frequency information are compared, and the high-frequency information with the relatively lower information intensity is determined as the high-frequency information of the target pixel. In this way, the pixel value of the target pixel after the first smoothing of wrinkles is more accurate, and the processed target pixel is more realistic and natural.
[0191] In the above Figure 1 Based on the aforementioned embodiments, in one implementation, such as Figure 5 As shown, S120, blurring the target pixel using an image blurring algorithm to obtain the first low-frequency information of the target pixel, may include the following steps:
[0192] S510, determine the first target window.
[0193] Specifically, in practical applications, the target window can be determined based on the actual situation. For clarity, this target window will be referred to as the first target window. For example, the first target window can be a square window of size r1*r1, where r1 can be 3.
[0194] S520, for the first center pixel of the first target window, if the first center pixel is the target pixel, determine the pixel values corresponding to the multiple first neighborhood pixels respectively.
[0195] Among them, multiple first neighboring pixels are pixels within the first target window other than the first center pixel.
[0196] It should be noted that, for clarity, the pixel located at the center of the first target window is called the first center pixel, and the pixels within the first target window other than the first center pixel are called the first neighboring pixels. For example, if the first target window is a 3x3 square, then the first target window includes 9 pixels, the pixel at the very center is the first center pixel, and the other 8 pixels are called the first neighboring pixels.
[0197] When the first target window is located in the target area, it can first be determined whether the first probability corresponding to the first center pixel is greater than the first threshold t1, and whether the second probability corresponding to the first center pixel is greater than the second threshold t2. If the first probability corresponding to the first center pixel is greater than t1 and the second probability corresponding to the first center pixel is greater than t2, it means that the first center pixel is located in the wrinkle area and in the skin area, and wrinkle removal processing needs to be performed on the first center pixel. That is, the first center pixel is the target pixel. At this time, for each of the multiple neighboring pixels, the pixel value corresponding to the multiple first neighboring pixels can be determined based on the original pixel value of the neighboring pixel and the pixel value of the first center pixel.
[0198] In one implementation, S520, the pixel values corresponding to the plurality of first neighborhood pixels are determined, such as... Figure 6 As shown, it may include the following steps:
[0199] S521, for each first neighboring pixel, determine whether the first neighboring pixel is a target pixel based on the first probability and the second probability corresponding to the first neighboring pixel.
[0200] Specifically, by obtaining the first probability and the second probability corresponding to multiple first neighboring pixels, it can be determined whether multiple first neighboring pixels are all located in the wrinkle area and in the skin area.
[0201] For each first neighboring pixel, determine whether the first probability corresponding to the first neighboring pixel is greater than the first threshold t1, and whether the second probability corresponding to the first neighboring pixel is greater than the second threshold t2. If the first probability corresponding to the first neighboring pixel is greater than the first threshold t1, and the second probability corresponding to the first neighboring pixel is greater than the second threshold t2, it means that the first neighboring pixel is located in the wrinkle area and in the skin area, and wrinkle removal processing needs to be performed on the first neighboring pixel, that is, the first neighboring pixel is the target pixel. Otherwise, the first neighboring pixel is not the target pixel.
[0202] S522, when the first neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target region is determined as the pixel value of the first neighboring pixel.
[0203] S523, if the first neighboring pixel is not the target pixel, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel.
[0204] Specifically, if the first neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target area is directly determined as the pixel value of the first neighboring pixel; if the first neighboring pixel is not the target pixel, it means that the first neighboring pixel is not located in the wrinkle area but in the skin area. In order to prevent the first neighboring pixel from affecting the subsequent blurring process, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel.
[0205] As can be seen, by using the technical solution provided in this embodiment, when determining the pixel value of each first neighboring pixel, it is first possible to determine whether the first neighboring pixel is a target pixel, that is, whether the first neighboring pixel is located in the wrinkle area and in the skin area; if the first neighboring pixel is not a target pixel, in order to prevent the pixel value of the first neighboring pixel from affecting the subsequent image blurring processing, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel, thereby improving the accuracy of image blurring processing, that is, the accuracy of the obtained first low-frequency information is relatively high.
[0206] S530, based on the pixel value of the first center pixel and the pixel values corresponding to multiple first neighboring pixels, performs Gaussian blur processing on the first center pixel to obtain the first low-frequency information of the first center pixel.
[0207] Specifically, after determining the pixel value of the first center pixel and the pixel values corresponding to the multiple first neighboring pixels, Gaussian blurring can be applied to the first center pixel based on the pixel values of the first center pixel and the pixel values of the multiple first neighboring pixels to obtain the first low-frequency information of the first center pixel. Those skilled in the art should understand the specific process of Gaussian blurring, which will not be elaborated here.
[0208] S540, move the first target window. If the first center pixel of the moved first target window is the target pixel, return to the step of determining the pixel values corresponding to the multiple first neighborhood pixels respectively, until the first low-frequency information of each target pixel in the target area is obtained.
[0209] Specifically, by moving the first target window, when the first center pixel of the moved first target window is located in the wrinkle area and the skin area, Gaussian blur processing is applied to the first center pixel until the first low-frequency information of each target pixel in the target area is obtained.
[0210] As can be seen, in this embodiment, when the first center pixel of the first target window is located in the wrinkle area and the skin area, the first center pixel is Gaussian blurred using the pixel value of the first center pixel and the pixel value of the first neighboring pixels. Furthermore, by moving the first target window, when the first center pixel of the moved first target window is the target pixel, the first center pixel is Gaussian blurred using the pixel value of the first center pixel and the pixel value of the first neighboring pixels until the first low-frequency information of each target pixel in the target area is obtained, thereby accurately obtaining the first low-frequency information of each target pixel in the target area.
[0211] exist Figure 1 In the illustrated embodiment, to determine the step size of the image blurring algorithm when blurring the target pixels to obtain the second low-frequency information based on the proportion of the face region to the face image in subsequent steps, in one implementation, such as... Figure 7 As shown, it may also include the following steps:
[0212] S710, obtain the coordinates of facial key points in a face image.
[0213] Among them, facial key points include the center point of the face, eyebrow key points, and cheek key points.
[0214] Specifically, a face image can be input into a pre-trained facial landmark extraction model, which then outputs the facial landmarks of the face image. It's important to note that facial landmarks include: the face center point, eyebrow landmarks, and cheek landmarks. The face center point typically refers to the coordinates of the center of the nose. However, forehead landmarks are usually not included because the forehead may be obscured by bangs or a hat in some face images; therefore, facial landmark extraction models typically do not extract the coordinates of the forehead landmarks.
[0215] S720 calculates the coordinates of the forehead key point in the target region based on the coordinates of the face center point and the eyebrow key point, and calculates the coordinates of the pixel points located on the outer border of the face in the face image based on the coordinates of the face center point and the cheek key point.
[0216] Specifically, assuming the center point of the face is Xo and the key point of the eyebrow is Xm, then the extension point Xe is defined as a point on the extension line of Xo and Xm, and the extension factor is set to n, which can be determined according to the actual situation. This is based on the following formula:
[0217] (Xe-Xo) / (Xm-Xo)=n
[0218] The coordinates of the key point Xe on the forehead can then be calculated.
[0219] Similarly, based on the above formula, the coordinates of the pixels of the outer border of the face can be calculated using the coordinates of the facial key points and cheek key points. Specifically, assuming the center point of the face is Xo and the cheek key point is Xm, then the extension point Xe is defined as a point on the extension line of Xo and Xm, and the extension factor is set to n. Thus, the coordinates of the pixels of the outer border of the face can be calculated using the above formula. For example, if there are 10 cheek key points, then the coordinates of the pixels of the outer border of the face for 10 people can be calculated.
[0220] S730, determine the target bounding rectangle of the face region in the face image.
[0221] The target bounding rectangle is the smallest bounding rectangle used to enclose the face outline pixels and the forehead key points.
[0222] Specifically, after obtaining the coordinates of the forehead key points and the outer frame pixels of the face, the location of the forehead key points and the outer frame pixels of the face can be determined. Then, the forehead key points and the outer frame pixels of the face can be enclosed by a minimum bounding rectangle, thus obtaining the target bounding rectangle.
[0223] S740 calculates the proportion coefficient of the face region to the width of the face image based on the width of the target bounding rectangle and the width of the face image, and calculates the proportion coefficient of the face region to the height of the face image based on the height of the target bounding rectangle and the height of the face image.
[0224] Specifically, since the coordinates of the key points on the forehead and the coordinates of the pixels of the face outline are both fixed, the vertex coordinates of the target's bounding rectangle can be determined. After determining the vertex coordinates of the target's bounding rectangle, the width and height of the target's bounding rectangle can be calculated using these vertex coordinates. The height of the target's bounding rectangle can then be expressed as H. f The width of the bounding rectangle of the target is W. f .
[0225] Assume the width of the face image is W. I The height is H I So, the width ratio factor R fW It can be W f / W IHeight ratio coefficient R fH It can be H f / H I .
[0226] As can be seen, the technical solution provided by this embodiment can estimate the coordinates of the forehead key points and the coordinates of the face outline pixels by using the coordinates of the face key points in the face image. Based on the coordinates of the forehead key points and the coordinates of the face outline pixels, the width ratio coefficient and height ratio coefficient of the target bounding rectangle can be accurately calculated. In subsequent steps, the step size when performing blurring processing by the second image blurring processing algorithm can be determined based on the ratio coefficient of the face region to the face image.
[0227] exist Figure 7 Based on the illustrated embodiments, in one implementation, such as Figure 8 As shown, in step S120, the target pixels in the target region are blurred using a second image blurring algorithm to obtain the second low-frequency information of the target region. This step may include the following steps:
[0228] S810, determine the second target window.
[0229] Specifically, in practical applications, the target window can be determined based on the actual situation. For clarity, this target window will be referred to as the second target window. For example, the second target window can be a square window of r2*r2, where r2 can be 3.
[0230] S820: For the second center pixel of the second target window, if the second center pixel is the target pixel, the mean-weighted blur processing step size is determined based on the width ratio coefficient and the height ratio coefficient.
[0231] Among them, the width ratio coefficient is the ratio of the width of the face region to the width of the face image, and the height ratio coefficient is the ratio of the height of the face region to the height of the face image. The step size of the mean-weighted blur processing is proportional to both the width ratio coefficient and the height ratio coefficient.
[0232] It should be noted that, for clarity of description, the pixel located at the center of the second target window is referred to as the second center pixel. For example, if the first target window is a 3x3 square, then the first target window contains 9 pixels, and the pixel at the very center is the second center pixel.
[0233] After determining the second center pixel, the second neighboring pixels can be determined based on the mean-weighted blur step size, where the mean-weighted blur step size can be (a*R) fw ,a*R _fHAs can be seen, the step size of the mean-weighted blur is directly proportional to the degree scaling factor and the height scaling factor. 'a' can be determined based on the actual situation. It is understood that, generally, the step size between two adjacent neighboring pixels is 1. If the width scaling factor R... fW and height ratio factor R fH A larger value indicates that the face region occupies a large proportion of the face image. In this case, the step size of two adjacent neighboring pixels can be adjusted, for example, to 2. This helps improve the efficiency of mean-weighted blur processing. At the same time, normalizing the calculation of the face blur map makes the subsequent wrinkle removal effect more consistent for faces of different sizes.
[0234] S830 determines multiple second neighboring pixels of the second center pixel based on the mean-weighted fuzzing step size.
[0235] S840, determine the pixel values corresponding to the multiple second-neighborhood pixels respectively.
[0236] After determining the second center pixel and the mean-weighted blurring step size, multiple second neighboring pixels of the second center pixel can be determined. For each second neighboring pixel, the corresponding pixel value can be determined based on the pixel value of the second center pixel and the pixel value of the corresponding second neighboring pixel.
[0237] In one implementation, S840, the pixel values corresponding to the plurality of second-domain pixels are determined, such as... Figure 9 As shown, it may include the following steps:
[0238] S841, for each second neighboring pixel, determine whether the second neighboring pixel is a target pixel based on the first probability and the second probability corresponding to the second neighboring pixel.
[0239] Specifically, by obtaining the first probability and the second probability corresponding to multiple second neighboring pixels, it can be determined whether multiple second neighboring pixels are all located in the wrinkle area and in the skin area.
[0240] For each second neighboring pixel, determine whether the first probability corresponding to the second neighboring pixel is greater than the first threshold t1, and whether the second probability corresponding to the second neighboring pixel is greater than the second threshold t2. If the first probability corresponding to the second neighboring pixel is greater than the first threshold t1, and the second probability corresponding to the second neighboring pixel is greater than the second threshold t2, it means that the second neighboring pixel is located in the wrinkle area and in the skin area, and wrinkle removal processing needs to be performed on the second neighboring pixel, that is, the second neighboring pixel is the target pixel. Otherwise, the second neighboring pixel is not the target pixel.
[0241] S842, when the second neighboring pixel is the target pixel, the original pixel value of the first neighborhood pixel in the target region is determined as the pixel value of the second neighboring pixel.
[0242] S843, if the second neighboring pixel is not the target pixel, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel.
[0243] Specifically, if the second neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target area is directly determined as the pixel value of the second neighboring pixel; if the second neighboring pixel is not the target pixel, it means that the second neighboring pixel is not located in the wrinkle area but in the skin area. In order to prevent the second neighboring pixel from affecting the subsequent blurring process, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel.
[0244] As can be seen, by using the technical solution provided in this embodiment, when determining the pixel value of each second neighboring pixel, it is first possible to determine whether the second neighboring pixel is a target pixel, that is, whether the second neighboring pixel is located in the wrinkle area and in the skin area; if the second neighboring pixel is not a target pixel, in order to prevent the pixel value of the second neighboring pixel from affecting the subsequent image blurring processing, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel, thereby improving the accuracy of image blurring processing, that is, the accuracy of the obtained first low-frequency information is relatively high.
[0245] S850 performs mean-weighted blurring processing on the second center pixel based on the pixel value of the second center pixel and the pixel values of multiple second neighboring pixels to obtain the second low-frequency information of the second center pixel.
[0246] Specifically, after determining the pixel value of the second center pixel as the pixel value of the second target neighboring pixels, a mean-weighted blurring process can be performed on the second center pixel based on its pixel value and the pixel values of multiple second neighboring pixels to obtain the second low-frequency information of the second center pixel. Those skilled in the art should understand the specific process of the mean-weighted blurring process, which will not be elaborated here. Assuming the coordinates of the second center pixel are (x, y), the calculation result of the second low-frequency information of the second center pixel is as follows:
[0247]
[0248] Where I(i,j) represents the pixel values of the first center pixel and multiple second neighboring pixels. Assuming r2 is 3, then the mean-weighted blurring step size (a*R) is used. fw ,a*R _fHEight second neighboring pixels can be identified, and the pixel value of the second center pixel and the average weighted value of the pixel values of these eight second neighboring pixels can be calculated to obtain the second low-frequency information of the second center pixel.
[0249] S860, move the second target window. If the second center pixel of the moved second target window is the target pixel, return to perform multiple second neighboring pixels of the second center pixel based on the mean weighted fuzzing step size, until the second low frequency information of each target pixel in the target area is obtained.
[0250] Specifically, by moving the second target window, when the second center pixel of the moved second target window is located in the wrinkle area and the skin area, the second center pixel is subjected to mean-weighted blurring until the second low-frequency information of each target pixel in the target area is obtained.
[0251] As can be seen, in this embodiment, when the second center pixel of the second target window is located in the wrinkle area and the skin area, the step size of the mean-weighted blurring process is determined by the width ratio coefficient and height ratio coefficient of the face area to the face image, thereby determining the second neighboring pixels of the second center pixel. The second center pixel is then subjected to mean-weighted blurring process using the pixel values of the second center pixel and the second neighboring pixels. Furthermore, by moving the second target window, if the second center pixel of the moved second target window is the target pixel, the second center pixel is further subjected to Gaussian blurring process using the pixel values of the second center pixel and the second neighboring pixels until the second low-frequency information of each target pixel in the target area is obtained. Thus, the second low-frequency information of each target pixel in the target area can be accurately obtained.
[0252] To ensure clarity, the complete technical solution of this disclosure will be described in detail below, taking the reduction or removal of forehead wrinkles as an example. The complete technical solution of this disclosure may include the following steps:
[0253] 1. Obtain a face image I, with a width of W. I The height is H I .
[0254] 2. Calculate the facial landmarks K using a pre-trained facial landmark extraction model. f The coordinates of the forehead wrinkle region, probability map P w , and the probability map P of the skin skin .
[0255] 3. For the probability graph P w Perform an expansion operation to obtain P. wd , that is, for P wFor smaller pixels, increase the first sub-probability corresponding to these pixels to obtain the final first probability P corresponding to these pixels. wd .
[0256] 4. Obtain information related to facial proportions.
[0257] Specifically, the coordinates of facial key points in the face image are obtained. Based on the coordinates of the face center point and eyebrow key points, the coordinates of the forehead key points in the target region are calculated. Furthermore, based on the coordinates of the face center point and cheek key points, the coordinates of the pixels located on the outer border of the face in the face image are calculated. The target bounding rectangle of the face region in the face image is determined, along with its width and height. Based on the width of the target bounding rectangle and the width of the face image, the proportion coefficient R of the face region to the width of the face image is calculated. fW Based on the height of the target's bounding rectangle and the height of the face image, the ratio R of the face region to the height of the face image is calculated. fH。
[0258] Since this step has been described in detail in the above embodiments, it will not be repeated here.
[0259] 5. Based on the target bounding rectangle in step 4, crop the face data and resize it into a square image with side length k, denoted as I. fp .
[0260] 6. Obtain I fp Low-frequency blur map. Specifically, for I... fp Perform a weighted Gaussian blur with a window size of r1*r1 to obtain the low-frequency image D. f1 ; and for I fp Perform weighted mean blurring with a window size of r2*r2 to obtain the low-frequency map D. f2 Among them, D f1 and D f2 The specific implementation methods have been described in detail in the above embodiments and will not be repeated here.
[0261] 7. For each target pixel undergoing image processing, determine the target high-frequency information of the target pixel based on the first low-frequency information, and determine the first pixel value I of the target pixel based on the target high-frequency information and the second low-frequency information. tmp ;
[0262] 8. Calculate the difference in brightness between the forehead wrinkle area and the surrounding area. Based on the first low-frequency information D of the forehead wrinkle area. f1 The second low-frequency information D in the forehead wrinkle area f2 The difference between them determines the wrinkle intensity I corresponding to each target pixel in the forehead wrinkle region. diff Among them, calculating I diffThe specific process has been described in the above embodiments and will not be repeated here.
[0263] 9. For those satisfying P wd >t1, and P skin The target pixel at >t2 has a pixel value of I in the processed face image. out .
[0264] I out =(1-I diff )*I+I diff *I tmp
[0265] The target pixel value calculated using this formula achieves the pixel value I obtained after smoothing forehead wrinkles. tmp This is combined with the pixel value I from the original face image. For areas with relatively strong dark edges in forehead wrinkles, i.e., areas with deeper forehead wrinkles, I is then... diff =1,I out =I tmp Evenly brightening while preserving texture details, using I tmp To replace the pixel values of the original face image; for target pixels in relatively bright areas, i.e., areas with shallower forehead wrinkles, I out =(1-I diff )*I+I diff* I tmp That is, using a certain proportion of I diff I after uniform darkening tmp The pixel values are mixed with those in the original face image to darken relatively bright areas, resulting in a smoother, more natural-looking forehead wrinkle area after processing.
[0266] 10. Output I out This yields a facial image with forehead wrinkles removed.
[0267] Secondly, embodiments of this disclosure provide an image processing apparatus, such as... Figure 10 As shown, it includes:
[0268] The face image acquisition module 1010 is configured to acquire a face image; the face image includes a target area for smoothing wrinkles;
[0269] The image blurring module 1020 is configured to perform different degrees of blurring on the target pixel using different image blurring algorithms to obtain first low-frequency information and second low-frequency information corresponding to the target pixel; the target pixel is a pixel in the target region that belongs to the skin and wrinkles.
[0270] The information determination module 1030 is configured to perform an operation based on the first low-frequency information and the second low-frequency information corresponding to the target pixel to determine the wrinkle intensity corresponding to the target pixel and the pixel value of the target pixel after the first smoothing of the wrinkles.
[0271] The target pixel value determination module 1040 is configured to perform a weighted result based on the original pixel value of the target pixel in the target region and the pixel value of the target pixel after the first smoothing wrinkle, to obtain the target pixel value after the second smoothing wrinkle; the weighting coefficient of the pixel value of the target pixel after the first smoothing wrinkle is positively correlated with the wrinkle intensity, and the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity.
[0272] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0273] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural.
[0274] Optional, also includes:
[0275] The probability acquisition module is configured to, after the face image acquisition module acquires the face image, acquire the first probability and the second probability corresponding to each pixel in the target region; the first probability corresponding to a pixel is the probability that the pixel belongs to a wrinkle, and the second probability corresponding to a pixel is the probability that the pixel belongs to skin;
[0276] The target pixel determination module is configured to determine the target pixel in the target region based on the first probability and the second probability corresponding to each pixel; wherein the first probability corresponding to the target pixel is greater than a first threshold, and the second probability corresponding to the target pixel is greater than a second threshold.
[0277] Optionally, the information determination module is specifically configured to execute:
[0278] The wrinkle intensity corresponding to the target pixel is determined based on the difference between the first low-frequency information and the second low-frequency information corresponding to the target pixel.
[0279] Based on the first low-frequency information corresponding to the target pixel, the high-frequency information corresponding to the target pixel is determined, and the sum of the high-frequency information and the second low-frequency information corresponding to the target pixel is determined as the pixel value of the target pixel after the first smoothing wrinkle.
[0280] Optionally, the image blurring module shown is configured to perform:
[0281] Determine the first target window;
[0282] For the first center pixel of the first target window, when the first center pixel is the target pixel, the pixel values corresponding to multiple first neighborhood pixels are determined respectively; the multiple first neighborhood pixels are the pixels in the first target window other than the first center pixel.
[0283] Based on the pixel value of the first center pixel and the pixel values corresponding to the plurality of first neighboring pixels, Gaussian blurring is performed on the first center pixel to obtain the first low-frequency information of the first center pixel.
[0284] Move the first target window. If the first center pixel of the moved first target window is the target pixel, return to the step of determining the pixel values corresponding to the multiple first neighborhood pixels, until the first low-frequency information of each target pixel in the target area is obtained.
[0285] Optionally, the image blurring module shown is configured to perform:
[0286] For each first neighboring pixel, based on the first probability and the second probability corresponding to the first neighboring pixel, determine whether the first neighboring pixel is the target pixel;
[0287] When the first neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target region is determined as the pixel value of the first neighboring pixel.
[0288] If the first neighboring pixel is not the target pixel, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel.
[0289] Optionally, the image blurring module shown is configured to perform:
[0290] Determine the second target window;
[0291] For the second center pixel of the second target window, when the second center pixel is the target pixel, the mean-weighted blur processing step size is determined based on the width ratio coefficient and the height ratio coefficient; wherein, the width ratio coefficient is the ratio of the width of the face region to the width of the face image, the height ratio coefficient is the ratio of the height of the face region to the height of the face image, and the mean-weighted blur processing step size is proportional to both the width ratio coefficient and the height ratio coefficient;
[0292] Based on the mean-weighted fuzzing step size, a plurality of second neighboring pixels of the second center pixel are determined;
[0293] Determine the pixel values corresponding to the plurality of second-domain pixels respectively;
[0294] Based on the pixel value of the second center pixel and the pixel values of the plurality of second neighboring pixels, the second center pixel is subjected to mean-weighted blurring processing to obtain the second low-frequency information of the second center pixel;
[0295] Move the second target window. If the second center pixel of the moved second target window is the target pixel, return to perform the determination of multiple second neighboring pixels of the second center pixel based on the mean-weighted fuzzing step size, until the second low-frequency information of each target pixel in the target area is obtained.
[0296] Optional, also includes:
[0297] The coordinate determination module is configured to obtain the coordinates of facial key points in the face image, including the face center point, eyebrow key points, and cheek key points.
[0298] The coordinate calculation module is configured to calculate the coordinates of the forehead key point in the target area based on the coordinates of the face center point and the eyebrow key point, and to calculate the coordinates of the pixel points located on the outer border of the face in the face image based on the coordinates of the face center point and the cheek key point.
[0299] The bounding rectangle determination module is configured to determine the target bounding rectangle of the face region in the face image, wherein the target bounding rectangle is the smallest bounding rectangle used to enclose the face outline pixels and the forehead key points;
[0300] A width and height determination module is configured to determine the width and height of the target bounding rectangle;
[0301] The scaling factor determination module is configured to calculate the width scaling factor of the face region to the face image based on the width of the target bounding rectangle and the width of the face image, and to calculate the height scaling factor of the face region to the face image based on the height of the target bounding rectangle and the height of the face image.
[0302] Optionally, the image blurring module is configured to perform:
[0303] For each second neighboring pixel, based on the first probability and the second probability corresponding to the second neighboring pixel, determine whether the second neighboring pixel is the target pixel;
[0304] When the second neighboring pixel is the target pixel, the original pixel value of the second neighboring pixel in the target region is determined as the pixel value of the second neighboring pixel.
[0305] If the second neighboring pixel is not the target pixel, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel.
[0306] Optionally, the information determination module is specifically configured to execute:
[0307] The first high-frequency information corresponding to the target pixel is calculated using the first low-frequency information corresponding to the target pixel.
[0308] In the face image, skin pixels belonging to the skin are selected, and based on the first low-frequency information corresponding to the skin pixels, the second high-frequency information corresponding to the skin pixels is determined.
[0309] Calculate the first information intensity of the first high-frequency information corresponding to the target pixel, and calculate the second information intensity of the second high-frequency information corresponding to the skin pixel;
[0310] When the intensity of the first information is less than the intensity of the second information, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel; when the intensity of the first information is greater than the intensity of the second information, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel.
[0311] Optionally, the probability acquisition module is configured to execute:
[0312] The face image is input into a pre-trained probability detection model to obtain the initial first probability corresponding to each pixel in the target region;
[0313] For a pixel whose initial first probability is less than the third threshold, the initial first probability corresponding to the pixel is increased to obtain the first probability corresponding to the pixel; the third threshold is less than the first threshold, and the first probability corresponding to the pixel is greater than the first threshold.
[0314] Thirdly, embodiments of this disclosure provide an electronic device, including:
[0315] processor;
[0316] Memory used to store the processor's executable instructions;
[0317] The processor is configured to execute the instructions to implement the method as described in the first aspect.
[0318] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0319] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural.
[0320] Fourthly, embodiments of this disclosure provide a computer-readable storage medium that, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method described in the first aspect.
[0321] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0322] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural.
[0323] Fifthly, embodiments of this disclosure provide a computer program product that, when run on a computer, causes the computer to perform the method described in the first aspect.
[0324] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0325] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural.
[0326] Figure 11 This is a block diagram illustrating an apparatus 1100 according to an exemplary embodiment. For example, apparatus 1100 may be provided as a server. (Refer to...) Figure 11 The apparatus 1100 includes a processing component 1122, which further includes one or more processors, and memory resources represented by memory 1132 for storing instructions, such as application programs, that can be executed by the processing component 1122. The application programs stored in memory 1132 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1122 is configured to execute instructions to perform the image processing method described in the first aspect.
[0327] Device 1100 may also include a power supply component 1126 configured to perform power management of device 1100, a wired or wireless network interface 1150 configured to connect device 1100 to a network, and an input / output (I / O) interface 1158. Device 1100 may operate on an operating system stored in memory 1132, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or similar.
[0328] The technical solution provided in this disclosure involves acquiring a face image, which includes a target region for smoothing wrinkles. Different image blurring algorithms are used to blur target pixels belonging to both skin and wrinkles within the target region to varying degrees, obtaining first and second low-frequency information corresponding to each target pixel. Based on this first and second low-frequency information, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Finally, based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value after the first smoothing of the wrinkles, the target pixel value after the second smoothing of the wrinkles is obtained. The calculated target pixel value combines the pixel value after smoothing the wrinkles with the original pixel value.
[0329] Since the weighting coefficient of the pixel value after the first smoothing of wrinkles is positively correlated with the wrinkle intensity, while the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity, for areas with higher wrinkle intensity (i.e., darker areas with deeper wrinkles), the target pixel value of each target pixel in these darker areas is closer to the pixel value after the first smoothing of wrinkles. This allows for a moderate brightening of these darker areas while preserving texture details. Conversely, for areas with lower wrinkle intensity (i.e., lighter areas with lighter wrinkles), the target pixel value of each target pixel in these brighter areas is closer to the original pixel value. This allows for a moderate darkening of the brighter areas in the forehead wrinkle region. Therefore, by moderately brightening the darker areas of the wrinkle region while preserving texture details, and moderately darkening the brighter areas, the processed wrinkle region becomes uniformly smooth and natural.
[0330] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0331] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that, include: Acquire a face image; the face image includes the target area for smoothing wrinkles; Different image blurring algorithms are used to blur the target pixels to different degrees to obtain the first low-frequency information and the second low-frequency information corresponding to the target pixels. The target pixel is a pixel in the target region that belongs to the skin and is a wrinkle; Based on the first low-frequency information and the second low-frequency information corresponding to the target pixel, the wrinkle intensity corresponding to the target pixel and the pixel value after the first smoothing of the wrinkles are determined. Based on the original pixel value of the target pixel in the target region and the weighted result of the pixel value of the target pixel after the first smoothing wrinkle, the target pixel value after the second smoothing wrinkle is obtained. The weighting coefficient of the pixel value after the first smoothing of the target pixel is positively correlated with the wrinkle intensity, and the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity. The step of determining the wrinkle intensity corresponding to the target pixel and the pixel value of the target pixel after smoothing the first wrinkle, based on the first low-frequency information and the second low-frequency information corresponding to the target pixel, includes: Based on the difference between the first low-frequency information and the second low-frequency information corresponding to the target pixel, the wrinkle intensity corresponding to the target pixel is determined; the first high-frequency information corresponding to the target pixel is calculated using the first low-frequency information; skin pixels belonging to the skin are selected in the face image, and the second high-frequency information corresponding to the skin pixels is determined based on the first low-frequency information; the first information intensity of the first high-frequency information corresponding to the target pixel is calculated, and the second information intensity of the second high-frequency information corresponding to the skin pixels is calculated; if the first information intensity is less than the second information intensity, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel; if the first information intensity is greater than the second information intensity, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel. The sum of the high-frequency information and the second low-frequency information corresponding to the target pixel is determined as the pixel value of the target pixel after the first smoothing wrinkle.
2. The method according to claim 1, characterized in that, After acquiring the face image, the process also includes: Obtain the first probability and the second probability corresponding to each pixel in the target area; the first probability corresponding to a pixel is the probability that the pixel belongs to a wrinkle, and the second probability corresponding to a pixel is the probability that the pixel belongs to skin; Based on the first probability and the second probability corresponding to each pixel, the target pixel in the target region is determined; the first probability corresponding to the target pixel is greater than a first threshold, and the second probability corresponding to the target pixel is greater than a second threshold.
3. The method according to claim 1, characterized in that, The target pixel is blurred using an image blurring algorithm to obtain the first low-frequency information corresponding to the target pixel, including: Determine the first target window; For the first center pixel of the first target window, if the first center pixel is the target pixel, the pixel values corresponding to a plurality of first neighboring pixels are determined respectively; the plurality of first neighboring pixels are the pixels in the first target window other than the first center pixel; Based on the pixel value of the first center pixel and the pixel values corresponding to the plurality of first neighboring pixels, Gaussian blurring is performed on the first center pixel to obtain the first low-frequency information of the first center pixel. Move the first target window. If the first center pixel of the moved first target window is the target pixel, return to the step of determining the pixel values corresponding to the multiple first neighborhood pixels, until the first low-frequency information of each target pixel in the target area is obtained.
4. The method according to claim 3, characterized in that, Determining the pixel values corresponding to the plurality of first neighborhood pixels includes: For each first neighboring pixel, based on the first probability and the second probability corresponding to the first neighboring pixel, determine whether the first neighboring pixel is the target pixel; When the first neighboring pixel is the target pixel, the original pixel value of the first neighboring pixel in the target region is determined as the pixel value of the first neighboring pixel. If the first neighboring pixel is not the target pixel, the pixel value of the first center pixel is determined as the pixel value of the first neighboring pixel.
5. The method according to claim 1, characterized in that, The target pixel is blurred using an image blurring algorithm to obtain the second low-frequency information corresponding to the target pixel, including: Determine the second target window; For the second center pixel of the second target window, when the second center pixel is the target pixel, the mean-weighted blur processing step size is determined based on the width ratio coefficient and the height ratio coefficient; wherein, the width ratio coefficient is the ratio of the width of the face region to the width of the face image, the height ratio coefficient is the ratio of the height of the face region to the height of the face image, and the mean-weighted blur processing step size is proportional to both the width ratio coefficient and the height ratio coefficient; Based on the mean-weighted fuzzing step size, a plurality of second neighboring pixels of the second center pixel are determined; Determine the pixel values corresponding to the plurality of second-domain pixels respectively; Based on the pixel value of the second center pixel and the pixel values of the plurality of second neighboring pixels, the second center pixel is subjected to mean-weighted blurring processing to obtain the second low-frequency information of the second center pixel; Move the second target window. If the second center pixel of the moved second target window is the target pixel, return to perform the determination of multiple second neighboring pixels of the second center pixel based on the mean-weighted fuzzing step size, until the second low-frequency information of each target pixel in the target area is obtained.
6. The method according to claim 5, characterized in that, Also includes: Obtain the coordinates of facial key points in the face image, including the face center point, eyebrow key points, and cheek key points; Based on the coordinates of the face center point and the eyebrow key point, the coordinates of the forehead key point in the target area are calculated, and based on the coordinates of the face center point and the cheek key point, the coordinates of the pixel points located on the outer border of the face in the face image are calculated. Determine the target bounding rectangle of the face region in the face image, wherein the target bounding rectangle is the smallest bounding rectangle used to enclose the outer border pixels of the face and the key points of the forehead; Based on the width of the target bounding rectangle and the width of the face image, calculate the proportion coefficient of the face region to the width of the face image, and based on the height of the target bounding rectangle and the height of the face image, calculate the proportion coefficient of the face region to the height of the face image.
7. The method according to claim 5, characterized in that, Determining the pixel values corresponding to the multiple second-neighborhood pixels includes: For each second neighboring pixel, based on the first probability and the second probability corresponding to the second neighboring pixel, determine whether the second neighboring pixel is the target pixel; When the second neighboring pixel is the target pixel, the original pixel value of the second neighboring pixel in the target region is determined as the pixel value of the second neighboring pixel. If the second neighboring pixel is not the target pixel, the pixel value of the second center pixel is determined as the pixel value of the second neighboring pixel.
8. The method according to claim 2, characterized in that, The step of obtaining the first probability corresponding to each pixel in the target region includes: The face image is input into a pre-trained probability detection model to obtain the initial first probability corresponding to each pixel in the target region; For a pixel whose initial first probability is less than the third threshold, the initial first probability corresponding to the pixel is increased to obtain the first probability corresponding to the pixel; the third threshold is less than the first threshold, and the first probability corresponding to the pixel is greater than the first threshold.
9. An image processing apparatus, characterized in that, include: A face image acquisition module is configured to acquire a face image; the face image includes a target area for smoothing wrinkles; The image blurring module is configured to perform different degrees of blurring on the target pixel using different image blurring algorithms to obtain the first low-frequency information and the second low-frequency information corresponding to the target pixel. The target pixel is a pixel in the target region that belongs to the skin and is a wrinkle; The information determination module is configured to perform an operation based on the first low-frequency information and the second low-frequency information corresponding to the target pixel to determine the wrinkle intensity corresponding to the target pixel and the pixel value of the target pixel after the first smoothing of the wrinkles. The target pixel value determination module is configured to perform a weighted result based on the original pixel value of the target pixel in the target region and the pixel value of the target pixel after the first smoothing wrinkle, to obtain the target pixel value after the second smoothing wrinkle; The weighting coefficient of the pixel value after the first smoothing of the target pixel is positively correlated with the wrinkle intensity, and the weighting coefficient of the original pixel value is negatively correlated with the wrinkle intensity. Specifically, the information determination module is configured to execute: Based on the difference between the first low-frequency information and the second low-frequency information corresponding to the target pixel, the wrinkle intensity corresponding to the target pixel is determined; the first high-frequency information corresponding to the target pixel is calculated using the first low-frequency information; skin pixels belonging to the skin are selected in the face image, and the second high-frequency information corresponding to the skin pixels is determined based on the first low-frequency information; the first information intensity of the first high-frequency information corresponding to the target pixel is calculated, and the second information intensity of the second high-frequency information corresponding to the skin pixels is calculated; if the first information intensity is less than the second information intensity, the first high-frequency information is determined as the high-frequency information corresponding to the target pixel; if the first information intensity is greater than the second information intensity, the second high-frequency information is determined as the high-frequency information corresponding to the target pixel; and the sum of the high-frequency information and the second low-frequency information corresponding to the target pixel is determined as the pixel value of the target pixel after the first smoothing of the wrinkle.
10. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method as claimed in any one of claims 1 to 8.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and storage medium
CN113379623A