Image processing method, device, equipment and storage medium

By acquiring and adding ambient light information, the target color is mixed with the target area in the original image, and the problem of poor authenticity of AR shooting and editing effects in the prior art is solved, and a more natural and realistic image effect is achieved.

CN113298888BActive Publication Date: 2025-02-28ALIBABA GROUP HOLDING LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010936809.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-08
Publication Date
2025-02-28
Estimated Expiration
2040-09-08

AI Technical Summary

Technical Problem

In the prior art, the authenticity of augmented reality (AR) shooting effects and AR photo editing effects is poor, mainly due to simple mixing of colors.

Method used

By obtaining the ambient light information of the original image, the target color is mixed with the target area in the original image, and the ambient light information is added to the target area after the background color is mixed to enhance the realism of the image.

Benefits of technology

By combining the information of the surrounding environment and adding it to the image, the authenticity of AR shooting and photo editing effects is significantly improved, making the image more natural and realistic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide an image processing method, apparatus, device and storage medium, which solve the problem of poor authenticity of AR shooting effects and AR photo editing effects in the prior art. The method includes: obtaining ambient light information of the original image; mixing the target color with the target area in the original image; and adding the ambient light information to the target area after the background color mixing. The ambient light information is calculated in combination with the information of the surrounding environment, so the use of this ambient light information will add a natural ambient light effect to the background color mixed area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image processing method and device, an electronic device and a storage medium. Background Art

[0002] With the rapid development of mobile communication technology, electronic devices, led by smartphones, have become indispensable tools in all aspects of people's lives. The functions of various applications (APPs) of electronic devices have gradually improved. They are no longer just for communication, but more for providing users with various intelligent services, bringing great convenience to users' work and life.

[0003] As one of the core functions of electronic devices, the shooting and image processing functions have gradually developed, making the application of augmented reality (AR) functions in shooting and image processing more and more extensive. However, in the prior art, the realization of AR effects is usually a simple mixing of colors, such as mixing the color of a virtual object with the color of a real object, resulting in poor authenticity of existing AR shooting and photo editing effects. Summary of the invention

[0004] The embodiment of the present application provides an image processing method to solve the problem of poor authenticity of AR shooting effects and AR photo editing effects in the prior art.

[0005] Correspondingly, an embodiment of the present application also provides an image processing device, an electronic device and a storage medium to ensure the implementation and application of the above method.

[0006] In order to solve the above problems, an embodiment of the present application discloses an image processing method, which includes:

[0007] Get the ambient light information of the original image;

[0008] Mixing the target color with the target area in the original image;

[0009] The ambient light information is added to the target area after the background color is mixed.

[0010] The present application also discloses an image generation method, which includes:

[0011] Acquire the original image including the target object in real time;

[0012] Acquire ambient light information of the original image;

[0013] Mixing the target color with the base color of the target area of ​​the target object;

[0014] The ambient light information is added to the target area after the background color is mixed to obtain a target image.

[0015] The present application also discloses an image processing method, which includes:

[0016] receiving an input operation for performing image processing on an original image;

[0017] In response to the input operation, acquiring ambient light information of the original image;

[0018] Mixing the target color with the target area in the original image;

[0019] The ambient light information is added to the target area after the background color is mixed.

[0020] The present application also discloses an image processing device, which includes:

[0021] An ambient light acquisition module is used to acquire ambient light information of the original image;

[0022] A background color mixing module, used for mixing the target color with the background color of the target area in the original image;

[0023] The ambient light adding module is used to add the ambient light information into the target area after the background color is mixed.

[0024] The present application also discloses an image generating device, which includes:

[0025] A shooting module, used for acquiring an original image including a target object in real time;

[0026] A first acquisition module, used to acquire the ambient light information of the original image;

[0027] A first mixing module, used for mixing a target color with a base color of a target area of ​​the target object;

[0028] The first adding module is used to add the ambient light information to the target area after the background color is mixed to obtain a target image.

[0029] The present application also discloses an image processing device, which includes:

[0030] A receiving module, used for receiving an input operation for performing image processing on an original image;

[0031] A response module, used for acquiring ambient light information of the original image in response to the input operation;

[0032] A second mixing module, used for mixing the target color with the base color of the target area in the original image;

[0033] The second adding module is used to add the ambient light information into the target area after the background color is mixed.

[0034] An embodiment of the present application further discloses an electronic device, including: a processor; and a memory, on which executable code is stored. When the executable code is executed, the processor executes one or more methods described in the embodiments of the present application.

[0035] The embodiments of the present application also disclose one or more machine-readable storage media on which executable codes are stored. When the executable codes are executed, the processor executes one or more methods described in the embodiments of the present application.

[0036] Compared with the prior art, the embodiments of the present application have the following advantages:

[0037] In the embodiment of the present application, the ambient light information of the original image is obtained; the target color is mixed with the target area in the original image; and finally the ambient light information is added to the target area after the background color is mixed. The ambient light information is calculated in combination with the information of the surrounding environment, so the use of this ambient light information will add a natural ambient light effect to the background color mixed area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a schematic diagram of an image processing scenario in an embodiment of the present application;

[0039] Figure 2 is another schematic diagram of an image processing scenario in an embodiment of the present application;

[0040] Figure 3 is a flowchart of steps of an embodiment of an image processing method of the present application;

[0041] Figure 4 is a flowchart of steps of an embodiment of an image generation method of the present application;

[0042] Figure 5 is a flowchart of another image processing method embodiment of the present application;

[0043] Figure 6 is a structural block diagram of an embodiment of an image processing device of the present application;

[0044] Figure 7 is a structural block diagram of an optional embodiment of an image generating device of the present application;

[0045] Figure 8 is a structural block diagram of an embodiment of an image processing device of the present application;

[0046] Fig. 9 It is a schematic diagram of the structure of a device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0048] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein.

[0049] The image processing method provided in the embodiments of the present application can be applied to the field of image processing or shooting, such as beauty makeup and photo editing in the image processing field; shooting such as beauty shooting and AR shooting, etc., generates highlight textures through ambient light information in the original image, and finally adds the highlight textures to the processed image to enhance the realism of the image. AR shooting, for example, adds virtual objects to the original image taken.

[0050] like Figure 1 As shown, Figure 1 A schematic diagram of an application scenario of an embodiment of the present application is shown. Figure 1 In this example, we take the image processing of the user's nail area and adding nail color as an example. Figure 1 Among them, P1 is the original image; P2 is an image diagram of the target area including the user's nail part extracted from the original image; P4 is an image diagram of the target color, that is, the color selected by the user to be added to the nails; P5 is an image diagram of the background color mixed area obtained by mixing P2 and P4; P6 is an image diagram of the ambient light information of the target area; P7 is the final target image, that is, the nail image with color added to the user's nails and ambient light information added.

[0051] The image processing method provided in the embodiment of the present application can be applied to shooting and image processing scenes. For example, shooting provides beauty functions while shooting, such as adding eye shadow to the eyes, adding lipstick to the lips, adding blush to the cheeks, adjusting the overall facial skin color, etc.; for example, in the scene of selling beauty products, the above-mentioned online makeup trial function can be provided to help users choose products according to the makeup trial effect; or hair dye products can help users choose hair dye products according to the hair color makeup trial effect of hair dye products; in addition to beauty products, it can also be physical products, such as glasses, hats, masks, etc., and a trial wearing function can be provided to help users choose products; shooting also includes AR shooting; image processing, such as photo editing, also performs the above-mentioned beauty operations. In addition to the face, it can also be used to adjust the skin color of other parts.

[0052] The image processing method provided in the embodiments of the present application can be applied to electronic devices, including various handheld devices, vehicle-mounted devices, wearable devices, computing devices or other processing devices connected to a wireless modem, as well as various forms of mobile stations (Mobile Station, MS), terminal devices (Terminal Device), etc.

[0053] Combination Figure 1 The image processing method provided in the embodiment of the present application comprises the following steps:

[0054] Step 101, obtaining ambient light information of the original image.

