Portrait beautification method and apparatus, electronic device, and storage medium

CN117408918BActive Publication Date: 2026-08-11GUANGZHOU HUYA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-16
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

然而目前的美颜功能常常会过度磨皮,导致美颜后的图像出现失真并且缺乏质感,美颜效果较差

Benefits of technology

[0057] This invention provides a portrait beautification method, apparatus, electronic device, and storage medium. The method includes: firstly, performing face detection and skin detection on the original portrait image in a video stream to obtain a face mask image and a skin mask image. The face mask image represents the facial feature area and the non-facial feature area, and the skin mask image represents the skin area. Then, performing filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the portrait outline area. Next, based on the face mask image, skin mask image, and portrait detail image, obtaining a beautification intensity distribution map. The beautification intensity distribution map represents the beautification degree of the facial feature area, the non-facial feature area, the skin area, and the portrait outline area. Finally, based on the original portrait image and the beautification intensity distribution map, obtaining a beautified portrait image corresponding to the original portrait image. By acquiring each area in the portrait image and applying different intensities of beautification processing to each area using the beautification intensity distribution map, not only is a beautification effect achieved, but the realism of the portrait is also preserved, improving the texture of the beautified portrait.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117408918B_ABST
    Figure CN117408918B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image processing technology, providing a portrait beautification method, apparatus, electronic device, and storage medium. The method includes: performing face detection and skin detection on an original portrait image from a video stream to obtain a face mask image and a skin mask image; then performing filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the portrait contour region; furthermore, obtaining a beautification intensity distribution map based on the face mask image, skin mask image, and portrait detail image; the beautification intensity distribution map represents the degree of beautification in the facial feature region, non-facial feature region, skin region, and portrait contour region; finally, obtaining a beautified portrait image corresponding to the original portrait image based on the original portrait image and the beautification intensity distribution map. By using the beautification intensity distribution map to perform beautification processing of different intensities on various regions of the portrait, not only is a beautification effect achieved, but the realism of the portrait is also preserved, improving the texture of the beautified portrait.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically, to a portrait beautification method, apparatus, electronic device, and storage medium. Background Technology

[0002] Nowadays, to achieve satisfactory results in their live streams, broadcasters typically use live streaming software with beauty filters. As these software programs become increasingly popular, viewers have higher expectations for these filters, hoping the results will closely resemble their real selves while exceeding the actual appearance, particularly focusing on effects like skin smoothing and blurring. However, current beauty filters often over-smooth the skin, resulting in distorted and textureless images with poor overall beauty quality. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a portrait beautification method, apparatus, electronic device and storage medium.

[0004] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0005] In a first aspect, the present invention provides a portrait beautification method, the portrait beautification method comprising:

[0006] Face detection and skin detection are performed on the original portrait image in the video stream to obtain a face mask image and a skin mask image; the face mask image represents the facial features area and the non-facial features area of ​​the face, and the skin mask image represents the skin area;

[0007] Based on the original portrait image, filtering and high-contrast processing are performed to obtain a portrait detail image representing the portrait outline region;

[0008] Based on the face mask image, the skin mask image, and the portrait detail image, a beautification intensity distribution map is obtained; the beautification intensity distribution map represents the degree of beautification of the facial features area, the non-facial features area, the skin area, and the portrait contour area;

[0009] Based on the original portrait image and the beautification intensity distribution map, a beautified portrait image corresponding to the original portrait image is obtained.

[0010] In an optional implementation, the step of performing filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the portrait outline region includes:

[0011] The original portrait image is reduced in size to obtain a smaller portrait image;

[0012] The portrait thumbnail is subjected to nonlocal mean filtering to obtain a first blurred portrait image;

[0013] The portrait thumbnail is subjected to mean filtering to obtain an initial blurred portrait image;

[0014] The initial blurred image is subjected to Gaussian filtering to obtain the second blurred image.

[0015] High-contrast processing is performed on the first blurred image and the second blurred image to obtain the detailed image of the portrait.

[0016] In an optional implementation, the step of performing nonlocal mean filtering on the portrait thumbnail to obtain a first blurred portrait image includes:

[0017] Take any pixel in the portrait thumbnail as the target pixel;

[0018] Obtain multiple pixels surrounding the target pixel according to a preset first rectangular window;

[0019] By rotating the inscribed circle of the first rectangular window by a preset angle, sampling is performed within the first rectangular window to obtain multiple associated pixels corresponding to the target pixel.

[0020] Based on the color value of the target pixel and the color value of each associated pixel, calculate the weight value of each associated pixel;

[0021] Calculate the average of the weight values ​​of all associated pixels to obtain the target weight value;

[0022] The first color value of the target pixel is obtained by weighting the color value of each pixel in the first rectangular window with the target weight value; the first color value of the target pixel is the color value of the pixel corresponding to the target pixel in the first portrait blur image;

[0023] By traversing each pixel in the portrait thumbnail, the first blurred portrait image is obtained.

[0024] In an optional implementation, the step of performing mean filtering on the portrait thumbnail to obtain an initial blurred portrait image includes:

[0025] Take any pixel in the portrait thumbnail as the target pixel;

[0026] Obtain multiple pixels surrounding the target pixel using a preset second rectangular window;

[0027] Calculate the sum of the color values ​​of each row of pixels in the second rectangular window to obtain the color value corresponding to each row;

[0028] The color values ​​corresponding to each row are added together to obtain a total color value, and the average value is calculated based on the total color value and the total number of pixels in the second rectangular window to obtain the second color value of the target pixel; the second color value of the target pixel is the color value of the pixel corresponding to the target pixel in the initial portrait blur image;

[0029] By traversing each pixel in the portrait thumbnail, the initial portrait blur image is obtained.

[0030] In an optional implementation, the step of performing Gaussian filtering on the initial blurred portrait image to obtain a second blurred portrait image includes:

[0031] Based on the color value of each pixel in the initial blurred portrait image, the coordinates of each pixel in the initial blurred portrait image in the Lab color space are obtained;

[0032] Take any pixel in the initial blurred portrait image as the pixel to be processed;

