An image processing method and apparatus

By acquiring target features and reference features, and using the migration matrix to control the fusion of reference features and target features, the problem of being unable to control the migration effect in the prior art is solved, and users can adjust the migration effect.

CN115294618BActive Publication Date: 2026-03-17BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-19
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In existing technologies, image feature transfer methods cannot support user control over the transfer effect, and users cannot adjust the degree of integration of facial makeup in the reference image into the target image according to their needs.

Method used

By acquiring target features and reference features, and using a transfer matrix to control the reference features to fuse with the target features with specified weights, a transfer result image is generated.

Benefits of technology

This technology enables users to control the migration effect, allowing them to adjust the fusion intensity of reference features in the target image according to their needs, thus solving the problem of the inability to control the migration effect in existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115294618B_ABST
    Figure CN115294618B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an image processing method and device, and relate to the technical field of image processing. The method comprises: obtaining a target feature and a reference feature; the target feature is a feature obtained by performing feature extraction on a target object in a target image, and the reference feature is a feature obtained by performing feature extraction on a reference object in a reference image; obtaining a transfer matrix, the transfer matrix being used to control the reference feature to be fused with the target feature with a specified weight; fusing the target feature and the reference feature according to the transfer matrix to obtain a fused feature; and generating a transfer result image according to the fused feature and the target image. Embodiments of the present application are used to solve the problem that the image feature transfer mode in the prior art does not support user control of the transfer effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an image processing method and apparatus. Background Technology

[0002] Currently, image feature transfer has become one of the most popular techniques in the field of image processing. Image feature transfer refers to the process of transferring features of a reference object from a reference image to a target image, and then fusing the features of the reference object with the features of the target object in the target image to generate a transferred result image. For example, makeup transfer in image feature transfer involves transferring facial makeup features from a reference image to the target image and fusing them with the features of a human face in the target image to obtain a transferred result image in which makeup is applied to a human face in the target image based on the facial makeup in the reference image.

[0003] In existing technologies, the main approach to image feature transfer is to input a reference image containing the reference object and a target image containing the target object into a pre-trained image transfer model, and then obtain the output of the feature fusion model as the transfer result image. While this existing method can achieve image feature transfer, users cannot control the transfer effect in the result image. For example, in a makeup transfer scenario, if a user feels the makeup in the reference image is too heavy, their need might not be to completely transfer the makeup from the reference image to the target face in the target image, but rather to transfer it to a certain extent. However, in existing image feature transfer methods, given a reference image and a target image, a fixed transfer result image is obtained, without allowing users to control the transfer effect to transfer the makeup from the reference image to the target face. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide an image processing method and apparatus to solve the problem that existing image feature transfer methods do not support user control over the transfer effect.

[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0006] In a first aspect, embodiments of the present invention provide an image processing method, comprising:

[0007] Obtain target features and reference features; the target features are features obtained by feature extraction of the target object in the target image, and the reference features are features obtained by feature extraction of the reference object in the reference image;

[0008] Obtain a transfer matrix, which is used to control the reference features to fuse with the target features with specified weights;

[0009] The target feature and the reference feature are fused according to the migration matrix to obtain the fused feature;

[0010] A migration result image is generated based on the fusion features and the target image.

[0011] As an optional implementation of this invention, the acquisition of the target feature and the reference feature includes:

[0012] Obtain a first region and a second region, wherein the first region is the region corresponding to the target object in the target image, and the second region is the region corresponding to the reference object in the reference image;

[0013] Based on the first region, feature extraction is performed on the target image to obtain the target features;

[0014] The reference image is subjected to feature extraction based on the second region to obtain the reference features.

[0015] As an optional implementation of this invention, obtaining the first region and the second region includes:

[0016] Obtain the first grayscale image and the second grayscale image;

[0017] In this image, pixels in the first grayscale image correspond one-to-one with pixels in the target image via pixel coordinates. The grayscale value of the pixel in the first grayscale image corresponding to a pixel within the first region is a first grayscale value, and the grayscale value of the pixel in the first grayscale image corresponding to a pixel outside the first region is a second grayscale value. Similarly, pixels in the second grayscale image correspond one-to-one with pixels in the reference image via pixel coordinates. The grayscale value of the pixel in the second grayscale image corresponding to a pixel within the second region is a first grayscale value, and the grayscale value of the pixel in the second grayscale image corresponding to a pixel outside the second region is a second grayscale value.