[0055] The original image (such as Figure 1 The original image (as shown in P1) is the image before processing, and the original image may be an image stored in the electronic device, or an image captured by the electronic device. For example, in a shooting scenario, the electronic device captures the original image when receiving a shooting instruction; in an image processing scenario, the electronic device performs image processing on the stored original image. In a video shooting scenario or a video processing scenario, the original image is an image frame in the video.

[0056] The ambient light information can be the overall ambient light information in the original image or the ambient light information of the target area; the target area (such as Figure 1 The target area is the area where image processing is performed. For example, if the user selects a specific beauty operation, the target area corresponding to the beauty operation is determined according to the beauty operation selected by the user. For example, if the beauty operation is manicure, the target area is the area where each fingernail of the user is located. If the beauty operation is facial whitening, the target area is the area where the user's face is located. For AR shooting operation, the target area is the area corresponding to the virtual object.

[0057] Step 102: Mix the target color with the base color of the target area in the original image.

[0058] The target color is the color to be added to the target area. For example, the target color ( Figure 1 The filter area, the target color and the target area are mixed with the background color to obtain the background color mixed area, which is the target area after the background color mixing, and the background color mixed area is combined with the target area. Figure 1 , P2 and P4 are mixed to obtain P5, where P5 is an image including a background color mixing area, and the background color mixing area is the nail area after the background color mixing.

[0059] It should be noted that the target color can be a single color, such as adding color to nails; it can also be multiple colors, such as adding virtual objects in AR shooting, and different pixels can correspond to different colors.

[0060] Step 103: Add the ambient light information to the target area after the background color is mixed.

[0061] After obtaining an image including the target area after background color mixing, the ambient light information is added to the target area after background color mixing to obtain a target image. The target image can be an image obtained in an image shooting scene, or a video frame shot in a video shooting scene. The ambient light information includes a highlight texture, which is generated based on the grayscale information (i.e., brightness information) of the original image, and the brightness information is the initial brightness information of the image; and the brightness information of the image is obtained based on the brightness of the environment, so the highlight obtained by superimposing such a highlight texture will change with the change of the ambient brightness. By adding a highlight texture to the target area after background color mixing, a natural ambient light effect is obtained, thereby making the final target image more realistic.

[0062] As a first example, still taking the case of image processing of the user's nail area and adding nail color as an example, the user uses an electronic device to shoot the nail area to obtain an original image, and selects a target color to be added to the nail; the electronic device obtains a target area including the nail area, generates ambient light information of the area according to the grayscale information of the target area; and mixes the target color with the target area in the original image. The ambient light information is generated according to the ambient brightness in the original image, changes with the change of the ambient brightness, and finally adds the ambient light information to the target area after the background color mixing to obtain the target image.

[0063] Specific, combined Figure 1 , the user selects the nail art function in the electronic device and selects the target color. The target color is as follows Figure 1As shown in P4; the electronic device captures the original image of the target area including the user's nails, such as Figure 1 As shown in P1; then the image including the target area is identified and segmented from the original image, as shown in Figure 1 As shown in P2 in FIG. 1 , the ambient light information of the target area is generated according to the grayscale information of the target area, and the ambient light information carries the ambient light information of the nail area, such as Figure 1 As shown in P6; the filter area, the target color selected by the user and the target area are mixed with the background color to obtain the target area after the background color is mixed, as shown in Figure 1 As shown in P5, the highlight texture is finally added to the target area after the base color is mixed, and the ambient light information in the original image is added to the target image, such as Figure 1 As shown in P7, a target image with a strong sense of reality is obtained. In this target image, the nail area not only adds the target color, but also adds a highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the nail area, making the final target image with a strong sense of reality.

[0064] As a second example, taking the process of adding lipstick to the lips of the user as an example, the user uses an electronic device to shoot the lip area to obtain the original image, and selects the target color to be added to the lips; the electronic device obtains the target area including the lip area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is generated according to the ambient brightness in the original image, and changes with the change of the ambient brightness. Finally, the ambient light information is added to the target area after the background color is mixed to obtain the final target image; in this target image, the lip area is not only added with the target color, but also with the highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the lip area, so that the target image has a strong sense of reality. In the above example, in addition to nails, it is also used to add eye shadow to the eyes, add lipstick to the lips, add blush to the cheeks, and adjust the overall facial skin color. The specific process of the embodiment of this application will not be repeated here.

[0065] As a third example, taking AR shooting processing as an example, the user shoots the facial area through an electronic device to obtain the original image, and selects the target color of the target virtual object added on the face (the colors corresponding to different pixels of the target virtual object may be different); the electronic device obtains the target area including the facial area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is finally added to the target area after the background color is mixed to obtain the target image; in this target image, the facial area is not only added with the target virtual object, but also with the highlight texture that changes with the ambient light, and the ambient light information in the original image is retained in the facial area.

[0066] In an embodiment of the present application, the ambient light information of the original image is obtained; the target color is mixed with the target area in the original image to form a background color; and finally, the ambient light information is added to the target area after the background color is mixed. The ambient light information is calculated in combination with the information of the surrounding environment, so the addition of this ambient light information will add a natural ambient light effect to the target area after the background color is mixed; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the final target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong. The embodiment of the present application solves the problem of poor authenticity of AR shooting effects and AR photo editing effects in the prior art.

[0067] In an optional embodiment, the step of generating the highlight texture of the target area includes steps 1021 to 1024.

[0068] Specifically, in step 1021, grayscale information of a target area of ​​the original image is obtained.

[0069] Grayscale information includes the grayscale value of each pixel in the target area. Grayscale uses black tones to represent objects, that is, black is used as the base color and different saturation black is used to display images. Each grayscale object has a brightness value from 0% (white) to 100% (black), that is, a grayscale value.

[0070] Optionally, in the process of acquiring the grayscale information of the target area of ​​the original image, the grayscale value corresponding to each pixel in the target area in the original image can be determined according to the RGB value of the pixel to obtain the grayscale information of all pixels in the target area.

[0071] In a grayscale image, the grayscale value is equal to the brightness value. Therefore, in order to obtain brightness information, the image needs to be grayscaled to obtain a grayscale image of the original image. For example, the following first formula is used to grayscale the original image to obtain the grayscale value Gray to determine the brightness.

[0072] The first formula is:

[0073] Gray=R*0.299+G*0.587+B*0.114;

[0074] Among them, Gray is the gray value of each pixel, R, G, and B represent the RGB parameters of the color of the pixel respectively. It can be understood that in the first formula, the coefficients of R, G, and B can be adjusted.

[0075] Step 1022: Determine brightness reference information of the target area according to the grayscale information.

[0076] In a grayscale image, the grayscale value is equal to the brightness value; after obtaining the grayscale value of each pixel, a grayscale histogram (i.e., brightness histogram) can be generated based on the grayscale information. The brightness histogram is a function of the brightness level distribution. It represents the number of pixels with a certain brightness level in the image and is a statistic of the brightness level distribution in the image. The brightness histogram is a statistical calculation of the frequency of occurrence of all pixels in a digital image according to the size of the brightness value. After obtaining the brightness histogram, the brightness reference information of the target area is calculated based on the brightness histogram.

[0077] The brightness reference information includes a brightness interval value, a brightness suppression value, and a maximum brightness value.

[0078] Specifically, the brightness interval value is the difference between the first brightness value and the second brightness value;

[0079] The first brightness value is a brightness of the pixels in the target area sorted from high to low, and the ranking is a first percentage;

[0080] The second brightness value is the brightness ranked as the second percentage; the first brightness value is higher than the second brightness value. For example, in the brightness histogram, the brightness of the pixels is sorted from high to low, and the brightness value ranked 1% is used as the first brightness value high_light, and 5% is used as the second brightness value low_light, then the brightness interval value light_range = high_light-low_light.

[0081] The brightness suppression value lightSuppress is the ratio between the maximum brightness value light_max and a preset brightness threshold. For example, for an 8-bit grayscale image, the brightness threshold is 255, then lightSuppress=light_max / 255.0.

[0082] Step 1023: Determine the highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information.

[0083] Highlight refers to when a light source shines on an object and then reflects into a person's eyes. Usually, the brightest point on an object is the highlight, which is the part of the object that directly reflects the light source. The highlight value of each pixel is determined based on the brightness interval value, the brightness suppression value, the maximum brightness value, and the grayscale value of each pixel. Specifically, in an optional embodiment, the highlight value of each pixel is determined based on the brightness reference information and the grayscale value of each pixel in the grayscale information, including:

[0084] The brightness processing weight of each pixel is determined according to the brightness interval value, the maximum brightness value and the grayscale value of each pixel in the grayscale information; the brightness processing weight gloss_weight is used to determine the weight of each pixel when multiplying the brightness interval value.

[0085] The highlight value of each pixel is determined according to the grayscale value, the brightness processing weight and the brightness suppression value; wherein the highlight value is the continuous product of the grayscale value, the square of the brightness processing weight and the brightness interval value, for example, as shown in the following second formula:

[0086] Second formula:

[0087] gloss=Gray*gloss_weight*gloss_weight*lightSuppress;

[0088] Among them, gloss represents the highlight value of the pixel, gloss_weight represents the brightness processing weight, and lightSuppress represents the brightness suppression value of the pixel.

[0089] After obtaining the highlight value of each pixel, the highlight texture of the target area is generated according to the highlight value of each pixel and the arrangement order of the pixels. In the process of calculating the highlight value, no additional algorithm is required for illumination estimation and no three-dimensional rendering is involved, so fast calculation can be achieved.

[0090] In an optional embodiment, determining the brightness processing weight of each pixel point according to the brightness interval value, the maximum brightness value, and the grayscale value of each pixel point in the grayscale information includes:

[0091] If the gray value of the pixel is greater than the second brightness value, the brightness processing weight of the pixel is the minimum value between the first ratio and the first preset weight threshold; the first ratio is the ratio of the first difference and the brightness interval value, and the first difference is the difference between the gray value and the second brightness value;

[0092] That is, if Gray>low_light,

[0093] Then gloss_weight=min{(Gray-low_light) / light_range, X};

[0094] Gray represents the gray value of the pixel, low_light represents the second brightness value, light_range represents the brightness suppression value, and X represents the first preset weight threshold, for example, 1.

[0095] If the grayscale value of the pixel point is less than or equal to the second brightness value, the brightness processing weight of the pixel point is a second preset weight threshold.

[0096] If Gray≤low_light,

[0097] Then gloss_weight=Y; Y represents the second preset weight threshold, for example, 0.

[0098] Step 1024: Generate a highlight texture of the target area according to the highlight value of each pixel; the highlight texture is the ambient light information of the original image.

[0099] Generate the highlight texture of the target area based on the highlight value; specifically, the highlight texture includes the texture of the highlight; highlight refers to the brightest point in the tone of the picture (tone refers to the black and white levels of different brightness of the picture), which represents the part of the object that directly reflects the light source. By saving the highlight to the texture, the ambient light information received by the object is saved. In the process of calculating the highlight value, no additional algorithm is required for lighting estimation and no three-dimensional rendering is involved, which can achieve fast calculation; the highlight texture of the target area is calculated in combination with the information of the surrounding environment, and this highlight texture is used to add a natural ambient light effect to the target area.

[0100] In an optional embodiment, the step of mixing the target color with the background color of the target area in the original image includes:

[0101] The target area in the original image is filtered to obtain a filtered area; the filtering is used to smooth the edge of the target area, and the edge of the target area is smoothed by changing the grayscale value of the pixel points in the edge area.

[0102] The filter area, the target color and the target area are mixed with the background color to obtain the target area after the background color mixing.

[0103] As a fourth example, combining Figure 2 , filter area (such as Figure 2 (as shown in P3 in the figure) is obtained by filtering the target area; optionally, the filtering method can be Gaussian filtering; Gaussian filtering is a linear smoothing filter used to eliminate Gaussian noise; in the field of digital images, the source of Gaussian noise mainly appears during image acquisition, due to sensor noise caused by poor lighting and / or high temperature. Specifically, Gaussian filtering is the process of weighted averaging the entire image. For each pixel, the grayscale value is obtained by weighted averaging itself and other pixel values ​​in the neighborhood. By performing Gaussian filtering on the target area to eliminate the Gaussian noise therein, an enhanced filtered area is obtained.

[0104] Combination Figure 2, the user selects the nail art function in the electronic device and selects the target color. The target color is as follows Figure 2 As shown in P4; the electronic device captures the original image of the target area including the user's nails, such as Figure 2 As shown in P1; then the image including the target area is identified and segmented from the original image, as shown in Figure 2 As shown in P2 in the figure, the highlight texture of the target area is generated according to the grayscale information of the target area. The highlight texture carries the ambient light information of the nail area, such as Figure 2 As shown in P6; and filtering the noise of the target area to obtain the filter area, as shown in Figure 2 As shown in P3 in FIG. 1 , the filter area, the target color selected by the user and the target area are mixed with the background color to obtain the target area after the background color mixing, as shown in FIG. Figure 2 As shown in P5, the highlight texture is finally added to the target area after the base color is mixed, and the ambient light information in the original image is added to the target image, such as Figure 2 As shown in P7, a target image with a strong sense of reality is obtained. In this target image, the nail area not only adds the target color, but also adds a highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the nail area, making the final target image with a strong sense of reality.

[0105] Combination Figure 2 Still taking the example of adding color processing to nails, the electronic device obtains a pre-stored nail image or a temporarily taken nail image, processes the nail image, obtains a target area including the nail area, generates a highlight texture of the area according to the grayscale information of the target area, and filters out noise from the target area to obtain a filtered area.

[0106] In an optional embodiment, filtering the target area in the original image to obtain the filtered area includes:

[0107] Step 1011, performing image segmentation on the original image to obtain the target area;

[0108] Step 1012, obtaining segmentation confidence parameters of the target area;

[0109] Step 1013: Perform Gaussian filtering on the segmentation confidence parameter to obtain a filtering area.

[0110] Target area (such as Figure 1The target area is the area where image processing is performed. For example, if the user selects a specific beauty operation, the target area corresponding to the beauty operation is determined according to the beauty operation selected by the user. For example, if the beauty operation is manicure, the target area is the area where each fingernail of the user is located. For AR shooting operation, the target area is the area corresponding to the virtual object.

[0111] After determining the target area, obtain the segmentation confidence parameter of the target area; confidence is reliability, and the segmentation confidence parameter represents the probability of correct identification of the target area; Gaussian filtering is performed on the segmentation confidence parameter to obtain a filtered area, and Gaussian filtering is a linear smoothing filter used to eliminate Gaussian noise; in the field of digital images, the source of Gaussian noise mainly appears during image acquisition, due to sensor noise caused by poor lighting and / or high temperature, and the Gaussian noise therein is eliminated by Gaussian filtering the target area to obtain an enhanced filtered area.

[0112] In an optional embodiment, the step of mixing the filter area, the target color and the target area with a background color to obtain the target area after the background color mixing includes:

[0113] Step 1025, for each pixel, the color parameter value of the target area, the color parameter value of the target color and the color parameter value of the filter area are multiplied to obtain a first mixing parameter; for example, for a certain pixel in the target area, the first mixing parameter = (srcImg*dstColor)*maskBlur, srcImg represents the color parameter value of the pixel in the target area, dstColor represents the color parameter value of the pixel in the target color, and maskBlur represents the color parameter value of the pixel in the filter area. It can be understood that the color parameters mentioned in the embodiments of the present application are all RGB parameters.

[0114] Step 1026, multiply the difference between the first preset value and the color parameter value of the filtering area by the color parameter value of the target area to obtain a second mixing parameter; for example, the second mixing parameter = (srcImg) * (M-maskBlur), the first preset value is M, for example, 1.

[0115] Step 1027, adding the first mixing parameter to the second mixing parameter to obtain the color parameter of the pixel; as shown in the following third formula,

[0116] baseImg=(srcImg*dstColor)*maskBlur+(srcImg)*(1-maskBlur)

[0117] Among them, baseImg represents the color parameter of the pixel.

[0118] Step 1028, obtaining the target area after background color mixing according to the color parameters of each pixel.

[0119] After the color parameters of each pixel are obtained, the target area after the background color is mixed is obtained by arranging each pixel according to its position in the target area.

[0120] In an optional embodiment, adding the ambient light information to the target area after the background color is mixed includes:

[0121] Determine a target color parameter of a pixel point in the target area after the background color is mixed; the target color parameter is a difference between the second preset value and the target value;

[0122] The target value is the product of the background color parameter and the highlight parameter.

[0123] The base color parameter is a difference value obtained by subtracting the color parameter of the pixel in the target area after the base color is mixed from the third preset value, and the base color parameter is N-baseImg, where N represents the third preset value, such as 1;

[0124] The highlight parameter is a difference obtained by subtracting the highlight value of the pixel from the fourth preset value. The highlight parameter is denoted as P-gloss, where P is the fourth preset value, such as 1.

[0125] As shown in the fourth formula below,

[0126] glossImg=Q-(N-baseImg)*(P-gloss)

[0127] Among them, glossImg represents the target color parameter; Q represents the second preset value, for example, 1.

[0128] In an optional embodiment, after adding the ambient light information to the target area after background color mixing, the method includes:

[0129] The highlight area and the target area are mixed according to the target weight to obtain a target image;

[0130] The highlight area is the target area after the background color is mixed with the ambient light information.

[0131] The target mixing weight is the mixing weight when the highlight adding area is mixed with the target area. Setting different mixing weights will visually show different concentrations of added ambient light. For example, if the user wants to add more ambient light, a higher mixing weight can be selected. Optionally, the following fifth formula can be used to mix the highlight adding area with the target area.

[0132] The fifth formula:

[0133] outputImg=glossImg*intensity+srcImg*(1-intensity);

[0134] Among them, glossImg represents the target color parameter of the pixel in the highlight adding area; intensity represents the mixing weight, and srcImg represents the color parameter of the pixel in the target area.

[0135] As a fifth example, taking adding color to nails as an example, the image processing method provided in the embodiment of the present application mainly includes the following steps:

[0136] Step (1): obtain an original image srcImg taken by a camera of an electronic device, use a deep learning segmentation algorithm to obtain a target area where the nail area is located, and obtain a segmentation confidence parameter mask of the target area;

[0137] Step (2): Perform Gaussian filtering on the mask in step (1) to obtain the filter area Mask Blur;

[0138] Step (3): Grayscale the original image to obtain a grayscale image srcGray. The grayscale formula is as follows:

[0139] Gray=R*0.299+G*0.587+B*0.114;

[0140] Among them, Gray represents the gray value of the pixel (for grayscale images, grayscale can also be called brightness), and R, G, and B represent the values ​​of the red, green, and blue channels, respectively.

[0141] Step (4): Obtain the target grayscale image nailGray of the nail area according to the maskBlur obtained in step (2) and the srcGray obtained in step (3);

[0142] Step (5): According to nailGray in step (4), calculate the brightness histogram nailHistogram of the nail area;

[0143] Step (6): Calculate the brightness values corresponding to the top 1%, 3%, and 5% in terms of brightness ranking based on the brightness histogram in step (5) or the target grayscale image nailGray in step (4).

[0144] They are respectively denoted as the first brightness value high_light, the middle brightness value mid_light, and the second brightness value low_light. At the same time, calculate the maximum brightness value light_max of the nail area;

[0145] Step (7): Calculate the brightness interval value light_range = high_light - low_light based on the values obtained in step (6);

[0146] Step (8): Calculate the brightness suppression value lightSuppress = light_max / 255.0 according to step (6);

[0147] Step (9): Calculate the nail brightness processing weight nail_gloss_weight based on the target grayscale image nailGray in step (4), the values calculated in steps (6) and (7). The formula is as follows:

[0148] If srcGray > low_light, then nail_gloss_weight = min((srcGray - low_light) / light_range, 1.0);

[0149] If srcGray < low_light, then nail_gloss_weight = 0;

[0150] Step (10): Calculate the highlight value nail_gloss of the nail based on the grayscale image nailGray in step (4), the brightness processing weight nail_gloss_weight obtained in step (9), and the brightness suppression value lightSuppress obtained in step (8). The calculation formula is as follows:

[0151] nail_gloss = nailGray * nail_gloss_weight * nail_gloss_weight * lightSuppress;

[0152] Step (11): Generate the highlight texture nail_gloss_tex based on the nail_gloss obtained in step (10);

[0153] Step (12): Use srcImg from step (1), maskBlur obtained from step (2), and target color dstColor to perform background color mixing to obtain the target area baseImg after background color mixing;

[0154] The mixing formula is as follows:

[0155] baseImg=(srcImg*dstColor)*maskBlur+(srcImg)*(1-maskBlur)

[0156] Step (13): Use the highlight texture obtained in step (11) to superimpose the highlight on baseImg in step (12) to obtain the highlight added area glossImg. The formula is as follows:

[0157] glossImg=1-(1-baseImg)*(1-nail_gloss)rgb

[0158] Step (14): Use the highlight result of step (13) and the target weight intensity (specified mixed concentration weight) to mix and obtain the final result target image outputImg, the formula is as follows:

[0159] outputImg=glossImg*intensity+srcImg*(1-intensity)

[0160] In the target image outputImg, the nail area not only adds the target color, but also adds a highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the nail area, making the target image more realistic.

[0161] In the embodiment of the present application, the ambient light information of the original image is obtained; the target color is mixed with the target area in the original image; and finally the ambient light information is added to the target area after the background color is mixed. The ambient light information is calculated in combination with the information of the surrounding environment, so the addition of this ambient light information will add a natural ambient light effect to the target area after the background color is mixed; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0162] Reference Figure 3, shows a flowchart of the steps of an image processing method embodiment of the present application, the method can be applied to the field of image processing or shooting, image processing fields such as beauty makeup and photo editing; shooting such as beauty shooting, AR shooting, etc., generating highlight textures through ambient light information in the original image, and finally adding the highlight textures to the processed image to enhance the realism of the image. AR shooting, for example, adds virtual objects to the original image taken.

[0163] like Figure 3 As shown, the method comprises the following steps:

[0164] Step 301: Acquire ambient light information of the original image.

[0165] The original image (such as Figure 1 The original image (as shown in P1) is the image before processing, and the original image may be an image stored in the electronic device, or an image captured by the electronic device. For example, in a shooting scenario, the electronic device captures the original image when receiving a shooting instruction; in an image processing scenario, the electronic device performs image processing on the stored original image. In a video shooting scenario or a video processing scenario, the original image is an image frame in the video.

[0166] The ambient light information can be the overall ambient light information in the original image or the ambient light information of the target area; the target area (such as Figure 1 The target area is the area where image processing is performed. For example, if the user selects a specific beauty operation, the target area corresponding to the beauty operation is determined according to the beauty operation selected by the user. For example, if the beauty operation is manicure, the target area is the area where each fingernail of the user is located. If the beauty operation is facial whitening, the target area is the area where the user's face is located. For AR shooting operation, the target area is the area corresponding to the virtual object.

[0167] Step 302: Mix the target color with the base color of the target area in the original image.

[0168] The target color is the color to be added to the target area. For example, the target color ( Figure 1 The filter area, the target color and the target area are mixed with the background color to obtain the background color mixed area, which is the target area after the background color mixing, and the background color mixed area is combined with the target area. Figure 1 , P2 and P4 are mixed to obtain P5, where P5 is an image including a background color mixing area, and the background color mixing area is the nail area after the background color mixing.

[0169] It should be noted that the target color can be a single color, such as adding color to nails; it can also be multiple colors, such as adding virtual objects in AR shooting, and different pixels can correspond to different colors.

[0170] Step 303: Add the ambient light information to the target area after the background color is mixed.

[0171] After obtaining an image including the target area after background color mixing, the ambient light information is added to the target area after background color mixing to obtain a target image. The target image can be an image obtained in an image shooting scene, or a video frame shot in a video shooting scene. The ambient light information includes a highlight texture, which is generated based on the grayscale information (i.e., brightness information) of the original image, and the brightness information is the initial brightness information of the image; and the brightness information of the image is obtained based on the brightness of the environment, so the highlight obtained by superimposing such a highlight texture will change with the change of the ambient brightness. By adding a highlight texture to the target area after background color mixing, a natural ambient light effect is obtained, thereby making the final target image more realistic.

[0172] As a first example, still taking the image processing of the user's nail area and adding nail color as an example, the user uses an electronic device to shoot the nail area to obtain an original image, and selects a target color to be added to the nail; the electronic device obtains a target area including the nail area, generates ambient light information of the area according to the grayscale information of the target area; the target color is mixed with the background color of the target area in the original image. The ambient light information is generated according to the ambient brightness in the original image, changes with the change of the ambient brightness, and finally the ambient light information is added to the target area after the background color is mixed to obtain the target image.

[0173] Specific, combined Figure 1 , the user selects the nail art function in the electronic device and selects the target color. The target color is as follows Figure 1 As shown in P4; the electronic device captures the original image of the target area including the user's nails, such as Figure 1 As shown in P1; then the image including the target area is identified and segmented from the original image, as shown in Figure 1 As shown in P2 in FIG. 1 , the ambient light information of the target area is generated according to the grayscale information of the target area, and the ambient light information carries the ambient light information of the nail area, such as Figure 1 As shown in P6; the filter area, the target color selected by the user and the target area are mixed with the background color to obtain the target area after the background color is mixed, as shown in Figure 1 As shown in P5, the highlight texture is finally added to the target area after the base color is mixed, and the ambient light information in the original image is added to the target image, such as Figure 1As shown in P7, a target image with a strong sense of reality is obtained. In this target image, the nail area not only adds the target color, but also adds a highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the nail area, making the final target image with a strong sense of reality.

[0174] As a second example, taking the process of adding lipstick to the lips of the user as an example, the user uses an electronic device to shoot the lip area to obtain the original image, and selects the target color to be added to the lips; the electronic device obtains the target area including the lip area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is generated according to the ambient brightness in the original image, and changes with the change of the ambient brightness. Finally, the ambient light information is added to the target area after the background color is mixed to obtain the final target image; in this target image, the lip area is not only added with the target color, but also with the highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the lip area, so that the target image has a strong sense of reality. In the above example, in addition to nails, it is also used to add eye shadow to the eyes, add lipstick to the lips, add blush to the cheeks, and adjust the overall facial skin color. The specific process of the embodiment of this application will not be repeated here.

[0175] As a third example, taking AR shooting processing as an example, the user shoots the facial area through an electronic device to obtain the original image, and selects the target color of the target virtual object added on the face (the colors corresponding to different pixels of the target virtual object may be different); the electronic device obtains the target area including the facial area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is finally added to the target area after the background color is mixed to obtain the target image; in this target image, the facial area is not only added with the target virtual object, but also with the highlight texture that changes with the ambient light, and the ambient light information in the original image is retained in the facial area.

[0176] In an optional embodiment, the acquiring the ambient light information of the original image includes:

[0177] Obtain the grayscale information of the target area of ​​the original image;

[0178] Determining brightness reference information of the target area according to the grayscale information;

[0179] Determine a highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information;

[0180] A highlight texture of the target area is generated according to the highlight value of each pixel; the highlight texture is the ambient light information of the original image.

[0181] In an optional embodiment, the brightness reference information includes a brightness interval value, a brightness suppression value, and a maximum brightness value;

[0182] Wherein, the brightness interval value is the difference between the first brightness value and the second brightness value;

[0183] The first brightness value is a brightness of the pixels in the target area sorted from high to low, and the ranking is a first percentage;

[0184] The second brightness value is a brightness ranked as a second percentage; and the brightness suppression value is a ratio between the maximum brightness value and a preset brightness threshold.

[0185] In an optional embodiment, determining the highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information includes:

[0186] Determine a brightness processing weight for each pixel according to the brightness interval value, the maximum brightness value, and the grayscale value of each pixel in the grayscale information;

[0187] The highlight value of each pixel is determined according to the grayscale value, the brightness processing weight and the brightness suppression value.

[0188] In an optional embodiment, determining the brightness processing weight of each pixel point according to the brightness interval value, the maximum brightness value, and the grayscale value of each pixel point in the grayscale information includes:

[0189] If the grayscale value of the pixel is greater than the second brightness value, the brightness processing weight of the pixel is the minimum value between the first ratio and the first preset weight threshold;

[0190] Wherein, the first ratio is a ratio of the first difference value to the brightness interval value, and the first difference value is a difference between the gray value and the second brightness value;

[0191] If the grayscale value of the pixel point is less than or equal to the second brightness value, the brightness processing weight of the pixel point is a second preset weight threshold.

[0192] In an optional embodiment, the highlight value is a continuous product of the gray value, the square of the brightness processing weight and the brightness interval value.

[0193] In an optional embodiment, the step of mixing the target color with the background color of the target area in the original image includes:

[0194] Filtering the target area in the original image to obtain a filtered area;

[0195] The filter area, the target color and the target area are mixed with the background color to obtain the target area after the background color mixing.

[0196] In an optional embodiment, filtering the target area in the original image to obtain the filtered area includes:

[0197] Performing image segmentation on the original image to obtain the target area;

[0198] Obtaining segmentation confidence parameters of the target area;

[0199] Gaussian filtering is performed on the segmentation confidence parameter to obtain a filtering area.

[0200] In an optional embodiment, the step of mixing the filter area, the target color and the target area with a background color to obtain the target area after the background color mixing includes:

[0201] For each pixel, the color parameter value of the target area, the color parameter value of the target color, and the color parameter value of the filter area are multiplied to obtain a first mixing parameter;

[0202] Multiplying the difference between the first preset value and the color parameter value of the filtering area by the color parameter value of the target area to obtain a second mixing parameter;

[0203] Adding the first mixing parameter to the second mixing parameter to obtain a color parameter of the pixel;

[0204] According to the color parameters of each pixel, a target area after background color mixing is obtained.

[0205] In an optional embodiment, adding the ambient light information to the target area after the background color is mixed includes:

[0206] Determine a target color parameter of a pixel point in the target area after the background color is mixed; the target color parameter is a difference between the second preset value and the target value;

[0207] Among them, the target value is the product of the background color parameter and the highlight parameter, the background color parameter is the difference obtained by subtracting the color parameter of the target area of ​​the pixel after the background color is mixed from the third preset value, and the highlight parameter is the difference obtained by subtracting the highlight value of the pixel from the fourth preset value.

[0208] In an optional embodiment, after adding the ambient light information to the target area after the background color is mixed, the method includes:

[0209] The highlight area and the target area are mixed according to the target weight to obtain a target image;

[0210] The highlight area is the target area after the background color is mixed with the ambient light information.

[0211] In the embodiment of the present application, the ambient light information of the original image is obtained; the target color is mixed with the target area in the original image; and finally the ambient light information is added to the target area after the background color is mixed. The ambient light information is calculated in combination with the information of the surrounding environment, so the addition of this ambient light information will add a natural ambient light effect to the target area after the background color is mixed; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0212] Reference Figure 4 , showing a step flow chart of an image generation method embodiment of an embodiment of the present application, the method can be applied to the field of AR shooting, AR shooting, for example, adding virtual objects to the original image captured or shooting AR videos, etc., by generating a highlight texture based on the ambient light information in the original image captured, and finally adding the highlight texture to the processed image to enhance the realism of the image.

[0213] like Figure 4 As shown, the method comprises the following steps:

[0214] Step 401: Acquire an original image including a target object in real time.

[0215] When the electronic device receives the shooting instruction, it shoots and obtains the original image. Figure 1 The original image (as shown in P1) is the image before processing, and the original image may be the image captured by the electronic device. For example, in a shooting scene, the original image is captured by the electronic device when receiving a shooting instruction; in a video shooting scene, the original image is an image frame in the captured video.

[0216] The target object is an object in the original image, such as a person, or a person's facial area.

[0217] Step 402: Acquire ambient light information of the original image.

[0218] The ambient light information can be the overall ambient light information in the original image or the ambient light information of the target area; the target area (such as Figure 1The target area is the area where image processing is performed. For example, if the user selects a specific beauty operation, the target area corresponding to the beauty operation is determined according to the beauty operation selected by the user. For example, if the beauty operation is manicure, the target area is the area where each fingernail of the user is located. If the beauty operation is facial whitening, the target area is the area where the user's face is located. For AR shooting operation, the target area is the area corresponding to the virtual object.

[0219] Step 403: Mix the target color with the base color of the target area of ​​the target object.

[0220] The target area can be a certain area of ​​the target object in the original image, such as the face area, lip area, nail area, etc. The target color is the color to be added to the target area. Taking the nail color processing as an example, the target color ( Figure 1 The filter area, the target color and the target area are mixed with the background color to obtain the background color mixed area, which is the target area after the background color mixing, and the background color mixed area is combined with the target area. Figure 1 , P2 and P4 are mixed to obtain P5, where P5 is an image including a background color mixing area, and the background color mixing area is the nail area after the background color mixing.

[0221] It should be noted that the target color can be a single color, such as adding color to nails; it can also be multiple colors, such as adding virtual objects in AR shooting, and different pixels can correspond to different colors.

[0222] Step 404: Add the ambient light information to the target area after the background color is mixed to obtain a target image.

[0223] After obtaining an image including the target area after background color mixing, the ambient light information is added to the target area after background color mixing to obtain a target image. The target image can be an image obtained in an image shooting scene, or a video frame shot in a video shooting scene. The ambient light information includes a highlight texture, which is generated based on the grayscale information (i.e., brightness information) of the original image, and the brightness information is the initial brightness information of the image; and the brightness information of the image is obtained based on the brightness of the environment, so the highlight obtained by superimposing such a highlight texture will change with the change of the ambient brightness. By adding a highlight texture to the target area after background color mixing, a natural ambient light effect is obtained, thereby making the final target image more realistic.

[0224] Still taking the image processing of the user's nail area and adding nail color as an example, the user uses an electronic device to shoot the nail area to obtain an original image, and selects a target color to be added to the nail; the electronic device obtains a target area including the nail area, generates ambient light information of the area according to the grayscale information of the target area; the target color is mixed with the base color of the target area in the original image. The ambient light information is generated according to the ambient brightness in the original image, changes with the change of the ambient brightness, and finally the ambient light information is added to the target area after the base color mixing to obtain the target image.

[0225] Specific, combined Figure 1 , the user selects the nail art function in the electronic device and selects the target color. The target color is as follows Figure 1 As shown in P4; the electronic device captures the original image of the target area including the user's nails, such as Figure 1 As shown in P1; then the image including the target area is identified and segmented from the original image, as shown in Figure 1 As shown in P2 in FIG. 1 , the ambient light information of the target area is generated according to the grayscale information of the target area, and the ambient light information carries the ambient light information of the nail area, such as Figure 1 As shown in P6; the filter area, the target color selected by the user and the target area are mixed with the background color to obtain the target area after the background color is mixed, as shown in Figure 1 As shown in P5, the highlight texture is finally added to the target area after the base color is mixed, and the ambient light information in the original image is added to the target image, such as Figure 1 As shown in P7, a target image with a strong sense of reality is obtained. In this target image, the nail area not only adds the target color, but also adds a highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the nail area, making the final target image with a strong sense of reality.

[0226] Taking the example of adding lipstick to the user's lips, the user uses an electronic device to shoot the lip area to obtain the original image, and selects the target color to be added to the lips; the electronic device obtains the target area including the lip area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is generated according to the ambient brightness in the original image, and changes with the change of the ambient brightness. Finally, the ambient light information is added to the target area after the background color is mixed to obtain the final target image; in this target image, the lip area is not only added with the target color, but also with the highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the lip area, making the target image more realistic. In the above example, in addition to nails, it is also used to add eye shadow to the eyes, add lipstick to the lips, add blush to the cheeks, and adjust the overall facial skin color. The specific process of the embodiment of this application will not be repeated here.

[0227] In the AR shooting process, the user shoots the facial area through an electronic device to obtain the original image, and selects the target color of the target virtual object added on the face (the colors corresponding to different pixels of the target virtual object may be different); the electronic device obtains the target area including the facial area, and processes it according to the above steps to obtain the background color mixed area. Similarly, the ambient light information is finally added to the background color mixed area to obtain the target image; in this target image, the facial area is not only added with the target virtual object, but also with the highlight texture that changes with the ambient light, and the ambient light information in the original image is retained in the facial area.

[0228] In this embodiment, other steps in the aforementioned embodiments may also be executed, which will not be described again to avoid repetition.

[0229] In the embodiment of the present application, an original image including a target object is acquired in real time, and ambient light information of the original image is acquired; a target color is mixed with a target area of ​​the target object; and finally, the ambient light information is added to the target area after the background color mixing to obtain a target image. The ambient light information is calculated in combination with information of the surrounding environment, so after adding this ambient light information, a natural ambient light effect will be added to the background color mixing area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0230] Reference Figure 5 , shows a flowchart of the steps of an image processing method embodiment of the present application, the method can be applied to the field of image processing, such as beauty and photo editing; generating a highlight texture through the ambient light information in the original image, and finally adding the highlight texture to the processed image to enhance the realism of the image; Figure 5 As shown, the method comprises the following steps:

[0231] Step 501: receiving an input operation for performing image processing on an original image.

[0232] Input operations such as user touch operations. Original images (such as Figure 1 The original image (as shown in P1) is the image before processing, and the original image may be an image stored in the electronic device, or an image captured by the electronic device. For example, in a shooting scenario, the electronic device captures the original image when receiving a shooting instruction; in an image processing scenario, the electronic device performs image processing on the stored original image. In a video shooting scenario or a video processing scenario, the original image is an image frame in the video.

[0233] Step 502: In response to the input operation, obtain ambient light information of the original image.

[0234] The ambient light information can be the overall ambient light information in the original image or the ambient light information of the target area; the target area (such as Figure 1 The target area is the area where image processing is performed. For example, if the user selects a specific beauty operation, the target area corresponding to the beauty operation is determined according to the beauty operation selected by the user. For example, if the beauty operation is manicure, the target area is the area where each fingernail of the user is located. If the beauty operation is facial whitening, the target area is the area where the user's face is located. For AR shooting operation, the target area is the area corresponding to the virtual object.

[0235] Step 503: Mix the target color with the background color of the target area in the original image.

[0236] The target color is the color to be added to the target area. For example, the target color ( Figure 1 The filter area, the target color and the target area are mixed with the background color to obtain the background color mixed area, which is the target area after the background color mixing, and the background color mixed area is combined with the target area. Figure 1 , P2 and P4 are mixed to obtain P5, where P5 is an image including a background color mixing area, and the background color mixing area is the nail area after the background color mixing.

[0237] It should be noted that the target color can be a single color, such as adding color to nails; it can also be multiple colors, such as adding virtual objects in AR shooting, and different pixels can correspond to different colors.

[0238] Step 504: Add the ambient light information to the target area after the background color is mixed.

[0239] After obtaining an image including the target area after background color mixing, the ambient light information is added to the target area after background color mixing to obtain a target image. The target image can be an image obtained in an image shooting scene, or a video frame shot in a video shooting scene. The ambient light information includes a highlight texture, which is generated based on the grayscale information (i.e., brightness information) of the original image, and the brightness information is the initial brightness information of the image; and the brightness information of the image is obtained based on the brightness of the environment, so the highlight obtained by superimposing such a highlight texture will change with the change of the ambient brightness. By adding a highlight texture to the target area after background color mixing, a natural ambient light effect is obtained, thereby making the final target image more realistic.

[0240] Still taking the image processing of the user's nail area and adding nail color as an example, the user uses an electronic device to shoot the nail area to obtain the original image, and selects the target color to be added to the nail; the electronic device obtains the target area including the nail area, generates the ambient light information of the area according to the grayscale information of the target area; the target color is mixed with the target area in the original image. The ambient light information is generated according to the ambient brightness in the original image, changes with the change of the ambient brightness, and finally the ambient light information is added to the target area after the background color mixing to obtain the target image.

[0241] Specific, combined Figure 1 , the user selects the nail art function in the electronic device and selects the target color. The target color is as follows Figure 1 As shown in P4; the electronic device captures the original image of the target area including the user's nails, such as Figure 1 As shown in P1; then the image including the target area is identified and segmented from the original image, as shown in Figure 1 As shown in P2 in FIG. 1 , the ambient light information of the target area is generated according to the grayscale information of the target area, and the ambient light information carries the ambient light information of the nail area, such as Figure 1 As shown in P6; the filter area, the target color selected by the user and the target area are mixed with the background color to obtain the target area after the background color is mixed, as shown in Figure 1 As shown in P5, the highlight texture is finally added to the target area after the base color is mixed, and the ambient light information in the original image is added to the target image, such as Figure 1 As shown in P7, a target image with a strong sense of reality is obtained. In this target image, the nail area not only adds the target color, but also adds a highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the nail area, making the final target image with a strong sense of reality.

[0242] Taking the example of adding lipstick to the user's lips, the user uses an electronic device to shoot the lip area to obtain the original image, and selects the target color to be added to the lips; the electronic device obtains the target area including the lip area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is generated according to the ambient brightness in the original image, and changes with the change of the ambient brightness. Finally, the ambient light information is added to the target area after the background color is mixed to obtain the final target image; in this target image, the lip area is not only added with the target color, but also with the highlight texture that changes with the ambient light. The ambient light information in the original image is retained in the lip area, making the target image more realistic. In the above example, in addition to nails, it is also used to add eye shadow to the eyes, add lipstick to the lips, add blush to the cheeks, and adjust the overall facial skin color. The specific process of the embodiment of this application will not be repeated here.

[0243] Taking AR shooting processing as an example, the user shoots the facial area through an electronic device to obtain the original image, and selects the target color of the target virtual object added on the face (the colors corresponding to different pixels of the target virtual object may be different); the electronic device obtains the target area including the facial area, and processes it according to the above steps to obtain the target area after the background color is mixed. Similarly, the ambient light information is finally added to the target area after the background color is mixed to obtain the target image; in this target image, not only the target virtual object is added to the facial area, but also a highlight texture that changes with the ambient light is added, and the ambient light information in the original image is retained in the facial area.

[0244] In addition to the above steps 501 to 504, the image processing method provided in this embodiment also includes other steps in the image processing method in the above embodiments, and the details can be referred to the description of the above embodiments; to avoid repetition, they will not be described again here.

[0245] In the embodiment of the present application, an input operation for image processing of an original image is received; in response to the input operation, ambient light information of the original image is obtained; a target color is mixed with a target area in the original image to form a background color; and finally, the ambient light information is added to the target area after the background color mixing. The ambient light information is calculated in combination with information about the surrounding environment, so after adding this ambient light information, a natural ambient light effect will be added to the background color mixing area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0246] On the basis of the above embodiments, this embodiment further provides an image processing device, which is applied to electronic devices such as terminal devices and servers.

[0247] Reference Figure 6 , shows a structural block diagram of an embodiment of an image processing device of the present application, which may specifically include the following modules:

[0248] An ambient light acquisition module 601 is used to acquire ambient light information of an original image;

[0249] A background color mixing module 602 is used to mix the target color with the background color of the target area in the original image;

[0250] The ambient light adding module 603 is used to add the ambient light information into the target area after the background color is mixed.

[0251] In an optional embodiment, the ambient light acquisition module 601 includes:

[0252] Grayscale acquisition submodule, used to obtain grayscale information of the target area of ​​the original image;

[0253] An information determination submodule, used to determine brightness reference information of the target area according to the grayscale information;

[0254] A highlight determination submodule, used to determine the highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information;

[0255] A highlight texture of the target area is generated according to the highlight value of each pixel; the highlight texture is the ambient light information of the original image.

[0256] In an optional embodiment, the brightness reference information includes a brightness interval value, a brightness suppression value, and a maximum brightness value;

[0257] Among them, the brightness interval value is the difference between the first brightness value and the second brightness value; the first brightness value is the brightness of the pixels in the target area sorted from high to low, ranked as the first percentage; the second brightness value is the brightness ranked as the second percentage; the brightness suppression value is the ratio between the maximum brightness value and the preset brightness threshold.

[0258] In an optional embodiment, the highlight determination submodule includes:

[0259] A weight determination unit, configured to determine a brightness processing weight for each pixel according to the brightness interval value, the maximum brightness value, and the grayscale value of each pixel in the grayscale information;

[0260] A highlight determination unit, configured to determine a highlight value of each pixel according to the grayscale value, the brightness processing weight, and the brightness suppression value;

[0261] The texture generating unit is used to generate the highlight texture of the target area according to the highlight value of each pixel point.

[0262] In an optional embodiment, the weight determination unit is used to:

[0263] If the grayscale value of the pixel is greater than the second brightness value, the brightness processing weight of the pixel is the minimum value between the first ratio and the first preset weight threshold;

[0264] Wherein, the first ratio is a ratio of the first difference value to the brightness interval value, and the first difference value is a difference between the gray value and the second brightness value;

[0265] If the grayscale value of the pixel point is less than or equal to the second brightness value, the brightness processing weight of the pixel point is a second preset weight threshold.

[0266] In an optional embodiment, the highlight value is a continuous product of the gray value, the square of the brightness processing weight and the brightness interval value.

[0267] In an optional embodiment, the background color mixing module 602 includes:

[0268] A filtering submodule, used for filtering the target area in the original image to obtain a filtered area;

[0269] The mixing submodule is used to mix the filter area, the target color and the target area with a background color to obtain the target area after the background color mixing.

[0270] In an optional embodiment, the filtering submodule includes:

[0271] A segmentation unit, used for performing image segmentation on the original image to obtain the target area;

[0272] A parameter acquisition submodule, used to obtain the segmentation confidence parameters of the target area;

[0273] The filtering submodule is used to perform Gaussian filtering on the segmentation confidence parameter to obtain a filtering area.

[0274] In an optional embodiment, the mixing submodule is used to:

[0275] For each pixel, the color parameter value of the target area, the color parameter value of the target color, and the color parameter value of the filter area are multiplied to obtain a first mixing parameter;

[0276] Multiplying the difference between the first preset value and the color parameter value of the filtering area by the color parameter value of the target area to obtain a second mixing parameter;

[0277] Adding the first mixing parameter to the second mixing parameter to obtain a color parameter of the pixel;

[0278] According to the color parameters of each pixel, a target area after background color mixing is obtained.

[0279] In an optional embodiment, the ambient light adding module 603 is used to:

[0280] Determine a target color parameter of a pixel point in the target area after the background color is mixed; the target color parameter is a difference between the second preset value and the target value;

[0281] Among them, the target value is the product of the background color parameter and the highlight parameter, the background color parameter is the difference obtained by subtracting the color parameter of the target area of ​​the pixel after the background color is mixed from the third preset value, and the highlight parameter is the difference obtained by subtracting the highlight value of the pixel from the fourth preset value.

[0282] In an optional embodiment, the device comprises:

[0283] A weighted mixing module is used to add the ambient light information to the target area after the ambient light adding module 603 adds the ambient light information to the background mixed target area.

[0284] The highlight area and the target area are mixed according to the target weight to obtain a target image;

[0285] The highlight area is the target area after the background color is mixed with the ambient light information.

[0286] In the embodiment of the present application, the ambient light acquisition module 601 acquires the ambient light information of the original image; the background color mixing module 602 performs background color mixing on the target color and the target area in the original image; and the ambient light adding module 603 adds the ambient light information to the target area after the background color mixing. The ambient light information is calculated in combination with the information of the surrounding environment, so after adding this ambient light information, a natural ambient light effect will be added to the background color mixing area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0287] On the basis of the above embodiments, this embodiment further provides an image generating device, which is applied to electronic devices such as terminal devices and servers.

[0288] Reference Figure 7 , shows a structural block diagram of an embodiment of an image generation device of the present application, which may specifically include the following modules:

[0289] The shooting module 701 is used to obtain the original image including the target object in real time;

[0290] A first acquisition module 702 is used to acquire the ambient light information of the target object;

[0291] A first mixing module 703, used to mix the target color with the background color of the target area in the original image;

[0292] The first adding module 704 is used to add the ambient light information to the target area after the background color is mixed to generate a target image.

[0293] The image generating device provided in the embodiment of the present application also executes other steps in the image processing method in the above embodiment, and the details can be referred to the description of the above embodiment; to avoid repetition, they will not be described again here.

[0294] In the embodiment of the present application, the shooting module 701 acquires the original image including the target object in real time, the first acquisition module 702 acquires the ambient light information of the original image; the first mixing module 703 performs a background color mixing with the target color and the target area of ​​the target object; the first adding module 704 adds the ambient light information to the target area after the background color mixing to generate the target image. The ambient light information is calculated in combination with the information of the surrounding environment, so after adding this ambient light information, a natural ambient light effect will be added to the background color mixing area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0295] On the basis of the above embodiments, this embodiment further provides an image processing device, which is applied to electronic devices such as terminal devices and servers.

[0296] Reference Figure 8 , shows a structural block diagram of an embodiment of an image processing device of the present application, which may specifically include the following modules:

[0297] A receiving module 801 is used to receive an input operation for performing image processing on an original image;

[0298] A response module 802 is used to obtain ambient light information of the original image in response to the input operation;

[0299] A second mixing module 803 is used to mix the target color with the background color of the target area in the original image;

[0300] The second adding module 804 is used to add the ambient light information to the target area after the background color is mixed.

[0301] The image processing device provided in the embodiment of the present application also executes other steps in the image processing method in the above embodiment. For details, please refer to the description of the above embodiment; to avoid repetition, they will not be described again here.

[0302] In the embodiment of the present application, the receiving module 801 receives an input operation for image processing of the original image; the responding module 802 obtains the ambient light information of the original image; the second mixing module 803 performs a background color mixing with the target color and the target area in the original image; and the second adding module 804 adds the ambient light information to the target area after the background color mixing. The ambient light information is calculated in combination with the information of the surrounding environment, so after adding this ambient light information, a natural ambient light effect will be added to the background color mixing area; and the ambient light information will change with the brightness of the surrounding environment, so that the highlight of the background color area in the target image will also change with the change of the brightness of the surrounding environment, and the sense of reality is strong.

[0303] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.

[0304] The present application embodiment provides one or more machine-readable storage media, on which instructions are stored, and when executed by one or more processors, the electronic device executes one or more of the methods described in the above embodiments. In the present application embodiment, the electronic device includes various types of devices such as terminal devices and servers (clusters).

[0305] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include electronic devices such as terminal devices and servers (clusters). Fig. 9 An exemplary apparatus 900 that can be used to implement various embodiments described in this application is schematically illustrated.

[0306] For one embodiment, Fig. 9 An exemplary apparatus 900 is shown having one or more processors 902, a control module (chip set) 904 coupled to at least one of the processor(s) 902, a memory 906 coupled to the control module 904, a non-volatile memory (NVM) / storage device 908 coupled to the control module 904, one or more input / output devices 910 coupled to the control module 904, and a network interface 912 coupled to the control module 904.

[0307] The processor 902 may include one or more single-core or multi-core processors, and the processor 902 may include any combination of general-purpose processors or special-purpose processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 900 can be used as a terminal device, server (cluster), etc. described in the embodiments of the present application.

[0308] In some embodiments, the apparatus 900 may include one or more computer-readable media (e.g., memory 906 or NVM / storage device 908) having instructions 914 and one or more processors 902 combined with the one or more computer-readable media and configured to execute the instructions 914 to implement a module to perform the actions described in the present disclosure.

[0309] For one embodiment, the control module 904 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 902 and / or any suitable device or component in communication with the control module 904 .

[0310] The control module 904 may include a memory controller module to provide an interface to the memory 906. The memory controller module may be a hardware module, a software module, and / or a firmware module.

[0311] The memory 906 may be used, for example, to load and store data and / or instructions 914 for the device 900. For one embodiment, the memory 906 may include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 906 may include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).

[0312] For one embodiment, control module 904 may include one or more input / output controllers to provide an interface to NVM / storage device 908 and input / output device(s) 910 .

[0313] For example, NVM / storage 908 may be used to store data and / or instructions 914. NVM / storage 908 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).

[0314] NVM / storage device 908 may include storage resources that are physically part of the device on which apparatus 900 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 908 may be accessed via (one or more) input / output devices 910 over a network.

[0315] (One or more) input / output devices 910 may provide an interface for the apparatus 900 to communicate with any other appropriate device, and the input / output device 910 may include a communication component, an audio component, a sensor component, etc. The network interface 912 may provide an interface for the apparatus 900 to communicate through one or more networks, and the apparatus 900 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.

[0316] For one embodiment, at least one of the processor(s) 902 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 904. For one embodiment, at least one of the processor(s) 902 may be packaged together with the logic of one or more controllers of the control module 904 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 902 may be integrated on the same die with the logic of one or more controllers of the control module 904. For one embodiment, at least one of the processor(s) 902 may be integrated on the same die with the logic of one or more controllers of the control module 904 to form a system-on-chip (SoC).

[0317] In various embodiments, the device 900 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the device 900 may have more or fewer components and / or a different architecture. For example, in some embodiments, the device 900 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.

[0318] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in a memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.

[0319] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0320] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0321] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0322] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0323] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0324] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0325] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0326] The above is a detailed introduction to an image processing method and device, an image generating method and device, an electronic device and a storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for a person skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Obtaining grayscale information of a target area of ​​an original image; determining brightness reference information of the target area according to the grayscale information; determining a highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information; generating a highlight texture of the target area according to the highlight value of each pixel; the highlight texture being the ambient light information of the original image; Performing Gaussian filtering on the target area in the original image to obtain a filtered area; for each pixel, multiplying the color parameter value of the target area, the color parameter value of the target color, and the color parameter value of the filtered area to obtain a first mixing parameter; multiplying the difference between a first preset value and the color parameter value of the filtered area by the color parameter value of the target area to obtain a second mixing parameter; adding the first mixing parameter to the second mixing parameter to obtain the color parameter of the pixel; and obtaining the target area after background color mixing according to the color parameter of each pixel; The ambient light information is added to the target area after the background color is mixed.