[0033] According to the preset second rectangular window, multiple neighboring pixels around the pixel to be processed are obtained, and the distance is calculated based on the coordinates of each neighboring pixel and the coordinates of the pixel to be processed to obtain the similarity between each neighboring pixel and the pixel to be processed.

[0034] According to a preset first mapping relationship, the weight value of each adjacent pixel is obtained based on the similarity of each adjacent pixel.

[0035] A weighted calculation is performed based on the color value and weight value of each of the adjacent pixels to obtain a new color value for the pixel to be processed; the new color value of the pixel to be processed is the color value of the pixel corresponding to the pixel to be processed in the second portrait blur image;

[0036] By traversing each pixel in the initial blurred portrait image, the second blurred portrait image is obtained.

[0037] In an optional implementation, the step of obtaining the beautification intensity distribution map based on the face mask image, the skin mask image, and the portrait detail image includes:

[0038] Based on the color value of each pixel in the portrait detail image, the coordinates of each pixel in the portrait detail image in the YUV color space are obtained;

[0039] Take any pixel in the portrait detail image as the pixel to be determined;

[0040] According to the preset second rectangular window, multiple neighboring pixels around the undetermined pixel are obtained, and the distance is calculated based on the coordinates of each neighboring pixel and the coordinates of the undetermined pixel to obtain the similarity between each neighboring pixel and the undetermined pixel;

[0041] According to the preset second mapping relationship, the weight value of each neighboring pixel is obtained based on the similarity of each neighboring pixel;

[0042] A weighted calculation is performed based on the color value and weight value of each of the neighboring pixels to obtain a new color value for the undetermined pixel; the new color value of the undetermined pixel is the color value of the pixel corresponding to the undetermined pixel in the surface blur map;

[0043] By traversing each pixel in the portrait detail image, the surface blur map is obtained;

[0044] The face mask image and the skin mask image are fused together to obtain a mask fusion image;

[0045] The beautification intensity distribution map is obtained by calculating based on the beautification parameters input by the user, the mask blending map, and the surface blur map.

[0046] In an optional implementation, the step of obtaining a beautified portrait image corresponding to the original portrait image based on the original portrait image and the beautification intensity distribution map includes:

[0047] A first high-frequency signal is calculated based on the original portrait image and the first blurred portrait image, and the first high-frequency signal is enhanced and then superimposed on the first blurred portrait image to obtain a first enhanced portrait image.

[0048] According to the beautification intensity distribution map, the first portrait enhancement map and the second portrait blur map are mixed to obtain the second portrait enhancement map;

[0049] A second high-frequency signal is calculated based on the second enhanced portrait image and the second blurred portrait image. The second high-frequency signal is then enhanced and superimposed onto the second enhanced portrait image to obtain a beautified portrait image corresponding to the original portrait image.

[0050] Secondly, the present invention provides a portrait beautification device, the portrait beautification device comprising:

[0051] The detection module is used to perform face detection and skin detection on the original portrait image in the video stream to obtain a face mask image and a skin mask image; the face mask image represents the facial features area and the non-facial features area of ​​the face, and the skin mask image represents the skin area;

[0052] The beautification module is used to perform filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the outline area of ​​the portrait.

[0053] Based on the face mask image, the skin mask image, and the portrait detail image, a beautification intensity distribution map is obtained; the beautification intensity distribution map represents the degree of beautification of the facial features area, the non-facial features area, the skin area, and the portrait contour area;

[0054] Based on the original portrait image and the beautification intensity distribution map, a beautified portrait image corresponding to the original portrait image is obtained.

[0055] Thirdly, the present invention provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the portrait beautification method described in any of the foregoing embodiments.

[0056] Fourthly, the present invention provides a storage medium storing a computer program, which, when executed by a processor, implements the portrait beautification method described in any of the foregoing embodiments.

[0057] This invention provides a portrait beautification method, apparatus, electronic device, and storage medium. The method includes: firstly, performing face detection and skin detection on the original portrait image in a video stream to obtain a face mask image and a skin mask image. The face mask image represents the facial feature area and the non-facial feature area, and the skin mask image represents the skin area. Then, performing filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the portrait outline area. Next, based on the face mask image, skin mask image, and portrait detail image, obtaining a beautification intensity distribution map. The beautification intensity distribution map represents the beautification degree of the facial feature area, the non-facial feature area, the skin area, and the portrait outline area. Finally, based on the original portrait image and the beautification intensity distribution map, obtaining a beautified portrait image corresponding to the original portrait image. By acquiring each area in the portrait image and applying different intensities of beautification processing to each area using the beautification intensity distribution map, not only is a beautification effect achieved, but the realism of the portrait is also preserved, improving the texture of the beautified portrait.

[0058] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0059] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0060] Figure 1 A block diagram of an electronic device provided in an embodiment of the present invention is shown;

[0061] Figure 2 This diagram illustrates a flowchart of a portrait beautification method provided in an embodiment of the present invention.

[0062] Figure 3 This illustration shows another flowchart of the portrait beautification method provided in an embodiment of the present invention;

[0063] Figure 4 An example diagram of a portrait beautification method provided in an embodiment of the present invention is shown;

[0064] Figure 5 A functional block diagram of a portrait beautification device provided in an embodiment of the present invention is shown.

[0065] Icons: 100 - Electronic device; 110 - Bus; 120 - Processor; 130 - Memory; 150 - I / O module; 170 - Communication interface; 300 - Portrait beautification device; 310 - Detection module; 330 - Beautification module. Detailed Implementation

[0066] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0067] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0068] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0069] Please refer to Figure 1 This is a block diagram of an electronic device 100 provided in an embodiment of the present invention. The electronic device 100 includes a bus 110, a processor 120, a memory 130, an I / O module 150, and a communication interface 170.

[0070] Bus 110 may be a circuit that connects the above-mentioned components to each other and transmits communication between the above-mentioned components.

[0071] The processor 120 can receive commands from the other components (such as memory 130, I / O module 150, communication interface 170, etc.) via bus 110, interpret the received commands, and perform calculations or data processing according to the interpreted commands.