[0018] As an optional implementation of this invention, the step of extracting features from the target image based on the first region to obtain the target features includes:

[0019] The target image and the first grayscale image are input into the feature extraction model, and the output of the feature extraction model is obtained as the target feature.

[0020] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0021] As an optional implementation of this invention, the step of extracting features from the reference image based on the second region to obtain the reference features includes:

[0022] The reference image and the second grayscale image are input into the feature extraction model, and the output of the feature extraction model is obtained as the reference feature.

[0023] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0024] As an optional implementation of this invention, obtaining the migration matrix includes:

[0025] Obtain the weight parameters, which are used to characterize the specified weights;

[0026] The transfer matrix is ​​obtained based on the weight parameters and the pre-training matrix;

[0027] The pre-trained matrix is ​​a matrix obtained by training a preset matrix based on the second sample data. The second sample data includes: first sample features, second sample features, and sample fusion features corresponding to the first sample features and the second sample features.

[0028] As an optional implementation of this invention, obtaining the weight parameters includes:

[0029] Display a first interface, the first interface including an input control for inputting the weight parameters;

[0030] In response to the user's operation on the input control, the weight parameter is obtained.

[0031] As an optional implementation of this invention, generating a migration result image based on the fusion features and the target image includes:

[0032] The fused features and the target image are input into the feature fusion model, and the output of the feature fusion model is obtained as the transfer result image;

[0033] The feature fusion model is a model obtained by training the second network model based on the third sample data; the third sample data includes: sample images, sample fusion features, and sample transfer result images corresponding to the sample images and the sample fusion features.

[0034] As an optional implementation of the present invention, the target feature is the facial feature obtained by feature extraction of the face to be made up in the target image, and the reference feature is the makeup feature obtained by feature extraction of the makeup to be transferred in the reference image.

[0035] In a second aspect, embodiments of the present invention provide an image processing apparatus, comprising:

[0036] The first acquisition unit is used to acquire target features and reference features; the target features are features obtained by feature extraction of a target object in a target image, and the reference features are features obtained by feature extraction of a reference object in a reference image;

[0037] The second acquisition unit is used to acquire a transfer matrix; the transfer matrix is ​​used to control the reference features to fuse with the target features with specified weights;

[0038] The processing unit fuses the target feature and the reference feature according to the migration matrix to obtain the fused feature;

[0039] The generation unit is used to generate a migration result image based on the fusion features and the target image.

[0040] As an optional implementation of this invention, the first acquisition unit is specifically used to acquire a first region and a second region, wherein the first region is the region corresponding to the target object in the target image, and the second region is the region corresponding to the reference object in the reference image; the first region is used to extract features from the target image to acquire the target features; and the second region is used to extract features from the reference image to acquire the reference features.

[0041] As an optional implementation of the present invention, the first acquisition unit is specifically used to acquire a first grayscale image and a second grayscale image;

[0042] In this image, pixels in the first grayscale image correspond one-to-one with pixels in the target image via pixel coordinates. The grayscale value of the pixel in the first grayscale image corresponding to a pixel within the first region is a first grayscale value, and the grayscale value of the pixel in the first grayscale image corresponding to a pixel outside the first region is a second grayscale value. Similarly, pixels in the second grayscale image correspond one-to-one with pixels in the reference image via pixel coordinates. The grayscale value of the pixel in the second grayscale image corresponding to a pixel within the second region is a first grayscale value, and the grayscale value of the pixel in the second grayscale image corresponding to a pixel outside the second region is a second grayscale value.

[0043] As an optional implementation of this invention, the first acquisition unit is specifically used to input the target image and the first grayscale image into a feature extraction model, and acquire the output of the feature extraction model as the target feature;

[0044] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0045] As an optional implementation of the present invention, the first acquisition unit is specifically used to input the reference image and the second grayscale image into the feature extraction model, and acquire the output of the feature extraction model as the reference feature;

[0046] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0047] As an optional implementation of this invention, the second acquisition unit is specifically used to acquire weight parameters; and acquire the transfer matrix based on the weight parameters and the pre-training matrix.

[0048] The weight parameter is used to characterize the specified weight, and the pre-trained matrix is ​​a matrix obtained by training a preset matrix based on the second sample data. The second sample data includes: a first sample feature, a second sample feature, and a sample fusion feature corresponding to the first sample feature and the second sample feature.