2. The image processing method according to claim 1, characterized in that: The brightness reference information includes a brightness interval value, a brightness suppression value, and a maximum brightness value; Wherein, the brightness interval value is the difference between the first brightness value and the second brightness value; The first brightness value is a brightness of the pixels in the target area sorted from high to low, and the ranking is a first percentage; The second brightness value is a brightness ranked as a second percentage; and the brightness suppression value is a ratio between the maximum brightness value and a preset brightness threshold.

3. The image processing method according to claim 2, characterized in that: The determining the highlight value of each pixel point according to the brightness reference information and the grayscale value of each pixel point in the grayscale information includes: Determine a brightness processing weight for each pixel according to the brightness interval value, the maximum brightness value, and the grayscale value of each pixel in the grayscale information; The highlight value of each pixel is determined according to the grayscale value, the brightness processing weight and the brightness suppression value.

4. The image processing method according to claim 3, characterized in that: The step of determining the brightness processing weight of each pixel point according to the brightness interval value, the maximum brightness value, and the grayscale value of each pixel point in the grayscale information includes: If the grayscale value of the pixel is greater than the second brightness value, the brightness processing weight of the pixel is the minimum value between the first ratio and the first preset weight threshold; Wherein, the first ratio is a ratio of the first difference value to the brightness interval value, and the first difference value is a difference between the gray value and the second brightness value; If the grayscale value of the pixel point is less than or equal to the second brightness value, the brightness processing weight of the pixel point is a second preset weight threshold.

