Image processing method, device and electronic system
By extracting the color and brightness information of the area whose brightness is lower than the target threshold in the reference makeup image, the makeup is processed, which solves the makeup color difference problem caused by the highlight area and improves the visual effect of makeup migration.
Patent Information
- Application Number
- CN202110969032.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-23
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-08-23
AI Technical Summary
In the existing makeup transfer technology, the makeup color in the highlight area is lighter than the non-highlight area, resulting in the overall makeup color after migration being lighter, causing obvious color difference and reducing the visual effect.
By extracting the makeup color information and brightness information of the area whose brightness is lower than the target brightness threshold in the reference makeup image, the makeup is applied, the color and brightness of the area to be applied are adjusted, and the brightness of the target image is calculated using histogram matching and mean transformation formulas. Channel value to alleviate chromatic aberration problems caused by highlight areas.
It effectively reduces the color difference after makeup migration, improves the visual effect of makeup migration, makes the color of the makeup after migration closer to the reference makeup area, and retains the light and dark distribution characteristics of the image to be applied.
Smart Images

Figure CN113781330B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image processing method, device and electronic system. Background Art
[0002] Makeup migration can migrate the makeup in the reference image to the source image through image processing, so that the bare face in the source image can be virtually made up. There are usually many highlight areas in makeup, for example, the forehead, eyes, nose bridge, cheekbones, mouth and other parts may have highlight areas. Due to the high brightness of the highlight area, the color of the makeup in the highlight area is lighter than that in the non-highlight area. When the makeup is migrated by histogram matching and other methods, the highlight area may cause the migrated makeup color to be lighter overall. The migrated makeup has obvious color difference, which reduces the visual effect of the makeup migration. Summary of the invention
[0003] In view of this, an object of the present invention is to provide an image processing method, device and electronic system, which can reduce the color difference after makeup transfer and improve the visual effect of makeup transfer.
[0004] In a first aspect, an embodiment of the present invention provides an image processing method, comprising: obtaining a to-be-made-up area of an image to be made-up and an already-made-up area in a reference makeup image corresponding to the to-be-made-up area of the image to be made-up; extracting makeup brightness information of the already-made-up area and makeup color information of a partial image area in the already-made-up area; wherein the brightness of the partial image area in the already-made-up area is lower than a target brightness threshold; and performing makeup processing on the to-be-made-up area based on the makeup color information and the makeup brightness information.
[0005] In a preferred embodiment of the present invention, the above-mentioned step of extracting makeup brightness information of the made-up area and makeup color information of a partial image area in the made-up area includes: extracting the brightness channel value of each pixel in the made-up area to obtain makeup brightness information; filtering out image areas in the made-up area where the brightness channel values of pixels are lower than a target brightness threshold to obtain a first image; and extracting the color channel value of each pixel of the first image to obtain makeup color information.
[0006] In a preferred embodiment of the present invention, the target brightness threshold is determined in the following manner: obtaining the brightness channel value of each pixel in the made-up area; calculating the probability of occurrence of each brightness channel value in the made-up area; wherein the probability of occurrence is the ratio of the number of pixels in the made-up area whose brightness is the brightness channel value to the total number of pixels in the made-up area; selecting brightness channel values one by one in order from low brightness to high brightness, and accumulating and integrating the occurrence probabilities corresponding to the selected brightness channel values until the cumulative probability obtained by the cumulative integration reaches a preset probability threshold; and determining the brightness channel value corresponding to the last occurrence probability participating in the cumulative integration as the target brightness threshold.
[0007] In a preferred embodiment of the present invention, the step of applying makeup to the area to be made up based on the makeup color information and the makeup brightness information includes: adjusting the color of the area to be made up based on the makeup color information, adjusting the brightness of the area to be made up based on the makeup brightness information, and obtaining an image of the area to be made up after the makeup is applied.
[0008] In a preferred embodiment of the present invention, the steps of adjusting the color of the area to be made-up based on the makeup color information, adjusting the brightness of the area to be made-up based on the makeup brightness information, and obtaining an image of the area to be made-up after makeup processing include: performing histogram matching processing on the area to be made-up based on the makeup color information to obtain a matched image; determining the color channel value of each pixel of the matched image as the color channel value of the target image; determining the brightness channel value of each pixel of the target image based on the makeup brightness information and the brightness channel information of the area to be made-up; and determining the target image according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image.
[0009] In a preferred embodiment of the present invention, the step of determining the brightness channel value of each pixel of the target image based on the makeup brightness information and the brightness channel information of the area to be made-up includes: calculating the average value of the brightness channel values of each pixel in the made-up area based on the makeup brightness information to obtain a first brightness average value; calculating the average value of the brightness channel values of each pixel in the area to be made-up to obtain a second brightness average value; determining the brightness channel value of each pixel of the target image based on the first brightness average value, the second brightness average value and the brightness channel value of each pixel in the area to be made-up.
[0010] In a preferred embodiment of the present invention, the step of determining the brightness channel value of each pixel of the target image according to the first brightness mean, the second brightness mean and the brightness channel value of each pixel of the area to be made up includes: calculating the brightness channel value of each pixel of the target image by a preset mean transformation formula according to the first brightness mean, the second brightness mean and the brightness channel value of each pixel of the area to be made up; wherein the mean transformation formula is: Sdi-l =S si-l -u s +u r , where S si-l is the brightness channel value of pixel i in the area to be made up; S di-l is the brightness channel value of pixel i of the target image; u r is the first average brightness of each pixel in the makeup area; s is the second brightness average of each pixel in the area to be made-up.
[0011] In a preferred embodiment of the present invention, the step of determining the target image according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image includes: according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image, the color channel and the brightness channel of each pixel in the target image are spliced in units of pixels to obtain the target image.
[0012] In a preferred embodiment of the present invention, the step of obtaining the area to be applied for makeup of the image to be applied for makeup and the area already applied for makeup in the reference makeup image corresponding to the area to be applied for makeup of the image to be applied for makeup comprises: segmenting the area to be applied for makeup from the image to be applied for makeup by an image segmentation algorithm or a facial key point detection algorithm, and segmenting the area already applied for makeup corresponding to the area to be applied for makeup from the reference makeup image.
[0013] In a second aspect, an embodiment of the present invention further provides an image processing device, comprising: an area acquisition module, used to acquire the area to be applied with makeup of an image to be applied with makeup and an already applied makeup area in a reference makeup image corresponding to the area to be applied with makeup of the image to be applied with makeup; an information extraction module, used to extract makeup brightness information of the already applied makeup area and makeup color information of a part of the image area in the already applied makeup area; wherein the brightness of the part of the image area in the already applied makeup area is lower than a target brightness threshold; and a makeup processing module, used to perform makeup processing on the area to be applied with makeup based on the makeup color information and the makeup brightness information.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic system, which includes: a processing device and a storage device; a computer program is stored on the storage device, and the computer program executes the above-mentioned image processing method when being run by the processing device.
[0015] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned image processing method.
[0016] The embodiments of the present invention bring the following beneficial effects:
[0017] An image processing method, device and electronic system provided by an embodiment of the present invention obtains a makeup-to-be-applied area of a makeup-to-be-applied image and a makeup-applied area corresponding to the makeup-to-be-applied area of the makeup-to-be-applied image in a reference makeup image; extracts makeup brightness information of the makeup-applied area and makeup color information of a portion of the image area in the makeup-applied area; wherein the brightness of the portion of the image area in the makeup-applied area is lower than a target brightness threshold; and performs makeup processing on the makeup-to-be-applied area based on the makeup color information and the makeup brightness information. In this method, by separately extracting makeup color information and makeup brightness information for performing makeup processing on the makeup-to-be-applied area of the makeup-to-be-applied image, wherein the makeup color information is extracted from the image area lower than the target brightness threshold in the corresponding makeup-applied area in the reference makeup image, the problem of obvious color difference caused by the makeup color of the highlight area in the reference makeup image being lighter than the color of the non-highlight area, resulting in the makeup color of the migrated highlight area being relatively lighter; this method effectively reduces the color difference after makeup migration and improves the visual effect of makeup migration.
[0018] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.
[0019] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 A schematic diagram of the structure of an electronic system provided by an embodiment of the present invention;
[0022] Figure 2 A schematic diagram of a flow chart of an image processing method provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of a flow chart of another image processing method provided by an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of the structure of an image processing device provided by an embodiment of the present invention.
[0025] Icons: 100 - electronic system; 102 - processing device; 104 - storage device; 106 - input device; 108 - output device; 110 - image acquisition device; 112 - bus system; 41 - area acquisition module; 42 - information extraction module; 43 - makeup processing module. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] Makeup transfer is a virtual makeup process that transfers the makeup in a reference image (makeup image) to a source image (natural makeup image). Compared with the physical makeup process, the virtual makeup process takes less time and does not damage the skin. It can meet the needs of modern women to try a large number of makeup in a short period of time. At the same time, it is easy to integrate into the makeup recommendation function, and has broad application prospects.
[0028] Considering that the existing makeup migration method may cause obvious color difference in the migrated makeup, the embodiment of the present invention provides an image processing method, device and electronic system, which can be applied to various application scenarios of virtual makeup. To facilitate understanding of this embodiment, firstly, an image processing method disclosed in the embodiment of the present invention is introduced in detail.
[0029] Embodiment 1:
[0030] First, refer to Figure 1 An exemplary electronic system 100 for implementing the image processing method, apparatus, and electronic system according to the embodiments of the present invention is described.
[0031] like Figure 1 The electronic system 100 includes one or more processing devices 102, one or more storage devices 104, an input device 106, an output device 108, and may also include one or more image acquisition devices 110. These components are interconnected through a bus system 112 and / or other forms of connection mechanisms (not shown). It should be noted that Figure 1 The components and structure of the electronic system 100 shown are merely exemplary and not limiting. The electronic system may also have other components and structures as required.
[0032] The processing device 102 can be a gateway, or a smart terminal, or a device including a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities. It can process data of other components in the electronic system 100 and control other components in the electronic system 100 to perform desired functions.
[0033] The storage device 104 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processing device 102 may run the program instructions to implement the client functions and / or other desired functions in the embodiments of the present invention (implemented by the processing device) described below. Various applications and various data, such as various data used and / or generated by the application, may also be stored in the computer-readable storage medium.
[0034] The input device 106 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, and the like.
[0035] The output device 108 may output various information (eg, images or sounds) to the outside (eg, a user), and may include one or more of a display, a speaker, and the like.
[0036] The image acquisition device 110 can acquire preview video frames or picture data (such as images to be processed or target video frames), and store the acquired preview video frames or image data in the storage device 104 for use by other components.
[0037] Exemplarily, the components in the example electronic system for implementing the image processing method, device and electronic system according to the embodiment of the present invention can be integrated or dispersed, such as integrating the processing device 102, the storage device 104, the input device 106 and the output device 108 into one body, and setting the image acquisition device 110 at a specified position where the image can be acquired. When the components in the above electronic system are integrated, the electronic system can be implemented as a smart terminal such as a camera, a smart phone, a tablet computer, a computer, a vehicle-mounted terminal, a video camera, etc.
[0038] Embodiment 2:
[0039] This embodiment provides an image processing method, such as Figure 2 As shown, the method comprises the following steps:
[0040] Step S202: obtaining a makeup-to-be-applied area of the makeup-to-be-applied image and a makeup-applied area corresponding to the makeup-to-be-applied area of the makeup-to-be-applied image in the reference makeup image.
[0041] The area to be made up can be any part of the image area to be made up. Usually, the area to be made up is a specific object in the image to be made up. The object can be the whole or part of a person or an animal, such as a person's face, mouth, forehead, etc. The reference makeup image is used to provide a reference makeup for the area to be made up. Usually, the reference makeup image contains the same object as the area to be made up. For example, if the object to be made up is a mouth, the reference makeup image also contains the mouth, and the mouth in the reference makeup image is used as the made-up area corresponding to the area to be made up; similarly, if the area to be made up is a face, the reference makeup image also contains the face, and the face is used as the corresponding made-up area.
[0042] In actual operation, the area to be made up can be segmented out from the image to be made up by image segmentation, and the area already made up in the reference makeup image corresponding to the area to be made up in the image to be made up can be segmented out from the reference makeup image. For example, if the lips of a person in the image to be made up need to be made up, the lips in the image to be made up can be segmented out, and the corresponding area already made up in the reference makeup image can be segmented out at the same time.
[0043] Specifically, the image segmentation method can be implemented by using an image segmentation algorithm. For example, if it is necessary to segment the lip region from the image to be made up, an image segmentation model can be trained to extract the lip graphics in the image, so as to segment the lip region from the image to be made up based on the image segmentation model. In addition, the above image segmentation process can also be implemented by a facial key point detection algorithm; taking the segmentation of the lip region from a facial image as an example, the geometric shape of the lip region can be represented by the coordinates of several key feature points connected in series to form a shape vector. The lip region can be obtained by connecting the key points of the lips and then performing segmentation.
[0044] Step S204: extracting makeup brightness information of the made-up area and makeup color information of a partial image area in the made-up area; wherein the brightness of the partial image area in the made-up area is lower than a target brightness threshold.
[0045] The makeup color information is used to determine the color of makeup to be applied to the makeup area.
[0046] In this embodiment, the image area for extracting makeup color information is conditionally restricted, and only the image area below the preset brightness threshold in the makeup area of the reference makeup image is extracted. In this way, the makeup color information is excluded from the area with higher image brightness, such as the highlight area. In actual operation, even if there are two areas with the same makeup color, for example, assuming that the upper lip and the lower lip have the same color of lipstick makeup, but if there is a highlight on the lower lip, the makeup color extracted from the lower lip will be lighter than the makeup color extracted from the upper lip due to the influence of the highlight effect, resulting in color difference problems.
[0047] Through the operation in the above step S204, the extraction area of the makeup color information is limited according to the image brightness, so as to alleviate the problem of color difference caused by the extracted makeup color information being lighter due to the high brightness in the reference makeup image in the above-mentioned highlight scene.
[0048] Step S206: performing makeup processing on the makeup area based on the makeup color information and the makeup brightness information.
[0049] The makeup color information is used to adjust the color of the area to be made-up to achieve a makeup effect; the makeup brightness information of the reference makeup image is used to adjust the brightness of the area to be made-up to achieve a makeup effect.
[0050] Compared with traditional makeup migration methods, such as the method of migrating makeup through histogram matching, this method directly uses the reference makeup image as the matching object to match the makeup image, and does not take into account the problem of color difference caused by the "weakening" of the makeup color due to areas with higher brightness such as highlights in color matching; the image processing method in this embodiment extracts the makeup color information separately, and extracts it from the area of the reference makeup image where the brightness is lower than the preset brightness threshold, thereby effectively alleviating the makeup color difference problem caused by the above-mentioned highlight area.
[0051] An image processing method provided by an embodiment of the present invention comprises the steps of obtaining a makeup-to-be-applied area of an image to be applied with makeup and a makeup-applied area corresponding to the makeup-to-be-applied area of the image to be applied with makeup in a reference makeup image; extracting makeup brightness information of the makeup-applied area and makeup color information of a part of the image area in the makeup-applied area; wherein the brightness of the part of the image area in the makeup-applied area is lower than a target brightness threshold; and applying makeup to the area to be applied with makeup based on the makeup color information and the makeup brightness information. In this method, the makeup color information and makeup brightness information used for applying makeup to the area to be applied with makeup of the image to be applied with makeup are extracted separately, wherein the makeup color information is extracted from the image area lower than the target brightness threshold in the makeup-applied area corresponding to the reference makeup image, thereby alleviating the problem of obvious color difference caused by the makeup color of the highlight area in the reference makeup image being lighter than the color of the non-highlight area, resulting in the makeup color of the migrated highlight area being relatively lighter; this method effectively reduces the color difference after makeup migration and improves the visual effect of makeup migration.
[0052] Embodiment three:
[0053] exist Figure 2 Based on the image processing method shown, this embodiment also provides another image processing method, which focuses on describing the specific implementation method of the above-mentioned step S204 (extracting the makeup brightness information of the made-up area and the makeup color information of the partial image area in the made-up area).
[0054] See also Figure 3 , which is a flow chart of another image processing method, wherein the method comprises the following steps:
[0055] Step S302: obtaining a makeup-to-be-applied area of the makeup-to-be-applied image and a makeup-applied area corresponding to the makeup-to-be-applied area of the makeup-to-be-applied image in the reference makeup image.
[0056] Step S302 in this embodiment corresponds to step S202 in the above embodiment. For the description of the corresponding contents, reference may be made to the corresponding parts of the above embodiment, which will not be described in detail here.
[0057] Step S304: extracting the brightness channel value of each pixel in the makeup area to obtain makeup brightness information.
[0058] In actual operation, the reference makeup image is more commonly an RGB color mode image, so the segmented makeup area is also in RGB color mode. In order to obtain the brightness and color information of the image, the makeup area can be converted to the Lab color space, and then the brightness channel information of the pixels in the makeup area can be extracted from the Lab color space. Among them, the Lab color space is a color mode, which consists of three elements, one element is brightness (L), and a and b are two color channels. The colors included in a are from dark green (low brightness value) to gray (medium brightness value) to bright pink (high brightness value); b is from bright blue (low brightness value) to gray (medium brightness value) to yellow (high brightness value).
[0059] For the makeup area in the Lab color space, each pixel in the makeup area corresponds to a brightness channel (L) and a color channel (a and b). Here, the brightness information of the makeup area is the brightness information of the makeup area, and the extracted brightness channel value of each pixel in the makeup area is the makeup brightness information used to adjust the brightness of the makeup area.
[0060] Step S306: Filter out image regions where the brightness channel values of pixels are lower than the target brightness threshold from the makeup-applied region to obtain a first image.
[0061] In one possible implementation manner, the target brightness threshold is obtained through the following steps 11-14:
[0062] (11) Obtain the brightness channel value of each pixel in the makeup area.
[0063] The L component in the Lab color space is used to represent the brightness of the pixel, and its value range is [0,100], which means from pure black to pure white; a represents the range from red to green, and its value range is [127,-128]; b represents the range from yellow to blue, and its value range is [127,-128]. In actual operation, for example, when converting an image from RGB color space to Lab color space in OpenCV (Python), OpenCV maps the L, a, and b parameters of the image as follows:
[0064] L←L*255 / 100
[0065] a←a+128
[0066] b←b+128
[0067] The data is quantized through the above mapping process, so that the three parameters L, a, and b are all in the range of 0-255.
[0068] (12) Calculate the probability of occurrence of each brightness channel value in the makeup area; wherein the probability of occurrence is the ratio of the number of pixels in the makeup area whose brightness is the brightness channel value to the total number of pixels in the makeup area.
[0069] For example, assuming that the total number of pixels in the makeup area is 1000, and the brightness channel values L of all pixels are between 0, 10, 50, 100, and 200, if there are 200 pixels with a brightness channel value of 10, then the corresponding occurrence probability is 200 / 1000, or 20%. Similarly, the occurrence probabilities of other brightness channel values can be deduced.
[0070] (13) Select brightness channel values one by one in order from low brightness to high brightness, and perform cumulative integration on the occurrence probability corresponding to the selected brightness channel value until the cumulative probability obtained by the cumulative integration reaches a preset probability threshold.
[0071] Still using the above example, assuming that the probability of the pixels corresponding to the brightness channel values of 0, 50, 100, and 200 are 5%, 15%, 35%, and 25% respectively. Then the brightness channel values are sorted from low brightness to high brightness, and the process of calculating the cumulative probability is shown in the following table:
[0072]
[0073]
[0074] Assuming the preset probability is 50%, when the brightness channel value 100 is selected one by one in order from low brightness to high brightness, the cumulative probability is 75%, which exceeds 50%. At this time, the selection of brightness channel values is stopped, and the cumulative integral calculation of the occurrence probability is no longer continued.
[0075] (14) The brightness channel value corresponding to the last occurrence probability participating in the cumulative integration is determined as the target brightness threshold.
[0076] In the above example, the brightness channel value corresponding to the last occurrence probability participating in the cumulative integration is 100, and therefore, 100 is the target brightness threshold in this example.
[0077] Step S308: extracting the color channel value of each pixel of the first image to obtain makeup color information.
[0078] The color channel value of each pixel is the value of the a parameter and the b parameter corresponding to each pixel.
[0079] Step S310: applying makeup to the makeup area based on the makeup color information and the makeup brightness information.
[0080] In at least one possible implementation, the color of the area to be made up can be adjusted based on the makeup color information, and the brightness of the area to be made up can be adjusted based on the makeup brightness information to obtain an image of the area to be made up after makeup processing, that is, a target image.
[0081] In this embodiment, the area to be made up is first converted to the Lab color space, and then the color and brightness of the area to be made up are adjusted in the Lab color space. Specifically, the area to be made up is first subjected to histogram matching based on the makeup color information to obtain a matched image. Among them, histogram matching refers to an image enhancement method that converts the histogram of an image into a histogram of a specified shape (such as the histogram of a matching object). That is, the histogram of an image or an area is matched to another image, so that the tones of the two images are consistent. It can match between single-band image histograms, and can also match multi-band images simultaneously.
[0082] Then, the color channel value of each pixel of the matched image is determined as the color channel value of the target image. Secondly, based on the makeup brightness information and the brightness channel information of the area to be made up, the brightness channel value of each pixel of the target image is determined. Specifically, based on the makeup brightness information, the average value of the brightness channel value of each pixel in the area with makeup applied is calculated to obtain a first brightness mean value; the average value of the brightness channel value of each pixel in the area to be made up is calculated to obtain a second brightness mean value; and then the brightness channel value of each pixel of the target image is determined based on the first brightness mean value, the second brightness mean value and the brightness channel value of each pixel in the area to be made up.
[0083] Here, the brightness channel value of each pixel of the target image is calculated by a preset mean transformation formula; wherein the mean transformation formula is:
[0084] S di-l =S si-l -u s +u r .
[0085] In the formula, S si-l is the brightness channel value of pixel i in the area to be made up; S di-l is the brightness channel value of pixel i of the target image; u r is the first average brightness of each pixel in the makeup area; s is the second brightness average of each pixel in the area to be made-up.
[0086] Finally, the target image is determined according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image. According to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image, the color channel and brightness channel of each pixel in the target image are spliced in units of pixels to obtain the target image. Here, for the image in the Lab color space, each pixel corresponds to three channels: L channel, a channel and b channel, wherein the L channel is the brightness channel, and the a channel and the b channel are both color channels. The pixels of the above target image can be selected in units of pixels, and the L channel, a channel and b channel of the selected pixels are spliced until all pixels complete the above splicing operation to obtain the target image. Here, the target image is the target makeup image.
[0087] In this embodiment, since the initial color space of the image to be made-up is the RGB color space, it is necessary to convert the target image from the Lab color space back to the RGB color space, so as to obtain the image of the area to be made-up after the makeup is processed.
[0088] The image processing method provided in this embodiment processes the makeup image to be applied in the Lab color space, wherein the brightness channel of the target makeup image is calculated by a mean transformation, and the color channel of the target makeup image is calculated by a histogram matching method, and then the target makeup image is obtained by splicing the brightness channel and the color channel to achieve makeup. Through the processing of the above steps, since the highlight area is deleted from the makeup area of the reference makeup image and then the histogram matching is performed, the color difference of the target makeup image after makeup is reduced; in addition, since the mean of the brightness channel of the target makeup image is consistent with the reference makeup image, its overall color is closer to the reference makeup area, and the variance of the brightness channel of the target makeup image is consistent with the variance of the brightness channel of the image to be applied, thereby retaining the light and dark distribution characteristics in the image to be applied, thereby further improving the makeup migration effect.
[0089] Embodiment 4:
[0090] In order to more clearly understand the image processing method provided by this embodiment, an application example is introduced below, wherein the application example is a scenario of transferring lipstick makeup to the mouth. The steps are as follows:
[0091] (31) Perform image segmentation on the source image S (Sourse) and the reference image R (Reference) to obtain the lipstick area S of the source image and the reference image lip and R lip Here, S lip Corresponding to the makeup area in the above embodiment, R lip Corresponding to the makeup-applied area in the above embodiment.
[0092] (32) The lipstick area S of the source image lip and the lipstick area R of the reference image lip Convert from RGB color space to Lab color space to get S lip-lab and R lip-lab .
[0093] (33) Filter the highlight area of the lipstick part of the reference image (because the highlight does not reflect the lipstick color that you want to migrate). Suppose the probability function of the lipstick area of the reference image on the L channel is:
[0094] f x (i) = p(x = i) = n i / n 0≤i <L。
[0095] Where L is the number of all possible grayscales in the lipstick area of the reference image (usually L = 256), n is the number of all pixels in the lipstick area, and n i Indicates the number of times gray level i appears. x (i) That is, the histogram on the L channel, normalized to [0,1].
[0096] Calculate the cumulative probability distribution (i.e., cumulative normalized histogram) of the lipstick area of the reference image on the L channel as follows:
[0097]
[0098] Find the color threshold c corresponding to the set threshold th(threshold) when the cumulative probability is equal to the set threshold th(threshold).
[0099]
[0100] Filter out the area in the lipstick area of the reference image where the L channel value is lower than the color threshold c (the area where the L channel value is higher than the color threshold c is the highlight area) to obtain the lipstick dark area R lip-th Here, R lip-th That is, it corresponds to the matching result image in the above embodiment.
[0101] (34) To S lip-lab and R lip-th Perform histogram matching to obtain S lip-his Here, S lip-his The color channel value of each pixel in is the color channel value of each pixel of the target makeup image.
[0102] (35) Take S respectively lip-lab L channel S lip-l The mean and R lip-lab L channel R lip-l The mean of us and u r , S lip-lab The mean brightness of the L channel is given by u s Transform to u r :
[0103] S matchi-l =S lipi-l -u s +u r .
[0104] Here, S matchi-l That is, it corresponds to the brightness channel value of pixel i in the target makeup image, S lipi-l It corresponds to the brightness channel value of pixel i in the makeup image.
[0105] (36) S match and S lip-his The a channel and b channel of the splicing are spliced to obtain the splicing result S lip-concat .
[0106] Among them, the splicing result S lip-concat The a channel and b channel of the image are obtained by histogram matching, and the L channel is obtained by mean transformation. The significance of using mean transformation for the L channel is that the light and dark changes (variance) of the source image can be retained after migration, and at the same time, the mean is consistent with the reference image, that is, the lipstick color is consistent with the lipstick color in the reference image. Here, if the L channel is also obtained by histogram matching like the a channel and the b channel (that is, the existing method of directly performing histogram matching), the mean and variance of the image after migration are consistent with the reference image. However, since the highlight area of the lipstick part of the reference image is filtered in the above step 32, the image after migration will lose the highlight area of the source image. In order to avoid the above problems, in this embodiment, the processing method of mean transformation is adopted for the L channel.
[0107] (37) Convert the splicing result from RGB color space to Lab color space to obtain the final migration result S lip-trans .
[0108] In this way, the lipstick makeup in the reference image is transferred to the source image, and the virtual makeup of lipstick makeup transfer is realized. In this embodiment, after the lipstick area of the reference image is screened, histogram matching is performed, which can effectively reduce the color difference between the lipstick area of the matched image and the reference image; by performing mean transformation on the L channel of the source image and then splicing it with the a channel and b channel of the matched image, the highlight area of the source image can be effectively retained. By combining the two, the lipstick color difference of the transferred image can be small and the color is accurate compared with the reference image; compared with the source image, the highlight of the source image can still be well preserved in the transferred image.
[0109] Embodiment five:
[0110] Corresponds to Figure 1 The image processing method shown in the embodiment of the present invention also provides an image processing device, such as Figure 4 As shown, it is a structural schematic diagram of an image processing device. Figure 4 It can be seen that the device includes a region acquisition module 41, an information extraction module 42 and a makeup processing module 43 which are connected in sequence, wherein the functions of each module are as follows:
[0111] The region acquisition module 41 is used to acquire the to-be-made-up region of the to-be-made-up image and the made-up region corresponding to the to-be-made-up region of the to-be-made-up image in the reference makeup image;
[0112] An information extraction module 42 is used to extract makeup brightness information of the makeup area and makeup color information of a partial image area in the makeup area; wherein the brightness of the partial image area in the makeup area is lower than a target brightness threshold;
[0113] The makeup processing module 43 is used to perform makeup processing on the area to be made up based on the makeup color information and the makeup brightness information.
[0114] An image processing device provided by an embodiment of the present invention obtains a makeup-to-be-applied area of a makeup-to-be-applied image and a makeup-applied area corresponding to the makeup-to-be-applied area of the makeup-to-be-applied image in a reference makeup image; extracts makeup brightness information of the makeup-applied area and makeup color information of a portion of the image area in the makeup-applied area; wherein the brightness of the portion of the image area in the makeup-applied area is lower than a target brightness threshold; and performs makeup processing on the makeup-to-be-applied area based on the makeup color information and the makeup brightness information. In the device, makeup color information and makeup brightness information for applying makeup to the makeup-to-be-applied area of the makeup-to-be-applied image are extracted separately, wherein makeup color information is extracted from an image area lower than the target brightness threshold in the makeup-applied area corresponding to the reference makeup image, thereby alleviating the problem of obvious color difference caused by the makeup color of the highlight area in the reference makeup image being lighter than the color of the non-highlight area, resulting in the makeup color of the migrated highlight area being relatively lighter; the method effectively reduces the color difference after makeup migration and improves the visual effect of makeup migration.
[0115] In one possible implementation, the information extraction module 42 is further used to: extract the brightness channel value of each pixel in the made-up area to obtain makeup brightness information; filter out image areas in the made-up area where the brightness channel value of pixels is lower than a target brightness threshold to obtain a first image; extract the color channel value of each pixel in the first image to obtain makeup color information.
[0116] In another possible implementation, the information extraction module 42 is also used to: obtain the brightness channel value of each pixel in the made-up area; calculate the occurrence probability of each brightness channel value in the made-up area; wherein the occurrence probability is the ratio of the number of pixels in the made-up area whose brightness is the brightness channel value to the total number of pixels in the made-up area; select brightness channel values one by one in order from low brightness to high brightness, and accumulate and integrate the occurrence probabilities corresponding to the selected brightness channel values until the accumulated probability obtained by the accumulated integration reaches a preset probability threshold; and determine the last brightness channel value corresponding to the occurrence probability participating in the accumulated integration as the target brightness threshold.
[0117] In another possible implementation, the makeup processing module 43 is further used to adjust the color of the area to be made-up based on the makeup color information, and adjust the brightness of the area to be made-up based on the makeup brightness information, so as to obtain an image of the area to be made-up after makeup processing.
[0118] In another possible implementation, the makeup processing module 43 is further used to: perform histogram matching on the area to be made-up based on the makeup color information to obtain a matched image; determine the color channel value of each pixel of the matched image as the color channel value of the target image; determine the brightness channel value of each pixel of the target image based on the makeup brightness information and the brightness channel information of the area to be made-up; determine the target image according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image.
[0119] In another possible implementation, the makeup processing module 43 is further used to: calculate the average value of the brightness channel values of each pixel in the makeup-applied area based on the makeup brightness information to obtain a first brightness average; calculate the average value of the brightness channel values of each pixel in the area to be made-up to obtain a second brightness average; determine the brightness channel values of each pixel of the target image based on the first brightness average, the second brightness average and the brightness channel values of each pixel in the area to be made-up.
[0120] In another possible implementation, the makeup processing module 43 is further used to calculate the brightness channel value of each pixel of the target image by a preset mean value transformation formula according to the first brightness mean value, the second brightness mean value and the brightness channel value of each pixel of the area to be made up; wherein the mean value transformation formula is: S di-l =S si-l -u s +u r , where S si-l is the brightness channel value of pixel i in the area to be made up; S di-l is the brightness channel value of pixel i of the target image; u sis the first average brightness of each pixel in the makeup area; r is the second brightness average of each pixel in the area to be made-up.
[0121] In another possible implementation, the makeup processing module 43 is also used to: based on the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image, in units of pixels, splice the color channel and brightness channel of each pixel in the target image to obtain the target image.
[0122] The image processing device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned image processing method embodiment. For the sake of brief description, for parts not mentioned in the embodiment of the image processing device, reference may be made to the corresponding contents in the aforementioned image processing method embodiment.
[0123] An embodiment of the present invention provides an electronic system, which includes: an image acquisition device, a processing device and a storage device; the image acquisition device is used to obtain preview video frames or image data; a computer program is stored on the storage device, and the computer program executes the steps of the above-mentioned image processing method when the processed device is running.
[0124] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the electronic system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0125] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processing device, the steps of the above-mentioned image processing method are executed.
[0126] The computer program products of the image processing methods, devices, and electronic systems provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0128] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0129] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0130] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0131] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. An image processing method, It is characterized in that include: Acquire a makeup-to-be-applied area of the makeup-to-be-applied image and a makeup-applied area corresponding to the makeup-to-be-applied area of the makeup-to-be-applied image in the reference makeup image; Extracting makeup brightness information of the makeup-applied area and makeup color information of a partial image area in the makeup-applied area; wherein the brightness of the partial image area in the makeup-applied area is lower than a target brightness threshold; Based on the makeup color information and the makeup brightness information, makeup processing is performed on the area to be made up.
2. The method according to claim 1, It is characterized in that The step of extracting makeup brightness information of the makeup-applied area and makeup color information of a partial image area in the makeup-applied area comprises: Extracting the brightness channel value of each pixel in the makeup area to obtain makeup brightness information; Filtering out image regions where pixel brightness channel values are lower than a target brightness threshold from the makeup-applied region to obtain a first image; The color channel value of each pixel of the first image is extracted to obtain makeup color information.
3. The method according to claim 2, It is characterized in that The target brightness threshold is determined in the following manner: Obtaining a brightness channel value of each pixel in the makeup-applied area; Calculating the occurrence probability of each brightness channel value in the makeup area; wherein the occurrence probability is the ratio of the number of pixels in the makeup area whose brightness is the brightness channel value to the total number of pixels in the makeup area; Selecting brightness channel values one by one in order from low brightness to high brightness, and cumulatively integrating the occurrence probabilities corresponding to the selected brightness channel values until the cumulative probability obtained by the cumulative integration reaches a preset probability threshold; The brightness channel value corresponding to the last occurrence probability participating in the cumulative integration is determined as the target brightness threshold.
4. The method according to claim 2, It is characterized in that The step of applying makeup to the area to be applied with makeup based on the makeup color information and the makeup brightness information comprises: The color of the area to be made-up is adjusted based on the makeup color information, and the brightness of the area to be made-up is adjusted based on the makeup brightness information, so as to obtain an image of the area to be made-up after makeup processing.
5. The method according to claim 4, It is characterized in that The step of adjusting the color of the area to be made-up based on the makeup color information, adjusting the brightness of the area to be made-up based on the makeup brightness information, and obtaining an image of the area to be made-up after makeup processing includes: Performing histogram matching processing on the area to be made up based on the makeup color information to obtain a matched image; Determine the color channel value of each pixel of the matched image as the color channel value of the target image; the target image is the image of the area to be made-up after the makeup process; Determining a brightness channel value of each pixel of the target image based on the makeup brightness information and the brightness channel information of the area to be made up; The target image is determined according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image.
6. The method according to claim 5, It is characterized in that The step of determining the brightness channel value of each pixel of the target image based on the makeup brightness information and the brightness channel information of the area to be made up includes: Based on the makeup brightness information, calculating an average value of brightness channel values of each pixel in the makeup area to obtain a first brightness average value; Calculating an average value of the brightness channel values of each pixel in the area to be made up to obtain a second brightness average value; The brightness channel value of each pixel of the target image is determined according to the first brightness mean value, the second brightness mean value, and the brightness channel value of each pixel of the area to be made up.
7. The method according to claim 6, It is characterized in that The step of determining the brightness channel value of each pixel of the target image according to the first brightness mean value, the second brightness mean value and the brightness channel value of each pixel of the area to be made-up, comprises: Calculating the brightness channel value of each pixel of the target image by a preset mean value transformation formula according to the first brightness mean value, the second brightness mean value and the brightness channel value of each pixel of the area to be made up; Wherein, the mean transformation formula is: WITH di-l =S si-l -in s +in r In the formula, S si-l is the brightness channel value of the pixel i in the area to be made up; S di-l is the brightness channel value of pixel i of the target image; u r is the first brightness average of each pixel in the makeup area; s is the second brightness average of each pixel in the area to be made-up.
8. The method according to claim 5, It is characterized in that The step of determining the target image according to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image comprises: According to the color channel value of each pixel of the target image and the brightness channel value of each pixel of the target image, the color channel and the brightness channel of each pixel in the target image are spliced in units of pixels to obtain the target image.
9. The method according to claim 1, It is characterized in that The step of obtaining the area to be made-up of the image to be made-up and the made-up area corresponding to the area to be made-up of the image to be made-up in the reference makeup image comprises: By using an image segmentation algorithm or a facial key point detection algorithm, a region to be made up is segmented from the image to be made up, and a made-up region corresponding to the region to be made up is segmented from the reference makeup image.
10. An image processing device, It is characterized in that include: An area acquisition module, used to acquire a makeup-to-be-applied area of the makeup-to-be-applied image and an already-applied makeup area corresponding to the makeup-to-be-applied area of the makeup-to-be-applied image in the reference makeup image; An information extraction module, used to extract makeup brightness information of the makeup area and makeup color information of a partial image area in the makeup area; wherein the brightness of the partial image area in the makeup area is lower than a target brightness threshold; A makeup processing module is used to perform makeup processing on the area to be made up based on the makeup color information and the makeup brightness information.
11. An electronic system, It is characterized in that The electronic system includes: a processing device and a storage device; The storage device stores a computer program, which, when executed by the processing device, executes the image processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the image processing method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Image processing method, device, computer device and storage medium
CN108509846A
A complex makeup migration method based on facial analysis and illumination migration
CN109949216A
Image processing method and device based on makeup template, storage medium and terminal
CN110390632A
Virtual makeup trying method and device, equipment and image processing method
CN110728618A
Image processing method and electronic equipment
CN111047511A