[0049] As an optional implementation of this invention, the second acquisition unit is specifically used to display a first interface, the first interface including an input control for inputting the weight parameters; and to acquire the weight parameters in response to the user's operation on the input control.

[0050] As an optional implementation of this invention, the generation unit is specifically used to input the fused features and the target image into a feature fusion model, and obtain the output of the feature fusion model as the migration result image;

[0051] The feature fusion model is a model obtained by training the second network model based on the third sample data; the third sample data includes: sample images, sample fusion features, and sample transfer result images corresponding to the sample images and the sample fusion features.

[0052] As an optional implementation of the present invention, the target feature is the facial feature obtained by feature extraction of the face to be made up in the target image, and the reference feature is the makeup feature obtained by feature extraction of the makeup to be transferred in the reference image.

[0053] Thirdly, embodiments of the present invention provide an electronic device, including: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to cause the electronic device to implement the image processing method described in any of the above embodiments when the computer program is invoked.

[0054] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a computing device, causes the computing device to implement the image processing method described in any of the above embodiments.

[0055] Fifthly, embodiments of the present invention provide a computer program product that, when run on a computer, enables the computer to implement the image processing method described in any of the above embodiments.

[0056] The image processing method provided in this embodiment of the invention first extracts features from the target object in the target image and the reference object in the reference image to obtain target features and reference features. Then, it obtains a migration matrix that can control the reference features to fuse with the target features with specified weights. Next, it fuses the target features and the reference features according to the migration matrix to obtain fused features. Finally, it generates a migration result image based on the fused features and the target image. Since the image processing method provided in this embodiment of the invention can obtain target features and reference features, and fuse the target features and the reference features according to the migration matrix, and since the migration matrix can control the reference features to fuse with the target features with specified weights, this embodiment of the invention can control the weight of the reference features when fusing the target features and the reference features by obtaining different migration matrices, thereby controlling the strength of the effect of the reference features on the fused features. This allows for control of the migration effect of the migration result image. Therefore, this embodiment of the invention can support user control over the migration effect, solving the problem that users cannot control the migration effect. Attached Figure Description

[0057] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1 This is one of the scene architecture diagrams for the makeup transfer method provided in an embodiment of the present invention;

[0060] Figure 2 The second schematic diagram of the scene architecture for the makeup transfer method provided in the embodiments of the present invention;

[0061] Figure 3 This is one of the flowcharts of the makeup transfer method provided in the embodiments of the present invention;

[0062] Figure 4 This is the second flowchart of the makeup transfer method provided in the embodiments of the present invention;

[0063] Figure 5 A schematic diagram of an image processing apparatus provided in an embodiment of the present invention;

[0064] Figure 6 A schematic diagram of another image processing apparatus provided in an embodiment of the present invention;

[0065] Figure 7 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0066] To better understand the above-mentioned objectives, features, and advantages of the present invention, the solutions of the present invention will be further described below. It should be noted that, unless otherwise specified, the embodiments of the present invention and the features thereof can be combined with each other.

[0067] Many specific details are set forth in the following description in order to provide a full understanding of the invention, but the invention may also be practiced in other ways different from those described herein; obviously, the embodiments in the specification are only some embodiments of the invention, and not all embodiments.

[0068] In the embodiments of the present invention, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner. Furthermore, in the description of the embodiments of the present invention, unless otherwise stated, "a plurality of" means two or more.

[0069] Based on the above, this embodiment of the invention provides an image processing method, referring to... Figure 1 As shown, the image processing method includes the following steps:

[0070] S101. Obtain target features and reference features.

[0071] The target feature is the feature obtained by feature extraction of the target object in the target image, and the reference feature is the feature obtained by feature extraction of the reference object in the reference image.

[0072] Optionally, the implementation of obtaining the target features in step S101 above may include the following steps a to c:

[0073] Step a: Obtain the target image.

[0074] Step b: Determine the target object in the target image.

[0075] For example, the target object can be automatically obtained based on an image recognition algorithm, or the target image can be displayed, the user's selection operation on the target object can be received, and the target object can be determined based on the user's selection operation on the target object.

[0076] Step c: Extract features from the target object in the target image to obtain the target features.

[0077] Optionally, the method for obtaining the reference features in step S101 above may include the following steps 1 to 3:

[0078] Step 1: Obtain a reference image.

[0079] Step 2: Determine the reference object in the reference image.

