Methods for adding skin texture to images, face image processing methods and devices
Patent Information
- Application Number
- CN202210894230.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-27
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2042-07-27
AI Technical Summary
其中,对人像进行美颜处理会有效平滑皮肤上的瑕疵,但同时会不可避免地平滑掉皮肤的纹理细节信息,导致皮肤纹理信息丢失
[0037]上述图像中添加皮肤纹理信息的方法、网络直播中人脸图像的处理方法、装置、设备和介质,获取待添加皮肤纹理的图像和皮肤纹理图像,基于预设的灰度值与混合强度的对应关系,根据目标区域中各像素点各自的原始灰度值确定各自的混合强度,以及根据目标区域中各像素点各自的原始灰度值及其各自在皮肤纹理图像中对应的皮肤纹理灰度值获取各自的原目标灰度值,然后针对目标区域中每一像素点,基于各自的混合强度,在各自的原始灰度值和原目标灰度值之间确定各自的目标灰度值,混合强度越大则目标灰度值越接近原目标灰度值,最后根据目标区域中各像素点各自的目标灰度值获得添加皮肤纹理的图像。该方案并非直接根据皮肤纹理图像决定最终添加皮肤纹理的图像中各像素点的目标灰度值,而是先根据待添加纹理图像上像素点的原始灰度值确定其混合强度,再根据其混合强度在原始灰度值和原目标灰度值之间取出最终的目标灰度值从而得到添加皮肤纹理的图像,也即最终添加皮肤纹理的图像中各像素点的目标灰度值是由各自的原始灰度值以及皮肤纹理图像中对应的皮肤纹理灰度值共同决定的,使之更好地贴合原图像,能够提高所添加的皮肤纹理信息与原图像的适配性,更好地弥补如过度美颜后丢失的皮肤纹理细节,使皮肤在图像中的表现更自然细腻。
Smart Images