[0072] The processor 120 can be an integrated circuit chip with signal processing capabilities. The processor 120 can be a general-purpose processor, including a graphics processing unit (GPU), a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0073] The memory 130 may store commands or data received from the processor 120 or other components (such as I / O module 150, communication interface 170, etc.) or commands or data generated by the processor 120 or other components.

[0074] The memory 130 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), or electrically erasable programmable read-only memory (EEPROM).

[0075] The I / O module 150 can receive commands or data input by the user via input-output means (e.g., sensors, keyboard, touch screen, etc.), and can transmit the received commands or data to the processor 120 or memory 130 via the bus 110. It is also used to display various information received, stored, and processed from the aforementioned components (e.g., multimedia data, text data), and can display video, images, data, etc., to the user.

[0076] The communication interface 170 can be used to communicate with other devices for signaling or data.

[0077] Understandable, Figure 1 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0078] The electronic device 100 provided in this embodiment of the invention may be a smartphone, personal computer, tablet computer, wearable device, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc. This embodiment of the invention does not impose any limitations on this.

[0079] It should be noted that the electronic device 100 is equipped with live streaming software, and the electronic device 100 implements the portrait beautification method provided in this embodiment of the invention by running the live streaming software.

[0080] The following will use the aforementioned electronic device 100 as the execution subject to perform the various steps of the methods provided in the embodiments of the present invention and achieve the corresponding technical effects. Please refer to... Figure 2 , Figure 2This is a schematic flowchart of a portrait beautification method provided in an embodiment of the present invention.

[0081] Step S202: Perform face detection and skin detection on the original portrait image in the video stream to obtain a face mask image and a skin mask image; the face mask image represents the facial features area and the non-facial features area of ​​the face, and the skin mask image represents the skin area;

[0082] In this embodiment, a video frame containing a human image can be obtained from a live video stream to obtain the original human image image. Then, a pre-trained face recognition model is used to detect faces in the original human image image, obtaining face point data. This face point data is then used as vertex coordinates for rendering, thus obtaining a face mask image. This face mask image can not only represent the position of the face, but also use differences in color intensity to represent the facial features and non-facial features to reflect facial details.

[0083] Understandably, existing technologies often only beautify the face, leading to significant differences between the face and other parts of the portrait, such as the neck and arms, resulting in an unnatural beautification effect. Therefore, this embodiment also uses a pre-trained skin recognition model to detect skin in the original portrait image, obtaining the skin areas in the portrait, which facilitates subsequent processing of the skin areas to improve the beautification effect.

[0084] Step S204: Based on the original portrait image, perform filtering and high-contrast processing to obtain a portrait detail image representing the portrait outline area;

[0085] In this embodiment, the original portrait image can be filtered to analyze the high and low frequency signals in the original portrait image and filter out noise. Then, based on the filtered original portrait image, high contrast processing is performed to distinguish the area where the portrait is located from the background area in order to obtain a portrait detail image representing the outline area of ​​the portrait.

[0086] It is understood that the portrait outline area represents the part where the portrait meets the background. By obtaining a portrait detail image, the portrait outline area can be processed in the future, making the angle between the portrait and the background more natural, thereby improving the portrait beautification effect.

[0087] Step S206: Based on the face mask image, skin mask image, and portrait detail image, obtain the beautification intensity distribution map; the beautification intensity distribution map represents the degree of beautification in the facial features area, the non-facial features area, the skin area, and the portrait contour area;

[0088] Step S208: Based on the original portrait image and the beautification intensity distribution map, obtain the beautified portrait image corresponding to the original portrait image;

[0089] In this embodiment, based on the face mask image, skin mask image, and portrait detail image, the beautification intensity parameters of the facial features region, non-facial features region, skin region, and portrait contour region are determined, thus obtaining a beautification intensity distribution map. This beautification intensity distribution map can reflect the degree of beautification in different regions of the original portrait image. Then, beautification processing is performed on the original portrait image based on the beautification intensity distribution map to obtain the beautified portrait image corresponding to the original portrait image.

[0090] It is understood that the embodiments of the present invention obtain the facial features area, non-facial features area, skin area and portrait outline area of ​​the portrait image, and use a beautification intensity distribution map to perform beautification processing of different areas in the portrait with different intensities, thereby not only achieving the beautification effect but also preserving the authenticity of the portrait and improving the texture of the portrait beautification.

[0091] As can be seen from the above steps, firstly, face detection and skin detection are performed on the original portrait image in the video stream to obtain a face mask image and a skin mask image. The face mask image represents the facial features and non-facial features of the face, and the skin mask image represents the skin area. Then, filtering and high-contrast processing are performed on the original portrait image to obtain a portrait detail image representing the portrait outline area. Next, based on the face mask image, skin mask image, and portrait detail image, a beautification intensity distribution map is obtained. The beautification intensity distribution map represents the degree of beautification in the facial features, non-facial features, skin area, and portrait outline area. Finally, based on the original portrait image and the beautification intensity distribution map, the corresponding beautified portrait image is obtained. By obtaining each region in the portrait image and applying different intensities of beautification processing to each region using the beautification intensity distribution map, not only is a beautification effect achieved, but the realism of the portrait is also preserved, improving the texture of the beautified portrait.

[0092] Optionally, for step S204, this embodiment of the invention provides a possible implementation method, please refer to [link to relevant documentation]. Figure 3 .

[0093] Step S204-1: Reduce the size of the original portrait image to obtain a smaller portrait image;

[0094] Understandably, given the high real-time requirements of live video streams, the original human image can be scaled down to facilitate subsequent processing based on the scaled-down image, thereby speeding up image processing.

[0095] Step S204-3: Perform non-local mean filtering on the portrait thumbnail to obtain the first blurred portrait image;

[0096] Step S204-5: Perform mean filtering on the portrait thumbnail to obtain the initial blurred portrait image;

[0097] Step S204-7: Perform Gaussian filtering on the initial blurred portrait image to obtain the second blurred portrait image;

[0098] In this embodiment, different filtering methods can be used to process the portrait thumbnail to obtain portrait blur images with different characteristics, so as to reflect the portrait information in the image from multiple perspectives. Non-local mean filtering can be used to process the portrait thumbnail, thus obtaining the first portrait blur image. Non-local mean filtering can preserve the texture details in the portrait.