[0080] Similarly, the reference object can be automatically obtained based on an image recognition algorithm, or the reference image can be displayed, the user's selection operation on the reference object can be received, and the target object can be determined based on the user's selection operation on the reference object.

[0081] Step c: Extract features from the reference object in the reference image to obtain the target features.

[0082] Optionally, the target feature is the facial feature obtained by feature extraction of the face to be made up in the target image, and the reference feature is the makeup feature obtained by feature extraction of the makeup to be transferred in the reference image.

[0083] S102, Obtain the migration matrix.

[0084] The migration matrix is ​​used to control the reference features to fuse with the target features with specified weights.

[0085] For example, the specified weight can be 100%, 50%, 30%, etc. This embodiment of the invention does not limit this, and users can set the specified weight according to their needs in actual use.

[0086] S103. The target feature and the reference feature are fused according to the migration matrix to obtain the fused feature.

[0087] S104. Generate a migration result image based on the fusion features and the target image.

[0088] For example, the above step S104 (generating a migration result image based on the fusion feature and the target image) can be implemented as follows: obtain the image corresponding to the fusion feature, and overlay the image corresponding to the fusion feature onto the target object in the target image to generate the migration result image.

[0089] The image processing method provided in this embodiment of the invention first extracts features from the target object in the target image and the reference object in the reference image to obtain target features and reference features. Then, it obtains a migration matrix that can control the reference features to fuse with the target features with specified weights. Next, it fuses the target features and the reference features according to the migration matrix to obtain fused features. Finally, it generates a migration result image based on the fused features and the target image. Since the image processing method provided in this embodiment of the invention can obtain target features and reference features, and fuse the target features and the reference features according to the migration matrix, and since the migration matrix can control the reference features to fuse with the target features with specified weights, this embodiment of the invention can control the weight of the reference features when fusing the target features and the reference features by obtaining different migration matrices, thereby controlling the strength of the effect of the reference features on the fused features. This allows for control of the migration effect of the migration result image. Therefore, this embodiment of the invention can support user control over the migration effect, solving the problem that users cannot control the migration effect.

[0090] As an extension and refinement of the above embodiments, this invention provides another image processing method, referring to... Figure 2 As shown, the image processing method also includes the following steps:

[0091] S201, Obtain the first region and the second region.

[0092] Wherein, the first region is the region corresponding to the target object in the target image, and the second region is the region corresponding to the reference object in the reference image.

[0093] Specifically, when the target feature is the facial feature obtained by feature extraction of the face to be made up in the target image, and the reference feature is the makeup feature obtained by feature extraction of the makeup to be transferred in the reference image, the first region is the region corresponding to the facial features of the face to be made up in the target image, and the second region is the region corresponding to the facial features of the face to which the makeup to be transferred belongs in the reference image.

[0094] Optionally, step S101 (obtaining the first region and the second region) includes:

[0095] Obtain the first grayscale image and the second grayscale image.

[0096] In this image, pixels in the first grayscale image correspond one-to-one with pixels in the target image via pixel coordinates. The grayscale value of the pixel in the first grayscale image corresponding to a pixel within the first region is a first grayscale value, and the grayscale value of the pixel in the first grayscale image corresponding to a pixel outside the first region is a second grayscale value. Similarly, pixels in the second grayscale image correspond one-to-one with pixels in the reference image via pixel coordinates. The grayscale value of the pixel in the second grayscale image corresponding to a pixel within the second region is a first grayscale value, and the grayscale value of the pixel in the second grayscale image corresponding to a pixel outside the second region is a second grayscale value.

[0097] For example, refer to Figure 3 As shown, Figure 3 The example shown uses the facial features of a person in the target image as the target object. Figure 3 As shown in (a), the target object is the facial features of the person in the target image 31. The grayscale image corresponding to the target image 31 is shown in (b) of 3. The pixels in the grayscale image 32 correspond one-to-one with the pixels in the target image 31 through pixel coordinates. The grayscale value of the pixels in the grayscale image 32 that correspond to the area where the facial features of the person in the target image 31 are located is 255, while the grayscale value of the pixels in the grayscale image 32 that correspond to the area outside the area where the facial features of the person in the target image 31 are located is 0.

[0098] S202. Extract features from the target image based on the first region to obtain the target features.

[0099] As an optional implementation of this invention, when the region corresponding to the target object in the target image is represented by a first grayscale image, the above step S202 (extracting features from the target image based on the first region to obtain the target features) can be implemented in the following ways:

[0100] The target image and the first grayscale image are input into the feature extraction model, and the output of the feature extraction model is obtained as the target feature.

[0101] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0102] S203. Extract features from the reference image based on the second region to obtain the reference features.

[0103] It should be noted that the order in which steps S202 and S203 are executed is not limited in the embodiments of the present invention. Step S202 can be executed first and then step S203, or step S203 can be executed first and then step S202, or steps S202 and S203 can be executed simultaneously.

[0104] As an optional implementation of this invention, when the region corresponding to the reference object in the reference image is represented by the second grayscale image, the above step S203 (extracting features from the reference image based on the second region to obtain the reference features) may include:

[0105] The reference image and the second grayscale image are input into the feature extraction model, and the output of the feature extraction model is obtained as the reference feature.

[0106] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0107] In the above embodiments, when extracting target features and reference features, the regions corresponding to the target object in the target image and the regions corresponding to the reference object in the reference image are first obtained. Then, feature extraction is performed on the target image based on the first region to obtain the target features, and feature extraction is performed on the reference image based on the second region to obtain the reference features. Therefore, the above embodiments can accurately extract target features and reference features, avoiding the mismatch between the actual extracted features and the desired extracted features due to morphological differences between the target object and the reference object, thereby improving the robustness of the image processing method provided by the embodiments of the present invention.

[0108] S204. Obtain the weight parameters.

[0109] The weight parameter is used to characterize the specified weight.

[0110] Optionally, the implementation of S204 (obtaining weight parameters) may include the following steps:

[0111] Step 1: Display a first interface, which includes an input control for inputting the weight parameters;

[0112] Step II: In response to the user's operation on the input control, obtain the weight parameters.

[0113] For example, refer to Figure 4As shown, the first interface includes the prompt "Please enter the weight parameters" and an input control 400 for entering the weight parameters. Users can enter the weight parameters by dragging the slider in the input control 400.

[0114] S205. Obtain the transfer matrix based on the weight parameters and the pre-training matrix.

[0115] The pre-trained matrix is ​​a matrix obtained by training a preset matrix based on the second sample data. The second sample data includes: first sample features, second sample features, and sample fusion features corresponding to the first sample features and the second sample features.

[0116] For example, when training a pre-trained matrix, the sample fusion feature in the sample data used can be a feature obtained by fusing the second sample feature with the first sample feature with 100% weight.

[0117] S206. The target feature and the reference feature are fused according to the migration matrix to obtain the fused feature.

[0118] S207. Input the fused features and the target image into the feature fusion model, and obtain the output of the feature fusion model as the transfer result image.

[0119] The feature fusion model is a model obtained by training the second network model based on the third sample data; the third sample data includes: sample images, sample fusion features, and sample transfer result images corresponding to the sample images and the sample fusion features.

[0120] Furthermore, refer to Figure 5 As shown, in Figure 2 Based on the image processing method shown, the image processing method provided in this embodiment of the invention includes the following steps:

[0121] The target image and the first grayscale image are input into the feature extraction model to obtain the target features.

[0122] Input the reference image and the second grayscale image into the feature extraction model to obtain the reference features.

[0123] The target features and reference features are fused based on the transfer matrix to obtain the fused features.

[0124] Input the target features and fused features into the feature fusion model to obtain the transfer result image.

[0125] Based on the same inventive concept, as an implementation of the above method, this embodiment of the invention also provides an image processing device. This device embodiment corresponds to the aforementioned method embodiment. For ease of reading, this device embodiment will not repeat the details of the aforementioned method embodiment one by one, but it should be clear that the image processing device in this embodiment can correspondingly implement all the contents of the aforementioned method embodiment.

[0126] This invention provides an image processing apparatus. Figure 6 This is a schematic diagram of the image processing device, as shown below. Figure 6 As shown, the image processing apparatus 600 includes:

[0127] The first acquisition unit 61 is used to acquire target features and reference features; the target features are features obtained by feature extraction of a target object in a target image, and the reference features are features obtained by feature extraction of a reference object in a reference image;

[0128] The second acquisition unit 62 is used to acquire a migration matrix; the migration matrix is ​​used to control the reference features to fuse with the target features with specified weights;

[0129] Processing unit 63 fuses the target feature and the reference feature according to the migration matrix to obtain fused features;

[0130] The generation unit 64 is used to generate a migration result image based on the fusion features and the target image.