5. The image processing method according to claim 3, characterized in that: The highlight value is the product of the gray value, the square of the brightness processing weight, and the brightness interval value.

6. The image processing method according to claim 1, characterized in that: The step of performing Gaussian filtering on the target area in the original image to obtain a filtered area includes: Performing image segmentation on the original image to obtain the target area; Obtaining segmentation confidence parameters of the target area; Gaussian filtering is performed on the segmentation confidence parameter to obtain a filtering area.

7. The image processing method according to claim 1, characterized in that: The step of adding the ambient light information to the target area after the background color is mixed comprises: Determine a target color parameter of a pixel point in the target area after the background color is mixed; the target color parameter is a difference between the second preset value and the target value; Among them, the target value is the product of the background color parameter and the highlight parameter, the background color parameter is the difference obtained by subtracting the color parameter of the target area of ​​the pixel after the background color is mixed from the third preset value, and the highlight parameter is the difference obtained by subtracting the highlight value of the pixel from the fourth preset value.

8. The image processing method according to claim 1, characterized in that: After adding the ambient light information to the target area after the background color is mixed, the method comprises: The highlight area and the target area are mixed according to the target weight to obtain a target image; The highlight area is the target area after the background color is mixed with the ambient light information.

9. An image generation method, characterized in that: The method comprises: Acquire the original image including the target object in real time; Obtaining grayscale information of a target area of ​​the original image; determining brightness reference information of the target area according to the grayscale information; determining a highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information; generating a highlight texture of the target area according to the highlight value of each pixel; the highlight texture being the ambient light information of the original image; Performing Gaussian filtering on the target area in the original image to obtain a filtered area; for each pixel, multiplying the color parameter value of the target area, the color parameter value of the target color, and the color parameter value of the filtered area to obtain a first mixing parameter; multiplying the difference between a first preset value and the color parameter value of the filtered area by the color parameter value of the target area to obtain a second mixing parameter; adding the first mixing parameter to the second mixing parameter to obtain the color parameter of the pixel; and obtaining the target area after background color mixing according to the color parameter of each pixel; The ambient light information is added to the target area after the background color is mixed to obtain a target image.