Figure CN115205358B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of image processing and live streaming technology, and in particular to a method for adding skin texture information to an image, a method for processing facial images in live streaming, an apparatus, an electronic device, and a computer-readable storage medium. Background Technology
[0002] With the development of image processing technology, beautification and other portrait processing techniques have been applied to the presentation of online live streaming content. Among them, beautification processing of portraits can effectively smooth out skin imperfections, but it will inevitably smooth out the skin texture details at the same time, resulting in the loss of skin texture information.
[0003] Current methods for adding skin texture information to images typically involve directly adding skin texture to the original image. This means that the enhancement or fading of each pixel in the face area of the final original image is directly determined by the grayscale value of the skin texture material. In other words, as long as the skin texture material is given, the intensity of change of each pixel in the face area of the original image is fixed, resulting in a problem of low compatibility between the added skin texture and the original image. Summary of the Invention
[0004] Therefore, it is necessary to provide a method for adding skin texture information to an image, a method for processing facial images in live web broadcasts, an apparatus, an electronic device, and a computer-readable storage medium to address the aforementioned technical problems.
[0005] Firstly, this application provides a method for adding skin texture information to an image. The method includes:
[0006] Obtain an image to which skin texture is to be added, and obtain a skin texture image for adding skin texture to the target area in the image to which skin texture is to be added;
[0007] Based on the preset correspondence between grayscale values and mixing intensity, the mixing intensity of each pixel in the target area is determined according to the original grayscale value of each pixel in the target area.
[0008] Based on the original grayscale value of each pixel in the target region and the skin texture grayscale value of each pixel in the target region in the skin texture image, obtain the original target grayscale value of each pixel in the target region;
[0009] For each pixel in the target region, a target gray value is determined between its original gray value and its original target gray value based on its respective mixing intensity; wherein, the greater the mixing intensity, the closer the target gray value is to the original target gray value;
[0010] Based on the target grayscale value of each pixel in the target region, an image with added skin texture is obtained.
[0011] In one embodiment, the preset correspondence between grayscale values and mixing intensity includes: a first type of grayscale interval and a second type of grayscale interval and a mixing intensity; wherein, the first type of grayscale interval and mixing intensity correspondence is that when the grayscale value is in the first grayscale interval, the mixing intensity is set to the minimum value; the second type of grayscale interval and mixing intensity correspondence is that when the grayscale value is in the second grayscale interval, the mixing intensity takes the maximum value when the grayscale value is in the middle grayscale value of the second grayscale interval, and decreases to the minimum value when the grayscale value changes from the middle grayscale value to the grayscale values at both ends of the second grayscale interval.
[0012] In one embodiment, determining the mixing intensity of each pixel in the target region based on the original gray value of each pixel in the target region according to the preset correspondence between gray values and mixing intensity includes: if the original gray value of a pixel is less than or equal to the first gray value of the second gray range, or if the original gray value of a pixel is greater than or equal to the second gray value of the second gray range, then the original gray value of the pixel is determined to be in the first gray range, and the mixing intensity of the pixel is determined to be the minimum value; if the original gray value of a pixel is greater than the first gray value and less than the second gray value, then the original gray value of the pixel is determined to be in the second gray range, and the mixing intensity is determined within the range defined by the maximum and minimum values based on the proximity of the original gray value of the pixel to the intermediate gray value.
[0013] In one embodiment, obtaining an image with added skin texture based on the target grayscale value of each pixel in the target region includes: acquiring the original hue value and original saturation of each pixel in the target region; converting the target grayscale value, original hue value, and original saturation of each pixel in the target region into corresponding color information to obtain the target color information of each pixel in the target region; and obtaining an image with added skin texture based on the target color information of each pixel in the target region.
[0014] In one embodiment, determining the target gray value between the original gray value and the original target gray value based on the respective mixing intensity includes: obtaining a grayscale variation limit value based on the difference between the original gray value and the original target gray value; obtaining a grayscale variation value based on the product of the grayscale variation limit value and the mixing intensity; and obtaining the target gray value based on the sum of the original gray value and the grayscale variation value.
[0015] Secondly, this application provides a method for processing facial images during live web streaming. The method includes:
[0016] In response to the beautification instruction on the facial image provided by the anchor, the beautified facial image is obtained;
[0017] The beautified face image is used as the image to which skin texture is to be added, and the beautified face image with added skin texture is obtained according to the method described in any of the above embodiments;
[0018] The image shows a beautified face with added skin texture.
[0019] Thirdly, this application provides an apparatus for adding skin texture information to an image. The apparatus includes:
[0020] The image acquisition module is used to acquire an image to which skin texture is to be added, and to acquire a skin texture image for adding skin texture to a target area in the image to which skin texture is to be added;
[0021] The intensity determination module is used to determine the mixing intensity of each pixel in the target area based on a preset correspondence between grayscale values and mixing intensity, according to the original grayscale values of each pixel in the target area.
[0022] The original target value acquisition module is used to acquire the original target gray value of each pixel in the target area based on the original gray value of each pixel in the target area and the skin texture gray value corresponding to each pixel in the target area in the skin texture image.
[0023] The target value determination module is used to determine the target gray value of each pixel in the target region based on its own mixing intensity, between its original gray value and its original target gray value; wherein, the greater the mixing intensity, the closer the target gray value is to the original target gray value;
[0024] The image acquisition module is used to obtain an image with added skin texture based on the target grayscale value of each pixel in the target region.
[0025] Fourthly, this application provides a device for processing facial images during live web streaming. The device includes:
[0026] The beautification module is used to respond to beautification instructions on the facial image provided by the anchor and obtain the beautified facial image.
[0027] The texture adding module is used to take the beautified face image as the image to which skin texture is to be added, and to obtain the beautified face image with added skin texture according to the method described in any of the above embodiments;
[0028] The image display module is used to display the beautified facial image with added skin texture.
[0029] Fifthly, this application provides an electronic device. The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0030] A skin texture image is acquired to be added to the target region of the image to be added to the skin texture. Based on a preset correspondence between grayscale values and blending intensities, the blending intensity of each pixel in the target region is determined according to its original grayscale value. The original target grayscale value of each pixel in the target region is obtained based on its original grayscale value and the corresponding skin texture grayscale value in the skin texture image. For each pixel in the target region, a target grayscale value is determined between its original grayscale value and its original target grayscale value based on its blending intensity. The higher the blending intensity, the closer the target grayscale value is to the original target grayscale value. Based on the target grayscale values of each pixel in the target region, an image with added skin texture is obtained.
[0031] Sixthly, this application provides an electronic device. The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0032] In response to a beautification instruction on a facial image provided by a broadcaster, a beautified facial image is obtained; the beautified facial image is used as an image to which skin texture is to be added, and a beautified facial image with added skin texture is obtained according to the method described in any of the above embodiments; the beautified facial image with added skin texture is displayed.
[0033] Seventhly, this application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0034] A skin texture image is acquired to be added to the target region of the image to be added to the skin texture. Based on a preset correspondence between grayscale values and blending intensities, the blending intensity of each pixel in the target region is determined according to its original grayscale value. The original target grayscale value of each pixel in the target region is obtained based on its original grayscale value and the corresponding skin texture grayscale value in the skin texture image. For each pixel in the target region, a target grayscale value is determined between its original grayscale value and its original target grayscale value based on its blending intensity. The higher the blending intensity, the closer the target grayscale value is to the original target grayscale value. Based on the target grayscale values of each pixel in the target region, an image with added skin texture is obtained.
[0035] Eighthly, this application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0036] In response to a beautification instruction on a facial image provided by a broadcaster, a beautified facial image is obtained; the beautified facial image is used as an image to which skin texture is to be added, and a beautified facial image with added skin texture is obtained according to the method described in any of the above embodiments; the beautified facial image with added skin texture is displayed.
[0037] The above-mentioned method for adding skin texture information to images, the method for processing face images in live streaming, the apparatus, device, and medium acquire an image to be added with skin texture and a skin texture image. Based on a preset correspondence between grayscale values and mixing intensity, the mixing intensity of each pixel in the target area is determined according to its original grayscale value. The original target grayscale value of each pixel in the target area is obtained according to its original grayscale value and its corresponding skin texture grayscale value in the skin texture image. Then, for each pixel in the target area, based on its mixing intensity, its target grayscale value is determined between its original grayscale value and its original target grayscale value. The greater the mixing intensity, the closer the target grayscale value is to the original target grayscale value. Finally, the image with added skin texture is obtained according to the target grayscale value of each pixel in the target area. This scheme does not directly determine the target grayscale value of each pixel in the final image with added skin texture based on the skin texture image. Instead, it first determines the mixing intensity of the pixels based on the original grayscale value of the pixels in the image to be textured, and then extracts the final target grayscale value between the original grayscale value and the original target grayscale value based on the mixing intensity to obtain the image with added skin texture. In other words, the target grayscale value of each pixel in the final image with added skin texture is jointly determined by its original grayscale value and the corresponding skin texture grayscale value in the skin texture image, so that it fits the original image better. This improves the adaptability of the added skin texture information to the original image, better compensates for the skin texture details lost after excessive beautification, and makes the skin appear more natural and delicate in the image. Attached Figure Description
[0038] Figure 1 This is a diagram illustrating the application scenarios of the relevant methods in the embodiments of this application;
[0039] Figure 2 This is a flowchart illustrating the method for adding skin texture information to an image in an embodiment of this application.
[0040] Figure 3 This is a schematic diagram illustrating the correspondence between grayscale values and mixing intensity in the embodiments of this application;
[0041] Figure 4 This is a schematic diagram illustrating the skin texture addition effect in an embodiment of this application;
[0042] Figure 5 This is a flowchart illustrating the method for processing facial images in live streaming according to an embodiment of this application.
[0043] Figure 6 This is a schematic diagram of the face image processing interface in an embodiment of this application;
[0044] Figure 7 This is a structural block diagram of the device for adding skin texture information to an image in the embodiments of this application;
[0045] Figure 8 This is a structural block diagram of the apparatus for processing facial images in live streaming according to an embodiment of this application;
[0046] Figure 9 This is a diagram of the internal structure of the electronic device in an embodiment of this application. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0048] The method for adding skin texture information to images and the method for processing face images in live streaming provided in this application can be applied to, for example... Figure 1 In the application scenarios shown, the terminal can be, but is not limited to, various personal computers, laptops, smartphones, and tablets. The terminal can acquire an image provided by the user as the image to which skin texture is to be added. This image can be the user's face image; in a live streaming scenario, the user can be the broadcaster. After obtaining the image to which skin texture is to be added, the terminal can execute the method for adding skin texture information to an image provided in this application embodiment to obtain an image with added skin texture. It can also execute the method for processing face images in live streaming provided in this application embodiment to display the beautified face image with added skin texture to the broadcaster. The method for adding skin texture information to an image and the method for processing face images in live streaming provided in this application embodiment can improve the adaptability of the added skin texture information to the original image, better compensate for skin texture details lost due to excessive beautification, and make the skin appear more natural and delicate in the image. Furthermore, it can be executed using GPU hardware acceleration, achieving real-time processing performance on terminals such as personal computers, laptops, smartphones, and tablets.
[0049] The following sections will describe, in conjunction with various embodiments and corresponding figures, the method for adding skin texture information to images provided in this application and the method for processing face images in live streaming.
[0050] In one embodiment, such as Figure 2 As shown, a method for adding skin texture information to an image is provided. This method can be executed by a terminal and includes the following steps:
[0051] Step S201: Obtain the image to which the skin texture is to be added, and obtain the skin texture image used to add skin texture to the target area in the image to which the skin texture is to be added.
[0052] In this step, the beautified facial image can be used as the image to which skin texture is to be added. The terminal first obtains the facial image provided by the user, then performs beautification processing on the facial image under the user's instructions to obtain the beautified facial image. The terminal then uses this beautified facial image as the image to which skin texture is to be added. The image to which skin texture is to be added has a target region, which refers to the area in the image where skin texture needs to be added, such as the facial area in the facial image. The skin texture image may contain different texture intensities set for different areas. This step obtains the skin texture image used to add skin texture to the target area in the image to which skin texture is to be added. For example, if the facial area in the facial image is the target area, the terminal obtains the skin texture image used to add skin texture to that facial area.
[0053] As an example, taking a beautified face image as the image to which skin texture is to be added, the terminal can obtain a skin texture image that matches the face pose of the face image based on the location information of the key points of the face on the beautified face image and the skin texture material image pre-designed for the face area. This is the skin texture image used to add skin texture to the target area of the image to which skin texture is to be added.
[0054] Step S202: Based on the preset correspondence between grayscale values and blending intensities, determine the blending intensity of each pixel in the target area according to its original grayscale value.
[0055] After obtaining the image of the skin texture to be added in step S201, step S202 can be executed. In this step, the terminal obtains the grayscale value of each pixel in the target area of the skin texture to be added based on the image of the skin texture to be added, and records it as the original grayscale value, thereby obtaining the original grayscale value of each pixel in the target area. At the same time, the terminal can also obtain a preset correspondence between grayscale values and blending intensity. That is, the correspondence between grayscale values and blending intensity is preset. Based on this correspondence, a blending intensity can be determined after obtaining a grayscale value. This allows relevant users to design the correspondence between grayscale values and blending intensity, assigning different blending intensities to pixels with different grayscale values. The blending intensity is used in subsequent steps to jointly determine the target grayscale value of a pixel value with the skin texture grayscale value corresponding to that pixel value. This ensures that even if a pixel has different original grayscale values and corresponds to the same skin texture grayscale value, the final target grayscale value of that pixel can change due to its different blending intensities, and the change can adapt to its original grayscale value. Therefore, specifically, after the terminal obtains the grayscale value of each pixel in the target area where the skin texture is to be added, as well as the preset correspondence between grayscale values and blending intensity, it determines the blending intensity of each pixel based on the corresponding relationship and the grayscale value of each pixel in the target area.
[0056] Step S203: Based on the original grayscale value of each pixel in the target area and the corresponding skin texture grayscale value of each pixel in the target area in the skin texture image, obtain the original target grayscale value of each pixel in the target area.
[0057] After obtaining the image of the skin texture to be added and its skin texture image in step S201, step S203 can be executed. In this step, the terminal obtains the original grayscale value of each pixel in the target area where the skin texture is to be added, and obtains the corresponding skin texture grayscale value of each pixel in the target area in the skin texture image based on the skin texture image. Then, the terminal obtains the original target grayscale value of each pixel in the target area based on the original grayscale value of each pixel and its corresponding skin texture grayscale value. The original target grayscale value referred to here means the target grayscale value that the pixel should originally be set before the mixing based on the mixing intensity in the subsequent step S204. For the calculation of the original target grayscale value, the BlendSoftLight standard algorithm can be used in practical applications, which can be expressed by the following formula:
[0058] L′ p =BlendSoftLight(L p ,L material )
[0059] Among them, L′ p L represents the original target grayscale value.p L represents the original grayscale value. material This represents the grayscale value of skin texture.
[0060] Step S204: For each pixel in the target region, based on its own mixing intensity, determine its own target gray value between its own original gray value and its own original target gray value.
[0061] This step involves blending the skin texture image and the image to which the skin texture will be added. This is manifested in the final target grayscale value of each pixel in the target area of the image to which the skin texture will be added. This target grayscale value is obtained between its original grayscale value and its original target grayscale value, and is determined based on the blending intensity of each pixel. The greater the blending intensity, the closer the target grayscale value is to the original target grayscale value. The blending intensity can be limited to between 0 and 1. That is, for each pixel in the target area, the terminal determines its target grayscale value between its original grayscale value and its original target grayscale value based on its blending intensity determined in step S202. When the blending intensity of a pixel is the maximum value of 1, the terminal can determine its target grayscale value as its original target grayscale value. When the blending intensity of a pixel is the minimum value of 0, the terminal can determine its target grayscale value as its original grayscale value. When the blending intensity of a pixel is 0.5, the terminal can determine its target grayscale value as the midpoint between the original grayscale value and the original target grayscale value.
[0062] Specifically, in some embodiments, determining the respective target grayscale value between the respective original grayscale value and the respective original target grayscale value based on the respective mixing intensity in step S204 may include:
[0063] The grayscale variation limit is obtained by the difference between the original grayscale value and the original target grayscale value; the grayscale variation value is obtained by the product of the grayscale variation limit value and the mixing intensity; and the target grayscale value is obtained by the sum of the original grayscale value and the grayscale variation value.
[0064] Specifically, the terminal obtains the original grayscale value L. p And the original target gray value L′ p The difference yields the grayscale variation limit value (L′). p -L p According to the grayscale variation limit value (L′) p -L p ) and mixing intensity I p The product of these two values yields the grayscale change value (L′). p -L p )*I p Based on the original grayscale value L p With grayscale change value (L′) p -L p )*Ip The sum of these values yields the target grayscale value L′. p ′=L p +(L′ p -L p )*I p The solution in this embodiment can achieve linear interpolation between the original grayscale value and the original target grayscale value based on the mixing intensity to obtain the target grayscale value, so that the superimposed texture is natural and delicate, close to the natural texture of skin.
[0065] Step S205: Based on the target grayscale value of each pixel in the target area, obtain an image with added skin texture.
[0066] In this step, after the terminal obtains the target grayscale value of each pixel in the target area of the image to which the skin texture is to be added, it can obtain the corresponding color information based on the target grayscale value of each pixel in the target area, and thus obtain the image with the skin texture added.
[0067] Specifically, in some embodiments, step S205 may include:
[0068] Obtain the original hue value and original saturation of each pixel in the target area; convert the target grayscale value, original hue value, and original saturation of each pixel in the target area into corresponding color information to obtain the target color information of each pixel in the target area; obtain the image with added skin texture based on the target color information of each pixel in the target area.
[0069] This embodiment primarily converts the target grayscale value of each pixel in the target area into its corresponding RGB color information to obtain an image with added skin texture. In this embodiment, the terminal uses the target grayscale value L′ of each pixel in the target area during the conversion. p L′, and the original hue value and original saturation value of each pixel, that is, the target grayscale value L′ of each pixel by the terminal. p The original hue and saturation of each pixel are converted into corresponding RGB color information, which serves as the target color information for each pixel in the target area. Thus, an image with added skin texture is obtained based on the target color information of each pixel in the target area.
[0070] The solution provided in this embodiment is based on the fact that people are sensitive to changes in brightness and thus generate a sense of texture. Therefore, it is not necessary to change the hue and saturation (HS) of each pixel, but only to change its grayscale value (L). This can save computing resources while adding natural skin texture.
[0071] The method for adding skin texture information to an image provided in this application does not directly determine the target grayscale value of each pixel in the final image with added skin texture based on the skin texture image. Instead, it first determines the mixing intensity based on the original grayscale value of the pixel in the image to be textured, and then extracts the final target grayscale value between the original grayscale value and the original target grayscale value based on the mixing intensity to obtain the image with added skin texture. That is, the target grayscale value of each pixel in the final image with added skin texture is jointly determined by its original grayscale value and the corresponding skin texture grayscale value in the skin texture image, so that it fits the original image better. This can improve the adaptability of the added skin texture information to the original image, better compensate for the skin texture details lost after excessive beautification, and make the skin appear more natural and delicate in the image.
[0072] Regarding the preset correspondence between grayscale values and mixing intensity mentioned in step S202, in some embodiments, the preset correspondence between grayscale values and mixing intensity includes: the correspondence between a first type of grayscale range and mixing intensity and the correspondence between a second type of grayscale range and mixing intensity.
[0073] In this embodiment, two types of correspondences are provided for different grayscale ranges of pixel grayscale values: the first type of correspondence between grayscale range and mixing intensity and the second type of correspondence between grayscale range and mixing intensity.
[0074] The first type of grayscale interval and the relationship between the mixing intensity are as follows: when the grayscale value is in the first grayscale interval, the mixing intensity is set to the minimum value, which can be set to 0. That is, for a pixel whose grayscale value is in the first grayscale interval, the terminal will assign it a mixing intensity of the minimum value of 0 according to the relationship.
[0075] The correspondence between the second type of grayscale interval and the mixing intensity is as follows: when the grayscale value is within the second grayscale interval, the mixing intensity reaches its maximum value when the grayscale value is in the middle of the second grayscale interval, and decreases to its minimum value when the grayscale value changes from the middle grayscale value to the grayscale values at both ends of the second grayscale interval. This maximum value can be set to 1, and the minimum value can be set to 0. Specifically, the grayscale values at both ends of the second grayscale interval are called the end grayscale values, including the first end grayscale value and the second end grayscale value. The first end grayscale value is less than the second end grayscale value, and the grayscale value in the middle of the second grayscale interval is called the middle grayscale value. For example, if the second grayscale interval is 0.2 to 0.8, then the first end grayscale value is 0.2, the second end grayscale value is 0.8, and the middle grayscale value is 0.5. That is, for the second type of correspondence, for a pixel with a gray value in the middle gray value of 0.5, the terminal will assign it a mixing intensity of the maximum value of 1 according to the correspondence. For a pixel with a gray value in the first gray value of 0.2 or the second gray value of 0.8, the terminal will assign it a mixing intensity of the minimum value of 0. For a pixel with a gray value between the first gray value of 0.2 and the middle gray value of 0.5, or between the middle gray value of 0.5 and the second gray value of 0.8, the terminal will assign it a mixing intensity greater than 0 and less than 1. The closer it is to the middle gray value of 0.5, the closer the mixing intensity assigned to it will be to 1.
[0076] Based on the aforementioned correspondence between grayscale values and blending intensity, further, in step S202, based on the preset correspondence between grayscale values and blending intensity, the blending intensity of each pixel in the target area is determined according to its original grayscale value. This specifically includes:
[0077] If the original gray value of a pixel is less than or equal to the gray value at the first end of the second gray value interval, or if the original gray value of a pixel is greater than or equal to the gray value at the second end of the second gray value interval, then the original gray value of the pixel is determined to be in the first gray value interval, and the mixing intensity of the pixel is determined to be the minimum value. If the original gray value of a pixel is greater than the gray value at the first end and less than the gray value at the second end, then the original gray value of the pixel is determined to be in the second gray value interval, and the mixing intensity is determined within the range of values defined by the maximum and minimum values based on the proximity of the original gray value of the pixel to the intermediate gray value.
[0078] Based on the interval value example mentioned above, specifically, the terminal can first determine whether the original gray value of the pixel is in the first gray value interval or the second gray value interval.
[0079] Specifically, the terminal compares the original gray value of the pixel with the first gray value of 0.2 and the second gray value of 0.8 in the second gray range. If the original gray value of the pixel is less than or equal to the first gray value of 0.2, or greater than or equal to the second gray value of 0.8, the terminal determines that the original gray value of the pixel is in the first gray range and determines that the mixing intensity of the pixel is the minimum value of 0.
[0080] If the original gray value of a pixel is greater than the first gray value of 0.2 and less than the second gray value of 0.8, the terminal determines that the original gray value of the pixel is in the second gray range, and determines the mixing intensity within the range of 0 to 1 defined by the maximum value of 1 and the minimum value of 0, based on the degree of closeness between the original gray value of the pixel and the intermediate gray value of 0.5.
[0081] For the original grayscale value L of the pixel p When in the second grayscale range, the mixing intensity I p As an example, the terminal can determine the value using the following formula:
[0082]
[0083] Among them, L m L represents the middle gray value of the second grayscale range. r This represents the half-range of gray levels in the second gray level interval. For example... Figure 3 The intermediate grayscale value L is shown. m Set to 0.5, grayscale half-range L r A schematic diagram showing the relationship between grayscale value and mixing intensity when the grayscale value is 0.3. It can be seen that when the grayscale value is less than or equal to the first grayscale value (L... m -L r ), or, greater than or equal to the second grayscale value (L) m +L r When the grayscale value is in the middle grayscale value L, the corresponding mixing intensity is 0. m It reaches its maximum value of 1 at that time. Figure 4 The images show the skin texture effects before and after using the embodiments of this application.
[0084] Therefore, the solution provided in this embodiment can achieve a natural and delicate overlay texture that closely resembles the natural texture of skin, while also reducing the intensity of the overlay texture in the shadow area of the target region of the image and creating a natural transition effect between light and dark boundaries.
[0085] In one embodiment, such as Figure 5 As shown, a method for processing facial images in live streaming is provided. This method is executed by a terminal and includes the following steps:
[0086] Step S501: In response to the beautification processing instruction on the face image provided by the anchor, the beautified face image is obtained.
[0087] Step S502: The beautified face image is used as the image to which skin texture is to be added, and the beautified face image with added skin texture is obtained according to the method for adding skin texture information to the image as described in any of the above embodiments.
[0088] Step S503: Display the beautified face image with added skin texture.
[0089] In this embodiment, combined with Figure 6 The terminal can provide a facial image processing interface in live streaming applications. With the broadcaster's authorization, the terminal can capture and obtain the broadcaster's facial image, which is then displayed in the facial image display area of the facial image processing interface. The broadcaster can click on skin smoothing or texture retouching on the facial image processing interface and set the texture retouching level (e.g., 100) to trigger a beautification command for the facial image. The terminal responds to the beautification command by performing the corresponding beautification processing on the facial image, resulting in a beautified facial image. Then, the terminal uses this beautified facial image as an image to which skin texture is to be added. Following the method for adding skin texture information to an image as described in any of the above embodiments, skin texture information is added to the beautified facial image, resulting in a beautified facial image with added skin texture. The terminal can then display this beautified facial image with added skin texture on the facial image processing interface.
[0090] The solution in this embodiment enables the method of adding skin texture information to the aforementioned image to be applied to the processing of the anchor's face image in the live streaming scene, improving the adaptability of the added skin texture information to the original image, better compensating for the skin texture details lost after excessive beautification, making the superimposed skin texture natural and delicate, close to the natural skin texture, and also reducing the superimposed intensity of skin texture in the shadow area, making the transition effect of the light and dark boundary natural, and can use GPU hardware acceleration to achieve real-time processing performance on general terminals such as mobile phones and PCs.
[0091] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0092] Based on the same inventive concept, this application also provides a related apparatus for implementing the aforementioned related methods. The solution provided by this apparatus is similar to the implementation scheme described in the above methods; therefore, the specific limitations in one or more related apparatus embodiments provided below can be found in the limitations of the related methods described above, and will not be repeated here.
[0093] In one embodiment, such as Figure 7 As shown, an apparatus for adding skin texture information to an image is provided. The apparatus 700 includes:
[0094] Image acquisition module 701 is used to acquire an image to which skin texture is to be added, and to acquire a skin texture image for adding skin texture to a target area in the image to which skin texture is to be added;
[0095] The intensity determination module 702 is used to determine the mixing intensity of each pixel in the target area based on a preset correspondence between grayscale values and mixing intensity, according to the original grayscale values of each pixel in the target area.
[0096] The original target value acquisition module 703 is used to acquire the original target gray value of each pixel in the target area based on the original gray value of each pixel in the target area and the skin texture gray value corresponding to each pixel in the target area in the skin texture image.
[0097] The target value determination module 704 is used to determine the target gray value of each pixel in the target region based on its own mixing intensity, between its own original gray value and its own original target gray value; wherein, the greater the mixing intensity, the closer the target gray value is to the original target gray value;
[0098] The image acquisition module 705 is used to obtain an image with added skin texture based on the target grayscale value of each pixel in the target region.
[0099] In one embodiment, the preset correspondence between grayscale values and mixing intensity includes: a first type of grayscale interval and a second type of grayscale interval and a mixing intensity; wherein, the first type of grayscale interval and mixing intensity correspondence is that when the grayscale value is in the first grayscale interval, the mixing intensity is set to the minimum value; the second type of grayscale interval and mixing intensity correspondence is that when the grayscale value is in the second grayscale interval, the mixing intensity takes the maximum value when the grayscale value is in the middle grayscale value of the second grayscale interval, and decreases to the minimum value when the grayscale value changes from the middle grayscale value to the grayscale values at both ends of the second grayscale interval.
[0100] In one embodiment, the intensity determination module 702 is configured to determine that the original gray value of a pixel is in the first gray range and the mixing intensity of the pixel is determined to be minimum if the original gray value of the pixel is less than or equal to the first gray value of the second gray range, or if the original gray value of the pixel is greater than or equal to the second gray value of the second gray range; and if the original gray value of the pixel is greater than the first gray value and less than the second gray value, the original gray value of the pixel is determined to be in the second gray range, and the mixing intensity is determined within a range defined by the maximum and minimum values based on the proximity of the original gray value of the pixel to the intermediate gray value.
[0101] In one embodiment, the image acquisition module 705 is used to acquire the original hue value and original saturation of each pixel in the target region; convert the target grayscale value, original hue value and original saturation of each pixel in the target region into corresponding color information to obtain the target color information of each pixel in the target region; and obtain an image with added skin texture based on the target color information of each pixel in the target region.
[0102] In one embodiment, the target value determination module 704 is used to obtain a grayscale variation limit value based on the difference between the original grayscale value and the original target grayscale value; to obtain a grayscale variation value based on the product of the grayscale variation limit value and the mixing intensity; and to obtain the target grayscale value based on the sum of the original grayscale value and the grayscale variation value.
[0103] In one embodiment, such as Figure 8 As shown, a facial image processing apparatus for live streaming is provided. The apparatus 800 includes:
[0104] The beautification processing module 801 is used to respond to the beautification processing instruction of the face image provided by the anchor and obtain the beautified face image;
[0105] The texture adding module 802 is used to take the beautified face image as the image to which skin texture is to be added, and to obtain the beautified face image with added skin texture according to the method described in any of the above embodiments;
[0106] The image display module 803 is used to display the beautified face image with added skin texture.
[0107] Each module in the above-mentioned device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the electronic device in hardware form or independent of it, or stored in the memory of the electronic device in software form, so that the processor can call and execute the operations corresponding to each module.
[0108] In one embodiment, an electronic device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown, the electronic device includes a processor, memory, communication interface, display screen, and input device connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for adding skin texture information to an image and a method for processing facial images in live web broadcasts. The display screen can be an LCD screen or an e-ink screen. The input device can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the device's casing, or an external keyboard, touchpad, or mouse.
[0109] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the electronic device to which the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0110] In one embodiment, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0111] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0112] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0113] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0114] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0115] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for adding skin texture information to an image, characterized in that, The method includes: Obtain an image to which skin texture is to be added, and obtain a skin texture image for adding skin texture to the target area in the image to which skin texture is to be added; Based on a preset correspondence between grayscale values and blending intensities, the blending intensity of each pixel in the target area is determined according to its original grayscale value. This includes: if the original grayscale value of a pixel is less than or equal to the first grayscale value of the second grayscale interval, or if the original grayscale value of a pixel is greater than or equal to the second grayscale value of the second grayscale interval, then the original grayscale value of the pixel is determined to be within the first grayscale interval, and the blending intensity of the pixel is determined to be the minimum value; if the original grayscale value of a pixel is greater than the first grayscale value and less than the second grayscale value, then the original grayscale value of the pixel is determined to be within the second grayscale interval, and the blending intensity is determined to be the minimum value based on the original grayscale value of the pixel and the intermediate grayscale value. The degree of closeness of the values determines the mixing intensity within a range defined by the maximum and minimum values; wherein, the preset correspondence between grayscale values and mixing intensity includes: a first type of grayscale interval and a second type of grayscale interval and a mixing intensity; wherein, the first type of grayscale interval and mixing intensity correspondence is that when the grayscale value is in the first grayscale interval, the mixing intensity is set to the minimum value; the second type of grayscale interval and mixing intensity correspondence is that when the grayscale value is in the second grayscale interval, the mixing intensity takes the maximum value when the grayscale value is in the middle grayscale value of the second grayscale interval, and decreases to the minimum value when the grayscale value changes from the middle grayscale value to the grayscale values at both ends of the second grayscale interval; Based on the original grayscale value of each pixel in the target region and the corresponding skin texture grayscale value of each pixel in the target region in the skin texture image, the original target grayscale value of each pixel in the target region is obtained; the original target grayscale value is the target grayscale value that the pixel should have originally been set to when it has not been mixed based on the mixing intensity. For each pixel in the target region, a target gray value is determined between its original gray value and its original target gray value based on its respective mixing intensity; wherein, the greater the mixing intensity, the closer the target gray value is to the original target gray value; Based on the target grayscale value of each pixel in the target region, an image with added skin texture is obtained.
2. The method according to claim 1, characterized in that, The step of obtaining an image with added skin texture based on the target grayscale value of each pixel in the target region includes: Obtain the original hue value and original saturation of each pixel in the target region; The target grayscale value, original hue value and original saturation of each pixel in the target area are converted into corresponding color information to obtain the target color information of each pixel in the target area. Based on the target color information of each pixel in the target area, an image with added skin texture is obtained.
3. The method according to claim 1 or 2, characterized in that, The process of determining the target grayscale value between the original grayscale value and the original target grayscale value based on the respective mixing intensity includes: The grayscale variation limit value is obtained based on the difference between the original grayscale value and the original target grayscale value. The grayscale change value is obtained by multiplying the grayscale change limit value by the mixing intensity. The target gray value is obtained by summing the original gray value and the gray value change.
4. A method for processing facial images in live streaming, characterized in that, The method includes: In response to the beautification instruction on the facial image provided by the anchor, the beautified facial image is obtained; The beautified face image is used as the image to which skin texture is to be added, and the beautified face image with added skin texture is obtained according to any one of claims 1 to 3. The image shows a beautified face with added skin texture.
5. An apparatus for adding skin texture information to an image, characterized in that, The device includes: The image acquisition module is used to acquire an image to which skin texture is to be added, and to acquire a skin texture image for adding skin texture to a target area in the image to which skin texture is to be added; An intensity determination module is used to determine the mixing intensity of each pixel in the target area based on a preset correspondence between grayscale values and mixing intensity, according to the original grayscale values of each pixel in the target area. This includes: if the original grayscale value of a pixel is less than or equal to the first grayscale value of the second grayscale interval, or if the original grayscale value of a pixel is greater than or equal to the second grayscale value of the second grayscale interval, then the original grayscale value of the pixel is determined to be within the first grayscale interval, and the mixing intensity of the pixel is determined to be the minimum value; if the original grayscale value of a pixel is greater than the first grayscale value and less than the second grayscale value, then the original grayscale value of the pixel is determined to be within the second grayscale interval, and the mixing intensity of the pixel is determined to be the minimum value based on the original grayscale value and the mixing intensity of the pixel. The degree of proximity of the intermediate grayscale values determines the mixing intensity within a range defined by the maximum and minimum values. The preset correspondence between grayscale values and mixing intensity includes: a first type of grayscale interval and a second type of grayscale interval and a mixing intensity. Specifically, the first type of grayscale interval and mixing intensity is such that when the grayscale value is in the first grayscale interval, the mixing intensity is set to the minimum value. The second type of grayscale interval and mixing intensity is such that when the grayscale value is in the second grayscale interval, the mixing intensity reaches its maximum value when the grayscale value is in the middle of the second grayscale interval, and decreases to the minimum value when the grayscale value changes from the middle grayscale value to the grayscale values at either end of the second grayscale interval. The original target value acquisition module is used to acquire the original target gray value of each pixel in the target area based on the original gray value of each pixel in the target area and the skin texture gray value corresponding to each pixel in the target area in the skin texture image; the original target gray value is the target gray value that the pixel should have originally been set when it has not been mixed based on the mixing intensity. The target value determination module is used to determine the target gray value of each pixel in the target region based on its own mixing intensity, between its original gray value and its original target gray value; wherein, the greater the mixing intensity, the closer the target gray value is to the original target gray value; The image acquisition module is used to obtain an image with added skin texture based on the target grayscale value of each pixel in the target region.
6. A device for processing facial images during live streaming, characterized in that, The device includes: The beautification module is used to respond to beautification instructions on the facial image provided by the anchor and obtain the beautified facial image. A texture adding module is used to take the beautified face image as an image to which skin texture is to be added, and to obtain a beautified face image with added skin texture according to any one of claims 1 to 3. The image display module is used to display the beautified facial image with added skin texture.
7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Face target area detection method, device and apparatus
CN112699760A
Image processing method and device, electronic equipment and storage medium
CN113205568A