[0099] Furthermore, mean filtering can be used to initially process the portrait image to obtain an initial blurred image, and then Gaussian filtering can be used to process the initial blurred image to obtain a second blurred image. Gaussian filtering can remove noise from the image and smooth it.

[0100] Step S204-9: Perform high-contrast processing on the first blurred portrait image and the second blurred portrait image to obtain a portrait detail image;

[0101] In this embodiment, high contrast calculation is performed based on the first blurred image and the second blurred image. That is, the color values ​​of corresponding pixels in the first blurred image and the second blurred image are subtracted, and the difference in color values ​​is calculated with a preset value to obtain the portrait detail image.

[0102] Optionally, for step S204-3, this embodiment of the invention provides a possible implementation.

[0103] Step S204-3-1: Take any pixel in the portrait thumbnail as the target pixel.

[0104] In this embodiment, the processing of each pixel in the portrait thumbnail is similar in the process of obtaining the first blurred portrait image. For simplicity, the following example will use any pixel in the portrait thumbnail as the target pixel.

[0105] Step S204-3-3: Obtain multiple pixels around the target pixel according to the preset first rectangular window;

[0106] Step S204-3-5: By rotating the inscribed circle of the first rectangular window by a preset angle, sampling is performed in the first rectangular window to obtain multiple associated pixels corresponding to the target pixel.

[0107] Step S204-3-7: Calculate the weight value of each associated pixel based on the color value of the target pixel and the color value of each associated pixel;

[0108] Step S204-3-9: Calculate the average weight value of all associated pixels to obtain the target weight value;

[0109] Step S204-3-11: Perform a weighted calculation based on the color value and target weight value of each pixel in the first rectangular window to obtain the first color value of the target pixel; the first color value of the target pixel is the color value of the pixel corresponding to the target pixel in the first portrait blur image;

[0110] Understandably, conventional non-mean filtering methods typically use search windows and neighborhood windows to determine weight values. However, this method involves a large amount of computation, takes a long time, and consumes a lot of computing resources. Therefore, this embodiment of the invention does not use a neighborhood window, but instead uses a search window to sample in a circular manner. Compared to a square window, using a circular method can optimize the edges of the curve and reduce the jaggedness of the edges.

[0111] For ease of understanding, an example is provided in this embodiment of the invention. For example, the size of the first rectangular window is 5*5, and the preset angle is 90°. It should be understood that the size of the first rectangular window and the preset rotation angle can be set according to actual conditions, and this embodiment of the invention does not limit them.

[0112] In step S204-3-3, the target pixel is used as the center point of the first rectangular window, and multiple pixels surrounding the target pixel are obtained through the first rectangular window. In step S204-3-5, the radius from the center of the inscribed circle of the first rectangular window to the upper left vertex of the first rectangular window is used as a reference line. By rotating the inscribed circle by a preset angle and combining it with the position of the reference line, sampling is performed in the first rectangular window to obtain multiple associated pixels corresponding to the target pixel.

[0113] like Figure 4 As shown, the reference line is sampled for the first time at its initial position to obtain the first associated pixel, which is the pixel located at the upper left corner of the first rectangular window. Then, the inscribed circle is rotated 90° clockwise and sampled for the second time based on the position of the reference line to obtain the second associated pixel, which is the pixel located at the upper right corner of the first rectangular window. Next, the inscribed circle is rotated 90° clockwise and sampled for the third time based on the position of the reference line to obtain the third associated pixel, which is the pixel located at the lower right corner of the first rectangular window. Finally, the inscribed circle is rotated 90° clockwise and sampled for the fourth time based on the position of the reference line to obtain the fourth associated pixel, which is the pixel located at the lower left corner of the first rectangular window. Thus, four associated pixels are obtained.

[0114] In step S204-3-7, for each obtained associated pixel, the squared difference between the color value of the associated pixel and the color value of the target pixel is calculated to obtain the distance between them. Then, the weight value of the associated pixel is calculated according to the preset formula weight = exp(dist * s), where weight represents the weight value of the associated pixel, dist represents the distance between the associated pixel and the target pixel, s represents a preset parameter, s can be set to -11.11111, and exp() represents an exponential function with the natural constant e as the base. By processing each associated pixel in a similar manner, the weight value of each associated pixel can be obtained.

[0115] In step S204-3-9, the average weight value of all associated pixels is calculated to obtain the target weight value, which is then used as the weight of each pixel in the first rectangular window. In step S204-3-11, a weighted calculation is performed based on the color value of each pixel in the first rectangular window and the target weight value to obtain the first color value of the target pixel. This first color value of the target pixel is the color value of the pixel corresponding to the target pixel in the first blurred portrait image.

[0116] Step S204-3-13: Traverse each pixel in the portrait thumbnail to obtain the first blurred portrait image.

[0117] In this embodiment, each pixel in the portrait thumbnail is processed in a similar manner as described above to obtain the first blurred portrait image.

[0118] Optionally, for steps S204-5, this embodiment of the invention provides a possible implementation.

[0119] Step S204-5-1: Take any pixel in the portrait thumbnail as the target pixel.

[0120] In this embodiment, the processing of each pixel in the portrait thumbnail is similar during the process of obtaining the initial blurred portrait image. For simplicity, the following example will use any pixel in the portrait thumbnail as the target pixel.

[0121] Step S204-5-3: Obtain multiple pixels around the target pixel according to the preset second rectangular window;

[0122] Step S204-5-5: Calculate the sum of the color values ​​of each row of pixels in the second rectangular window to obtain the color value corresponding to each row;

[0123] Step S204-5-7: Add the color values ​​corresponding to each row to obtain the total color value, and calculate the average value based on the total color value and the total number of pixels in the second rectangular window to obtain the second color value of the target pixel; the second color value of the target pixel is the color value of the pixel corresponding to the target pixel in the initial portrait blur image;

[0124] Understandably, conventional mean filtering methods typically involve sequentially summing the color values ​​of multiple pixels within a rectangular window and then calculating the average. However, this method is computationally time-consuming. Therefore, this embodiment of the invention performs the calculation in both horizontal and vertical directions, thereby reducing computational complexity and time.