10. An image processing method, characterized in that: The method comprises: receiving an input operation for performing image processing on an original image; In response to the input operation, grayscale information of a target area of ​​an original image is obtained; according to the grayscale information, brightness reference information of the target area is determined; according to the brightness reference information and the grayscale value of each pixel in the grayscale information, a highlight value of each pixel is determined; according to the highlight value of each pixel, a highlight texture of the target area is generated; the highlight texture is the ambient light information of the original image; Performing Gaussian filtering on the target area in the original image to obtain a filtered area; for each pixel, multiplying the color parameter value of the target area, the color parameter value of the target color, and the color parameter value of the filtered area to obtain a first mixing parameter; multiplying the difference between a first preset value and the color parameter value of the filtered area by the color parameter value of the target area to obtain a second mixing parameter; adding the first mixing parameter to the second mixing parameter to obtain the color parameter of the pixel; and obtaining the target area after background color mixing according to the color parameter of each pixel; The ambient light information is added to the target area after the background color is mixed.

11. An image processing device, characterized in that: The device comprises: An ambient light acquisition module is used to acquire grayscale information of a target area of ​​an original image; determine brightness reference information of the target area according to the grayscale information; determine a highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information; generate a highlight texture of the target area according to the highlight value of each pixel; the highlight texture is the ambient light information of the original image; A background color mixing module is used to perform Gaussian filtering on the target area in the original image to obtain a filtered area; for each pixel, the color parameter value of the target area, the color parameter value of the target color and the color parameter value of the filtered area are multiplied to obtain a first mixing parameter; the difference between a first preset value and the color parameter value of the filtered area is multiplied by the color parameter value of the target area to obtain a second mixing parameter; the first mixing parameter and the second mixing parameter are added to obtain the color parameter of the pixel; and the target area after background color mixing is obtained according to the color parameter of each pixel; The ambient light adding module is used to add the ambient light information into the target area after the background color is mixed.