[0131] As an optional implementation of this invention, the first acquisition unit 61 is specifically used to acquire a first region and a second region, wherein the first region is the region corresponding to the target object in the target image, and the second region is the region corresponding to the reference object in the reference image; the first region is used to extract features from the target image to acquire the target features; and the second region is used to extract features from the reference image to acquire the reference features.

[0132] As an optional implementation of the present invention, the first acquisition unit 61 is specifically used to acquire a first grayscale image and a second grayscale image.

[0133] In this image, pixels in the first grayscale image correspond one-to-one with pixels in the target image via pixel coordinates. The grayscale value of the pixel in the first grayscale image corresponding to a pixel within the first region is a first grayscale value, and the grayscale value of the pixel in the first grayscale image corresponding to a pixel outside the first region is a second grayscale value. Similarly, pixels in the second grayscale image correspond one-to-one with pixels in the reference image via pixel coordinates. The grayscale value of the pixel in the second grayscale image corresponding to a pixel within the second region is a first grayscale value, and the grayscale value of the pixel in the second grayscale image corresponding to a pixel outside the second region is a second grayscale value.

[0134] As an optional implementation of the present invention, the first acquisition unit 61 is specifically used to input the target image and the first grayscale image into the feature extraction model, and acquire the output of the feature extraction model as the target feature;

[0135] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0136] As an optional implementation of this invention, the first acquisition unit 61 is specifically used to input the reference image and the second grayscale image into the feature extraction model, and acquire the output of the feature extraction model as the reference feature;

[0137] The feature extraction model is a model obtained by training a first network model based on the first sample data; the first sample data includes: sample images, sample features, and sample grayscale images; the sample features are features obtained by feature extraction of sample objects in the sample images, and the sample grayscale images are used to characterize the regions corresponding to the sample objects in the sample images.

[0138] As an optional implementation of this invention, the second acquisition unit 62 is specifically used to acquire weight parameters; and acquire the transfer matrix based on the weight parameters and the pre-training matrix.

[0139] The weight parameter is used to characterize the specified weight, and the pre-trained matrix is ​​a matrix obtained by training a preset matrix based on the second sample data. The second sample data includes: a first sample feature, a second sample feature, and a sample fusion feature corresponding to the first sample feature and the second sample feature.

[0140] As an optional implementation of this invention, the second acquisition unit 62 is specifically used to display a first interface, the first interface including an input control for inputting the weight parameters; and to acquire the weight parameters in response to the user's operation on the input control.

[0141] As an optional implementation of this invention, the generation unit 64 is specifically used to input the fusion features and the target image into a feature fusion model, and obtain the output of the feature fusion model as the migration result image;

[0142] The feature fusion model is a model obtained by training the second network model based on the third sample data; the third sample data includes: sample images, sample fusion features, and sample transfer result images corresponding to the sample images and the sample fusion features.

[0143] As an optional implementation of the present invention, the target feature is the facial feature obtained by feature extraction of the face to be made up in the target image, and the reference feature is the makeup feature obtained by feature extraction of the makeup to be transferred in the reference image.

[0144] The image processing apparatus provided in this embodiment can execute the image processing method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0145] Based on the same inventive concept, embodiments of the present invention also provide an electronic device. Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, such as... Figure 6 As shown, the electronic device provided in this embodiment includes a memory 61 and a processor 62. The memory 61 is used to store computer programs; the processor 62 is used to enable the electronic device to implement the image processing method provided in the above embodiment when the computer program is invoked.

[0146] This invention also provides a computer-readable storage medium storing a computer program, which, when executed by a computing device, causes the computing device to implement the image processing method provided in the above embodiments.

[0147] This invention also provides a computer program product that, when run on a computer, enables the computer to implement the image processing method provided in the above embodiments.

[0148] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.

[0149] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0150] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0151] Computer-readable media include both permanent and non-permanent, removable and non-removable storage media. Storage media can store information using any method or technology; the information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An image processing method, characterized by, The method comprises: obtaining a first gray image and a second gray image, the pixels in the first gray image correspond to the pixels in the target image one by one through pixel coordinates, the gray value of the pixel corresponding to the pixel in the first region in the first gray image is a first gray value, the gray value of the pixel corresponding to the pixel outside the first region in the first gray image is a second gray value, the first region is a region corresponding to a target object in the target image, the pixels in the second gray image correspond to the pixels in the reference image one by one through pixel coordinates, the gray value of the pixel corresponding to the pixel in the second region in the second gray image is a first gray value, the gray value of the pixel corresponding to the pixel outside the second region in the second gray image is a second gray value, the second region is a region corresponding to a reference object in the reference image; extracting features from the target image according to the first region to obtain target features; extracting features from the reference image according to the second region to obtain reference features; obtaining a transfer matrix, the transfer matrix being used to control the reference features to be fused with the target features with a specified weight; fusing the target features and the reference features according to the transfer matrix to obtain fused features; generating a transfer result image according to the fused features and the target image.