[0125] In this embodiment, the target pixel is used as the center point of the second rectangular window. Multiple pixels surrounding the target pixel are acquired through the second rectangular window. Then, processing is performed horizontally, calculating the sum of the color values ​​of each row of pixels within the second rectangular window to obtain the color value for each row. Next, processing is performed vertically, adding the color values ​​of each row to obtain the total color value. The average value is then calculated based on the total color value and the total number of pixels in the second rectangular window to obtain the second color value of the target pixel. This second color value of the target pixel is the color value of the pixel corresponding to the target pixel in the initial blurred portrait image.

[0126] Assuming the position of the target pixel in the portrait thumbnail is represented by (x, y), and the size of the second rectangular window is (2n+1)*(2n+1), where n is a positive integer, the process of calculating the second color value of the target pixel can be expressed by the formula: Where P′(x,y) represents the second color value of the target pixel, and P(i,j) represents the color value of a pixel in the second rectangular window.

[0127] Step S204-5-9: Traverse each pixel in the portrait thumbnail to obtain the initial blurred portrait image.

[0128] In this embodiment, each pixel in the portrait thumbnail is processed in a similar manner to that described above to obtain the initial blurred portrait image.

[0129] Optionally, for steps S204-7, this embodiment of the invention provides a possible implementation.

[0130] Step S204-7-1: Based on the color value of each pixel in the initial portrait blur image, obtain the coordinates of each pixel in the Lab color space in the initial portrait blur image;

[0131] In this embodiment, the Lab color space is used, where L represents luminance and a and b represent color contrast dimensions. The color values ​​of each pixel in the initial blurred portrait image can be converted to the Lab color space to obtain the coordinates of each pixel in the initial blurred portrait image.

[0132] Step S204-7-3: Take any pixel in the initial blurred portrait image as the pixel to be processed;

[0133] In this embodiment, the process of obtaining the second blurred image based on the initial blurred image is similar to the processing of each pixel in the initial blurred image. For simplicity, the following example will use any pixel in the initial blurred image as the pixel to be processed.

[0134] Step S204-7-5: Obtain multiple neighboring pixels around the pixel to be processed according to the preset second rectangular window, and calculate the distance based on the coordinates of each neighboring pixel and the coordinates of the pixel to be processed to obtain the similarity between each neighboring pixel and the pixel to be processed;

[0135] Step S204-7-7: According to the preset first mapping relationship, obtain the weight value of each adjacent pixel based on the similarity of each adjacent pixel;

[0136] Step S204-7-9: Perform a weighted calculation based on the color value and weight value of each adjacent pixel to obtain a new color value for the pixel to be processed; the new color value of the pixel to be processed is the color value of the pixel corresponding to the pixel to be processed in the second portrait blur image;

[0137] Understandably, conventional Gaussian filtering methods typically calculate the weights of all pixels except the currently processed pixel. However, this method is computationally intensive and produces poor results. Therefore, this embodiment of the invention employs selective Gaussian filtering, which determines the weights of surrounding pixels based on the similarity between the currently processed pixel and its neighbors. This creates a difference between the parts of the image that are affected by the filtering and those that are not, resulting in a clear contrast between the edges of these two parts. This effectively highlights the foreground, i.e., the human figure, in the image.

[0138] In this embodiment, the pixel to be processed is used as the center point of the second rectangular window. Multiple pixels surrounding the pixel to be processed are obtained through the second rectangular window, thus obtaining multiple adjacent pixels. Then, for each adjacent pixel, the distance between the two is calculated based on the coordinates of the adjacent pixel and the coordinates of the pixel to be processed. This distance represents the similarity between the adjacent pixel and the pixel to be processed. By processing each adjacent pixel in a similar manner, the similarity between each adjacent pixel and the pixel to be processed can be obtained.

[0139] A mapping relationship can be pre-established for the Lab color space, namely, a one-to-one correspondence between multiple similarities and multiple weight values, i.e., the first mapping relationship, where higher similarities result in larger weight values. Within this first mapping relationship, the weight value corresponding to the similarity of each adjacent pixel is obtained, thus acquiring the weight value of each adjacent pixel. Then, a weighted calculation is performed based on the color value and weight value of each adjacent pixel to obtain the new color value of the pixel to be processed. This new color value of the pixel to be processed is the color value of the corresponding pixel in the second blurred portrait image.

[0140] It is understandable that the process of processing an image using selective Gaussian filtering can also be divided into two directions, horizontal and vertical, as described above, to save processing time.

[0141] Step S204-7-11: Traverse each pixel in the initial blurred portrait image to obtain the second blurred portrait image.

[0142] In this embodiment, each pixel in the initial blurred portrait image is processed in a similar manner as described above to obtain the second blurred portrait image.

[0143] Optionally, for step S206, this embodiment of the invention provides a possible implementation.

[0144] Step S206-1: Based on the color value of each pixel in the portrait detail image, obtain the coordinates of each pixel in the YUV color space in the portrait detail image;

[0145] In this embodiment, after obtaining the portrait detail image, surface blurring can be applied to make the edge transition of the portrait outline area more natural. The color value of each pixel in the portrait detail image can be converted to the YUV color space to obtain the coordinates of each pixel. In the YUV color space, Y represents luminance, and U and V represent chrominance.

[0146] Step S206-3: Take any pixel in the portrait detail image as the pixel to be determined;

[0147] In this embodiment, the processing of each pixel in the portrait detail image is similar in the process of obtaining the surface blur image based on the portrait detail image. For simplicity, the following example will use any pixel in the initial portrait blur image as the undetermined pixel.

[0148] Step S206-5: Obtain multiple neighboring pixels around the undetermined pixel according to the preset second rectangular window, and calculate the distance based on the coordinates of each neighboring pixel and the coordinates of the undetermined pixel to obtain the similarity between each neighboring pixel and the undetermined pixel;

[0149] Step S206-7: According to the preset second mapping relationship, obtain the weight value of each neighboring pixel based on the similarity of each neighboring pixel;