12. An image generating device, characterized in that: The device comprises: A shooting module, used for acquiring an original image including a target object in real time; A first acquisition module is used to acquire grayscale information of a target area of ​​an original image; determine brightness reference information of the target area according to the grayscale information; determine a highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information; generate a highlight texture of the target area according to the highlight value of each pixel; the highlight texture is the ambient light information of the original image; A first mixing module is used to perform Gaussian filtering on the target area in the original image to obtain a filtering area; for each pixel, the color parameter value of the target area, the color parameter value of the target color and the color parameter value of the filtering area are multiplied to obtain a first mixing parameter; a difference between a first preset value and the color parameter value of the filtering area is multiplied by the color parameter value of the target area to obtain a second mixing parameter; the first mixing parameter and the second mixing parameter are added to obtain the color parameter of the pixel; and the target area after background color mixing is obtained according to the color parameter of each pixel; The first adding module is used to add the ambient light information to the target area after the background color is mixed to obtain a target image.

13. An image processing device, characterized in that: The device comprises: A receiving module, used for receiving an input operation for performing image processing on an original image; A response module, configured to obtain grayscale information of a target area of ​​an original image in response to the input operation; determine brightness reference information of the target area according to the grayscale information; determine a highlight value of each pixel according to the brightness reference information and the grayscale value of each pixel in the grayscale information; generate a highlight texture of the target area according to the highlight value of each pixel; the highlight texture is the ambient light information of the original image; A second mixing module is used to perform Gaussian filtering on the target area in the original image to obtain a filtering area; for each pixel, the color parameter value of the target area, the color parameter value of the target color and the color parameter value of the filtering area are multiplied to obtain a first mixing parameter; a difference between a first preset value and the color parameter value of the filtering area is multiplied by the color parameter value of the target area to obtain a second mixing parameter; the first mixing parameter and the second mixing parameter are added to obtain the color parameter of the pixel; and the target area after background color mixing is obtained according to the color parameter of each pixel; The second adding module is used to add the ambient light information into the target area after the background color is mixed.

14. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, cause the processor to perform the method as claimed in one or more of claims 1 to 10.

15. One or more machine-readable storage media having executable code stored thereon, characterized in that: When the executable code is executed, the processor is caused to perform the method as claimed in one or more of claims 1 to 10.

Citation Information

Patent Citations

  • Virtual makeup trying method and device, equipment and image processing method

    CN110728618A

  • 3D projection beauty makeup method and 3D projection beauty makeup wearable device

    CN111260587A