2. The method of claim 1, wherein, The method comprises: inputting the target image and the first gray image into a feature extraction model, and obtaining the output of the feature extraction model as the target features; wherein the feature extraction model is a model obtained by training a first network model based on first sample data; the first sample data comprises a sample image, sample features and a sample gray image; the sample features are features obtained by extracting features from a sample object in the sample image, and the sample gray image is used to represent a region corresponding to the sample object in the sample image.

3. The method of claim 1, wherein, The method comprises: inputting the reference image and the second gray image into a feature extraction model, and obtaining the output of the feature extraction model as the reference features; wherein the feature extraction model is a model obtained by training a first network model based on first sample data; the first sample data comprises a sample image, sample features and a sample gray image; the sample features are features obtained by extracting features from a sample object in the sample image, and the sample gray image is used to represent a region corresponding to the sample object in the sample image.

4. The method according to any one of claims 1 to 3, characterized in that, The method comprises: obtaining a weight parameter, the weight parameter being used to represent the specified weight; obtaining the transfer matrix according to the weight parameter and a pre-training matrix; wherein the pre-training matrix is a matrix obtained by training a preset matrix based on second sample data, and the second sample data comprises first sample features, second sample features and sample fused features corresponding to the first sample features and the second sample features.

5. The method of claim 4, wherein, The weight parameter comprises: Display a first interface, the first interface comprising an input control for inputting the weight parameter; In response to user operation of the input control, the weight parameter is obtained.

6. The method according to any one of claims 1 to 3, characterized in that, The generation of the migration result image according to the fusion feature and the target image comprises: Inputting the fusion feature and the target image into a feature fusion model, and obtaining the output of the feature fusion model as the migration result image; The feature fusion model is a model obtained by training a second network model based on third sample data; the third sample data comprises: a sample image, a sample fusion feature, and a sample migration result image corresponding to the sample image and the sample fusion feature.

7. The method according to any one of claims 1 to 3, characterized in that, The target feature is a face feature obtained by feature extraction on a face to be made up in the target image, and the reference feature is a makeup feature obtained by feature extraction on a makeup to be migrated in the reference image.

8. An image processing apparatus characterized by comprising: Comprise: The first acquisition unit is configured to acquire a first gray image and a second gray image, extract a target feature from a target image according to a first region, and extract a reference feature from a reference image according to a second region; The pixel points in the first gray image and the pixel points in the target image are one-to-one corresponding through pixel coordinates, the gray value of the pixel points corresponding to the pixel points in the first region in the first gray image is a first gray value, the gray value of the pixel points corresponding to the pixel points outside the first region in the first gray image is a second gray value, the first region is a region corresponding to a target object in the target image, the pixel points in the second gray image and the pixel points in the reference image are one-to-one corresponding through pixel coordinates, the gray value of the pixel points corresponding to the pixel points in the second region in the second gray image is a first gray value, the gray value of the pixel points corresponding to the pixel points outside the second region in the second gray image is a second gray value, and the second region is a region corresponding to a reference object in the reference image; The second acquisition unit is configured to acquire a migration matrix; the migration matrix is used to control the reference feature to be fused with the target feature with a specified weight; The processing unit is configured to fuse the target feature and the reference feature according to the migration matrix, and obtain a fusion feature; The generation unit is configured to generate a migration result image according to the fusion feature and the target image.

9. An electronic device, comprising: Comprise: The memory is configured to store a computer program; and the processor is configured to, when the computer program is invoked, enable the electronic device to implement the image processing method in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program; when the computer program is executed by a computing device, the computing device implements the image processing method in any one of claims 1-7.

11. A computer program product, characterised in that, When the computer program product runs on a computer, the computer implements the image processing method in any one of claims 1-7.

Citation Information

Patent Citations

  • Lightweight human face automatic makeup method based on mobile terminal

    CN108257084A