[0150] Step S206-9: Perform a weighted calculation based on the color value and weight value of each neighboring pixel to obtain a new color value for the undetermined pixel; the new color value of the undetermined pixel is the color value of the pixel corresponding to the undetermined pixel in the surface blur map;

[0151] In this embodiment, the undetermined pixel is used as the center point of the second rectangular window. Multiple pixels surrounding the undetermined pixel are obtained through the second rectangular window, thus obtaining multiple neighboring pixels. Then, for each neighboring pixel, the distance between the two is calculated based on the coordinates of the neighboring pixel and the undetermined pixel. This distance represents the similarity between the neighboring pixel and the undetermined pixel. By processing each neighboring pixel in a similar manner, the similarity between each neighboring pixel and the undetermined pixel can be obtained.

[0152] A mapping relationship for the YVU color space can be pre-established, namely a one-to-one correspondence between multiple similarities and multiple weight values, i.e., a second mapping relationship, where higher similarities result in larger weight values. In this second mapping relationship, the weight value corresponding to the similarity of each neighboring pixel is obtained, thus acquiring the weight value of each neighboring pixel. Then, a weighted calculation is performed based on the color value and weight value of each neighboring pixel to obtain the new color value of the pixel to be determined. This new color value of the pixel to be determined is the color value of the pixel corresponding to the pixel to be determined in the surface blur map.

[0153] It is understandable that the process of surface blurring of an image can also be calculated in two directions, horizontal and vertical, as described above, to save processing time.

[0154] Step S206-11: Traverse each pixel in the portrait detail image to obtain the surface blur map;

[0155] In this embodiment, each pixel in the portrait detail image is processed in a similar manner as described above to obtain a surface blur image.

[0156] Step S206-13: Merge the face mask image and the skin mask image to obtain a merged mask image;

[0157] Step S206-15: Calculate the beautification intensity distribution map based on the user-input beautification parameters, mask blending map, and surface blur map.

[0158] In this embodiment, the face mask image and the skin mask image are fused to obtain a mask fusion image that includes the facial feature area, the non-facial feature area, and the skin area. It can be understood that the facial feature area and the non-facial feature area are divided using different shades of color, which represent the basic beautification parameters for each area.

[0159] Then, based on the user-defined beautification parameters, the mask blending map, and the surface blur map, calculations are performed. Specifically, the product of the color values ​​of corresponding pixels in the mask blending map and the surface blur map is calculated, and this product is multiplied by the user-defined beautification parameters to obtain the beautification intensity distribution map. This calculation process can be expressed by the formula: smthAmt = smoothValue * region * kMin; where smthAmt represents the beautification intensity distribution map; smoothValue represents the user-inputted beautification parameters; region represents the mask blending map; and kMin represents the surface blur map.

[0160] Understandably, to speed up image processing, the obtained portrait detail image can be merged with the face mask image and skin mask image through channel merging. That is, each channel in a merged image is used to represent the information of each image. Then, the channel representing the portrait detail image in the merged image is surface blurred, and the two channels representing the face mask image and skin mask image in the merged image are fused. Finally, based on the beautification parameters input by the user, the beautification intensity distribution map is obtained.

[0161] Optionally, for step S208, this embodiment of the invention provides a possible implementation.

[0162] Step S208-1: Calculate the first high-frequency signal based on the original portrait image and the first portrait blur image, and then superimpose the first high-frequency signal onto the first portrait blur image after enhancement processing to obtain the first portrait enhancement image;

[0163] Step S208-3: According to the beautification intensity distribution map, the first portrait enhancement image and the second portrait blur image are mixed to obtain the second portrait enhancement image;

[0164] Step S208-5: Calculate the second high-frequency signal based on the second portrait enhancement image and the second portrait blur image, and then superimpose the second high-frequency signal onto the second portrait enhancement image after enhancement processing to obtain the portrait beautification image corresponding to the original portrait image;

[0165] In this embodiment, in order to enhance the edge details of the portrait and the background, the difference in color values ​​of corresponding pixels in the original portrait image and the first portrait blurred image can be calculated to obtain the first high-frequency signal. After the first high-frequency signal is enhanced, it is superimposed on the first portrait blurred image to obtain the first portrait enhanced image.

[0166] Then, based on the beautification intensity distribution map, the first portrait enhancement image and the second portrait blur image are blended to obtain the second portrait enhancement image. It can be understood that the color value of each pixel in the beautification intensity distribution map is between 0 and 1. That is, the color value of each pixel in the beautification intensity distribution map is used as an adjustment weight to blend the first portrait enhancement image and the second portrait blur image, thus obtaining the second portrait enhancement image.

[0167] Next, the difference in color values ​​of corresponding pixels in the second portrait enhancement image and the second portrait blur image is calculated to obtain the second high-frequency signal. The second high-frequency signal is then enhanced and superimposed on the second portrait enhancement image to further enhance edge details and texture, thus obtaining the portrait beautification image corresponding to the original portrait image.

[0168] Understandably, by processing each video frame containing a human figure in the live video stream using the methods described above, it is possible not only to improve the beautification effect of the human figure, but also to reduce the complexity of image processing, save processing time, and ensure smooth operation even on low-performance electronic devices.

[0169] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of the portrait beautification device 300 is given below. Please refer to... Figure 5 , Figure 5 This is a functional block diagram of a portrait beautification device 300 provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the portrait beautification device 300 provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The portrait beautification device 300 includes:

[0170] The detection module 310 is used to perform face detection and skin detection on the original portrait image in the video stream to obtain a face mask image and a skin mask image; the face mask image represents the facial features area and the non-facial features area of ​​the face, and the skin mask image represents the skin area;

[0171] The beautification module 330 is used to perform filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the portrait outline area; based on the face mask image, skin mask image, and portrait detail image, it obtains a beautification intensity distribution map; the beautification intensity distribution map represents the beautification degree of the facial features area, non-facial features area, skin area, and portrait outline area; based on the original portrait image and the beautification intensity distribution map, it obtains the beautified portrait image corresponding to the original portrait image.

[0172] Optionally, the beautification module 330 is also used to: reduce the size of the original portrait image to obtain a smaller portrait image; perform non-local mean filtering on the smaller portrait image to obtain a first blurred portrait image; perform mean filtering on the smaller portrait image to obtain an initial blurred portrait image; perform Gaussian filtering on the initial blurred portrait image to obtain a second blurred portrait image; and perform high-contrast processing based on the first blurred portrait image and the second blurred portrait image to obtain a portrait detail image.

[0173] Optionally, the beautification module 330 is further configured to: take any pixel in the portrait thumbnail as the target pixel; obtain multiple pixels around the target pixel according to a preset first rectangular window; obtain multiple associated pixels corresponding to the target pixel by rotating the inscribed circle of the first rectangular window by a preset angle and sampling in the first rectangular window; calculate the weight value of each associated pixel based on the color value of the target pixel and the color value of each associated pixel; calculate the average of the weight values ​​of all associated pixels to obtain the target weight value; perform a weighted calculation based on the color value of each pixel in the first rectangular window and the target weight value to obtain the first color value of the target pixel; the first color value of the target pixel is the color value of the pixel corresponding to the target pixel in the first portrait blur image; and traverse each pixel in the portrait thumbnail to obtain the first portrait blur image.

[0174] Optionally, the beautification module 330 is further configured to: take any pixel in the portrait thumbnail as the target pixel; obtain multiple pixels around the target pixel according to a preset second rectangular window; calculate the sum of the color values ​​of each row of pixels in the second rectangular window to obtain the color value corresponding to each row; add the color values ​​corresponding to each row to obtain the total color value, and calculate the average value based on the total color value and the total number of pixels in the second rectangular window to obtain the second color value of the target pixel; the second color value of the target pixel is the color value of the pixel corresponding to the target pixel in the initial portrait blur image; and traverse each pixel in the portrait thumbnail to obtain the initial portrait blur image.

[0175] Optionally, the beautification module 330 is further configured to: obtain the coordinates of each pixel in the initial portrait blur image in the Lab color space based on the color value of each pixel in the initial portrait blur image; take any pixel in the initial portrait blur image as the pixel to be processed; obtain multiple neighboring pixels around the pixel to be processed according to a preset second rectangular window, and calculate the distance based on the coordinates of each neighboring pixel and the coordinates of the pixel to be processed to obtain the similarity between each neighboring pixel and the pixel to be processed; obtain the weight value of each neighboring pixel based on the similarity of each neighboring pixel according to a preset first mapping relationship; perform a weighted calculation based on the color value and weight value of each neighboring pixel to obtain a new color value of the pixel to be processed; the new color value of the pixel to be processed is the color value of the pixel corresponding to the pixel to be processed in the second portrait blur image; and traverse each pixel in the initial portrait blur image to obtain the second portrait blur image.

[0176] Optionally, the beautification module 330 is further configured to: obtain the coordinates of each pixel in the portrait detail image in the YUV color space based on the color value of each pixel in the portrait detail image; take any pixel in the portrait detail image as a pending pixel; obtain multiple neighboring pixels around the pending pixel according to a preset second rectangular window, and calculate the distance based on the coordinates of each neighboring pixel and the coordinates of the pending pixel to obtain the similarity between each neighboring pixel and the pending pixel; obtain the weight value of each neighboring pixel based on the similarity of each neighboring pixel according to a preset second mapping relationship; perform a weighted calculation based on the color value and weight value of each neighboring pixel to obtain a new color value of the pending pixel; the new color value of the pending pixel is the color value of the pixel corresponding to the pending pixel in the surface blur image; traverse each pixel in the portrait detail image to obtain a surface blur image; fuse the face mask image and the skin mask image to obtain a mask fusion image; and calculate based on the beautification parameters input by the user, the mask fusion image, and the surface blur image to obtain a beautification intensity distribution image.

[0177] Optionally, the beautification module 330 is further configured to: calculate a first high-frequency signal based on the original portrait image and the first portrait blur image, and then enhance the first high-frequency signal and superimpose it onto the first portrait blur image to obtain a first portrait enhancement image; according to the beautification intensity distribution map, mix the first portrait enhancement image and the second portrait blur image to obtain a second portrait enhancement image; calculate a second high-frequency signal based on the second portrait enhancement image and the second portrait blur image, and then enhance the second high-frequency signal and superimpose it onto the second portrait enhancement image to obtain a portrait beautification image corresponding to the original portrait image.

[0178] This invention also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the portrait beautification method disclosed in this invention.

[0179] This invention also provides a storage medium storing a computer program, which, when executed by a processor, implements the portrait beautification method disclosed in this invention.

[0180] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0181] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0182] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0183] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A portrait beautification method, characterized in that, The portrait beautification method includes: Face detection and skin detection are performed on the original portrait image in the video stream to obtain a face mask image and a skin mask image; the face mask image represents the facial features area and the non-facial features area of ​​the face, and the skin mask image represents the skin area; Based on the original portrait image, filtering and high-contrast processing are performed to obtain a portrait detail image representing the portrait outline region; Based on the color value of each pixel in the portrait detail image, the coordinates of each pixel in the portrait detail image in the YUV color space are obtained; Take any pixel in the portrait detail image as the pixel to be determined; According to the preset second rectangular window, multiple neighboring pixels around the undetermined pixel are obtained, and the distance is calculated based on the coordinates of each neighboring pixel and the coordinates of the undetermined pixel to obtain the similarity between each neighboring pixel and the undetermined pixel; According to the preset second mapping relationship, the weight value of each neighboring pixel is obtained based on the similarity of each neighboring pixel; A weighted calculation is performed based on the color value and weight value of each of the neighboring pixels to obtain a new color value for the undetermined pixel; the new color value of the undetermined pixel is the color value of the pixel corresponding to the undetermined pixel in the surface blur map; By traversing each pixel in the portrait detail image, the surface blur map is obtained; The face mask image and the skin mask image are fused together to obtain a mask fusion image; Based on the user-input beautification parameters, the mask blending map, and the surface blur map, a beautification intensity distribution map is obtained; the beautification intensity distribution map represents the degree of beautification of the facial features area, the non-facial features area, the skin area, and the portrait contour area; Based on the original portrait image and the beautification intensity distribution map, a beautified portrait image corresponding to the original portrait image is obtained.

2. The portrait beautification method of claim 1, wherein, The step of performing filtering and high-contrast processing on the original portrait image to obtain a portrait detail image representing the portrait outline region includes: The original portrait image is reduced in size to obtain a smaller portrait image; The portrait thumbnail is subjected to nonlocal mean filtering to obtain a first blurred portrait image; The portrait thumbnail is subjected to mean filtering to obtain an initial blurred portrait image; The initial blurred image is subjected to Gaussian filtering to obtain the second blurred image. High-contrast processing is performed on the first blurred image and the second blurred image to obtain the detailed image of the portrait.

3. The portrait beautification method of claim 2, wherein, The step of performing nonlocal mean filtering on the portrait thumbnail to obtain the first blurred portrait image includes: Take any pixel in the portrait thumbnail as the target pixel; Obtain multiple pixels surrounding the target pixel according to a preset first rectangular window; By rotating the inscribed circle of the first rectangular window by a preset angle, sampling is performed within the first rectangular window to obtain multiple associated pixels corresponding to the target pixel. Based on the color value of the target pixel and the color value of each associated pixel, calculate the weight value of each associated pixel; Calculate the average of the weight values ​​of all associated pixels to obtain the target weight value; The first color value of the target pixel is obtained by weighting the color value of each pixel in the first rectangular window with the target weight value; the first color value of the target pixel is the color value of the pixel corresponding to the target pixel in the first portrait blur image; By traversing each pixel in the portrait thumbnail, the first blurred portrait image is obtained.

4. The portrait beautification method of claim 2, wherein, The step of performing mean filtering on the portrait thumbnail to obtain an initial blurred portrait image includes: Take any pixel in the portrait thumbnail as the target pixel; Obtain multiple pixels surrounding the target pixel using a preset second rectangular window; Calculate the sum of the color values ​​of each row of pixels in the second rectangular window to obtain the color value corresponding to each row; The color values ​​corresponding to each row are added together to obtain a total color value, and the average value is calculated based on the total color value and the total number of pixels in the second rectangular window to obtain the second color value of the target pixel; the second color value of the target pixel is the color value of the pixel corresponding to the target pixel in the initial portrait blur image; By traversing each pixel in the portrait thumbnail, the initial portrait blur image is obtained.

5. The portrait beautification method of claim 2, wherein, The step of performing Gaussian filtering on the initial blurred portrait image to obtain the second blurred portrait image includes: Based on the color value of each pixel in the initial blurred portrait image, the coordinates of each pixel in the initial blurred portrait image in the Lab color space are obtained; Take any pixel in the initial blurred portrait image as the pixel to be processed; According to the preset second rectangular window, multiple neighboring pixels around the pixel to be processed are obtained, and the distance is calculated based on the coordinates of each neighboring pixel and the coordinates of the pixel to be processed to obtain the similarity between each neighboring pixel and the pixel to be processed. According to a preset first mapping relationship, the weight value of each adjacent pixel is obtained based on the similarity of each adjacent pixel. A weighted calculation is performed based on the color value and weight value of each of the adjacent pixels to obtain a new color value for the pixel to be processed; the new color value of the pixel to be processed is the color value of the pixel corresponding to the pixel to be processed in the second portrait blur image; By traversing each pixel in the initial blurred portrait image, the second blurred portrait image is obtained.

6. The portrait beautification method of claim 2, wherein, The step of obtaining the beautified portrait image corresponding to the original portrait image based on the original portrait image and the beautification intensity distribution map includes: A first high-frequency signal is calculated based on the original portrait image and the first blurred portrait image, and the first high-frequency signal is enhanced and then superimposed on the first blurred portrait image to obtain a first enhanced portrait image. According to the beautification intensity distribution map, the first portrait enhancement map and the second portrait blur map are mixed to obtain the second portrait enhancement map; A second high-frequency signal is calculated based on the second enhanced portrait image and the second blurred portrait image. The second high-frequency signal is then enhanced and superimposed onto the second enhanced portrait image to obtain a beautified portrait image corresponding to the original portrait image.

7. A portrait beautifying device, characterized by, The portrait beautification device includes: The detection module is used to perform face detection and skin detection on the original portrait image in the video stream to obtain a face mask image and a skin mask image; the face mask image represents the facial features area and the non-facial features area of ​​the face, and the skin mask image represents the skin area; The beauty module is used for: Based on the original portrait image, filtering and high-contrast processing are performed to obtain a portrait detail image representing the portrait outline region; Based on the color value of each pixel in the portrait detail image, the coordinates of each pixel in the portrait detail image in the YUV color space are obtained; Take any pixel in the portrait detail image as the pixel to be determined; According to the preset second rectangular window, multiple neighboring pixels around the undetermined pixel are obtained, and the distance is calculated based on the coordinates of each neighboring pixel and the coordinates of the undetermined pixel to obtain the similarity between each neighboring pixel and the undetermined pixel; According to the preset second mapping relationship, the weight value of each neighboring pixel is obtained based on the similarity of each neighboring pixel; A weighted calculation is performed based on the color value and weight value of each of the neighboring pixels to obtain a new color value for the undetermined pixel; the new color value of the undetermined pixel is the color value of the pixel corresponding to the undetermined pixel in the surface blur map; By traversing each pixel in the portrait detail image, the surface blur map is obtained; The face mask image and the skin mask image are fused together to obtain a mask fusion image; Based on the user-input beautification parameters, the mask blending map, and the surface blur map, a beautification intensity distribution map is obtained; the beautification intensity distribution map represents the degree of beautification of the facial features area, the non-facial features area, the skin area, and the portrait contour area; Based on the original portrait image and the beautification intensity distribution map, a beautified portrait image corresponding to the original portrait image is obtained.

8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a computer program, and when the processor executes the computer program, it implements the portrait beautification method according to any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the portrait beautification method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image processing method and device, electronic equipment and storage medium

    CN112184540A

  • Image processing method and device

    CN112488965A