Image synthesis method, device, equipment and storage medium

By extracting and covering the hair area images, the problem that the image synthesis method in the prior art fails to deal with the relationship between the hair and the torso in real user images is solved, and a more realistic image synthesis effect is achieved.

CN114782299BActive Publication Date: 2025-06-27MIGU CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210456294.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-27
Publication Date
2025-06-27
Estimated Expiration
2042-04-27

AI Technical Summary

Technical Problem

Existing image synthesis methods fail to effectively process the front and back relationship between hair and trunk in real user images, resulting in inconsistent with the synthetic image.

Method used

By obtaining the first portrait image and the second portrait image of the target individual, it is determined whether the hair part of the target individual in the first portrait image is located on the front side of the torso. If so, the hair region image is extracted from the first portrait image and overlaid it in the corresponding position in the second portrait image to obtain the target composite image.

Benefits of technology

Ensure that the front and back relationship between hair and torso in the composite image is consistent with the real user image, thereby generating a more realistic image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114782299B_ABST
    Figure CN114782299B_ABST
Patent Text Reader

Abstract

The present invention discloses an image synthesis method, device, equipment and storage medium, belonging to the field of image processing. The image synthesis method includes: obtaining a first portrait image and a second portrait image of a target individual; wherein, in the second portrait image, the area where the torso of the target individual is located does not show hair; determining whether the part of the hair of the target individual in the first portrait image is located in front of the torso; if the part of the hair is located in front of the torso, extracting a hair area image from the first portrait image; covering the hair area image at the corresponding position in the second portrait image to obtain a target composite image. The present invention can synthesize a real portrait image and a clothing material image, so that the hair draping state of the obtained target composite image is consistent with that of the real portrait image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular, to an image synthesis method, apparatus, device, and storage medium. Background Art

[0002] In related technologies, in order to meet the needs of users to generate various ID photos, change clothes, and create interesting images conveniently and quickly through mobile phones at any time and place, composite images that meet the user's needs, such as ID photos or dressed-up photos, can be synthesized by combining material pictures and real user images.

[0003] However, the existing image synthesis methods do not pay attention to the front-back relationship between the hair of the real user image and the shoulders of the clothes. Whether it is front-draped hair (part of the hair is located on the front side of the torso) or back-draped hair (part of the hair is located on the back side of the torso), the synthesized hair is back-draped hair after synthesis. Summary of the Invention

[0004] The main objective of the present invention is to provide an image synthesis method, apparatus, device, and storage medium, aiming to solve the problem that the front-back relationship between the hair and the torso in the image synthesized by the existing image synthesis method is inconsistent with that of the real user image.

[0005] To achieve the above objective, in a first aspect, the present invention provides an image synthesis method, including:

[0006] Obtain a first portrait image and a second portrait image of a target individual; wherein, in the second portrait image, the area where the torso of the target individual is located does not show hair;

[0007] Determine whether the part of the hair of the target individual in the first portrait image is located on the front side of the torso;

[0008] If the part of the hair is located on the front side of the torso, extract the hair area image from the first portrait image;

[0009] Cover the hair area image at the corresponding position in the second portrait image to obtain a target composite image.

[0010] In an embodiment, the hair area image includes a unilateral hair area image, and the unilateral hair area image is a left hair area image or a right hair area image; determining whether the part of the hair of the target individual is located on the front side of the torso includes:

[0011] Determine whether the part of the unilateral hair of the target individual is located on the front side of the torso; the unilateral hair is any one of the left hair or the right hair;

[0012] Covering the hair area image at the corresponding position in the second portrait image to obtain a target composite image includes:

[0013] Segment the hair region image into two unilateral hair region images;

[0014] Overlay the unilateral hair region image at the corresponding position in the second portrait image to obtain the target composite image.

[0015] In one embodiment, determining whether a part of the unilateral hair of the target individual is located in front of the torso includes:

[0016] Extract the chest region image from the first portrait image;

[0017] Determine the intersection region between the unilateral hair region image and the chest region image;

[0018] Based on the intersection region, determine whether a part of the unilateral hair of the target individual is located in front of the torso.

[0019] In one embodiment, based on the intersection region, determining whether a part of the unilateral hair of the target individual is located in front of the torso includes:

[0020] Determine the pixel quantity ratio between the pixel quantity of the intersection region and the total pixel quantity of the face region of the first portrait image;

[0021] Judge whether the pixel quantity ratio is greater than a preset threshold;

[0022] If the pixel quantity ratio is greater than the preset threshold, determine that a part of the unilateral hair of the target individual is located in front of the torso;

[0023] If the pixel quantity ratio is less than or equal to the preset threshold, determine that a part of the unilateral hair of the target individual is not located in front of the torso.

[0024] In one embodiment, extracting the chest region image from the first portrait image includes:

[0025] Extract the chin curve of the target individual from the first portrait image;

[0026] Input the first portrait image into a trained shoulder and neck key point detection model to obtain at least two shoulder and neck key points output by the shoulder and neck key point detection model;

[0027] Perform fitting processing on at least two shoulder and neck key points to obtain a shoulder and neck curve;

[0028] Generate a chest region image according to the chin curve and the shoulder and neck curve.

[0029] In one embodiment, segmenting the hair region image into two unilateral hair region images includes:

[0030] Input the first portrait image into a trained face key point detection model to obtain the chin key point and the nose bridge key point output by the face key point detection model;

[0031] According to the chin key point and the nose bridge key point, the hair region image is segmented into a left hair region image or a right hair region image.

[0032] In one embodiment, extracting the hair region image from the first portrait image includes:

[0033] Performing portrait segmentation on the first portrait image to obtain a human head region image and a user face region image;

[0034] Subtracting the human head region image from the user face region image to obtain the hair region image.

[0035] In a second aspect, the present application further provides an image synthesis device, including:

[0036] An image acquisition module, configured to acquire a first portrait image and a second portrait image of a target individual; wherein, the area of the torso of the target individual in the second portrait image does not show hair;

[0037] A state detection module, configured to determine whether a part of the hair of the target individual in the first portrait image is located in front of the torso;

[0038] An image extraction module, configured to extract the hair region image from the first portrait image if a part of the hair is located in front of the torso;

[0039] An image overlay module, configured to overlay the hair region image at a corresponding position in the second portrait image to obtain a target composite image.

[0040] In a third aspect, the present application further provides an image synthesis device, including: a memory, a processor, and an image synthesis program stored on the memory and executable on the processor, the image synthesis program being configured to implement the steps of the image synthesis method as described above.

[0041] In a fourth aspect, the present application further provides a computer-readable storage medium, on which an image synthesis program is stored, and when the image synthesis program is executed by a processor, it implements the steps of the image synthesis method as above.

[0042] An embodiment of the present invention provides an image synthesis method, which includes obtaining a first portrait and a second portrait of a target individual; wherein, in the second portrait, the area where the torso of the target individual is located does not show hair; determining whether the part of the hair of the target individual in the first portrait is located in front of the torso; if the part of the hair is located in front of the torso, extracting a hair area image from the first portrait; covering the hair area image at the corresponding position in the second portrait to obtain a target composite image. Thus, when it is determined that the part of the hair of the target individual in the first portrait is located in front of the torso, the present invention extracts the hair area image from the first portrait and superimposes the hair area image at the corresponding position in the second portrait where the area where the torso of the target individual is located does not show hair, so as to ensure the restoration of the original front-back relationship between the hair and the torso of the target individual, thereby obtaining a more realistic composite image. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 is a schematic structural diagram of the image synthesis device of the present invention;

[0044] Figure 2 is a schematic flowchart of the first embodiment of the image synthesis method of the present invention;

[0045] Figure 3 is a schematic diagram of superimposing the hair area image at the corresponding position in the intermediate composite image of the present invention;

[0046] Figure 4 is a schematic flowchart of the second embodiment of the image synthesis method of the present invention;

[0047] Figure 5 is a schematic flowchart of the third embodiment of the image synthesis method of the present invention;

[0048] Figure 6 is a schematic diagram of the face key points of the present invention;

[0049] Figure 7 is a schematic diagram of the shoulder and neck key points of the present invention;

[0050] Figure 8 is a schematic diagram of the modules of the image synthesis device of the present invention.

[0051] The implementation, functional features and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0052] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0053] In the existing related technologies, in order to meet the needs of users to generate various synthetic images such as ID photos, clothing change, and interesting synthetic images at any time and place conveniently and quickly through mobile phones, composite images can be generated by combining material pictures and real portrait pictures. However, in the existing clothing change applications, the front-back relationship between the hair and the torso of the real portrait picture is not noticed during clothing change. Whether it is a front-draped hairstyle (part of the hair is located on the front side of the torso) or a back-draped hairstyle (part of the hair is located on the back side of the torso), it is made into a back-draped hairstyle after synthesis, resulting in inconsistent situations.

[0054] Therefore, the present application provides an image synthesis method. When it is determined whether a part of the hair of the target individual in the first portrait picture is located on the front side of the torso, the hair region image is extracted from the first portrait picture, and the hair region image is superimposed on the corresponding position in the second portrait picture where the region of the torso of the target individual does not show hair, to obtain the target composite image, so as to ensure the restoration of the original front-back relationship between the hair and the torso of the target individual, thereby obtaining a more realistic composite image.

[0055] The inventive concept of the present application will be further elaborated below in conjunction with some specific embodiments.

[0056] Refer to Figure 1 , Figure 1 which is a schematic structural diagram of an image synthesis device for the hardware operating environment involved in the solution of the embodiment of the present application.

[0057] As Figure 1 shown, the image synthesis device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0058] Those skilled in the art can understand, Figure 1The structure shown does not constitute a limitation on the image synthesis device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0059] As Figure 1 shown, the memory 1005, as a storage medium, may include an operating system, a data storage module, a communication module, a user interface module, and an image synthesis program.

[0060] In Figure 1 the image synthesis device shown, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the image synthesis device of the present invention may be provided in an image sending device. The image synthesis device calls the image synthesis program stored in the memory 1005 through the processor 1001 and executes the image synthesis method provided in the embodiments of the present application.

[0061] Based on the above hardware devices but not limited to the above hardware devices, a first embodiment of an image synthesis method of the present application is proposed. Refer to Figure 2 , Figure 2 which is a schematic flowchart of the first embodiment of the image synthesis method of the present application.

[0062] In this embodiment, it includes:

[0063] Step S100: Obtain a first portrait image and a second portrait image of a target individual; wherein, in the second portrait image, the area where the torso of the target individual is located does not show hair.

[0064] In this embodiment, the execution subject of the image synthesis method is an image synthesis device, and the image synthesis device is used to synthesize a synthesized image required by a user according to an input real portrait image and a clothing material image. The image synthesis device may be a mobile terminal such as a mobile phone or a tablet, or may also be a local computer or a cloud server, etc.

[0065] Specifically, the image synthesis device may obtain a real portrait image and a clothing material image through a network, or may retrieve the stored real portrait image and clothing material image from a local database. Alternatively, the image synthesis device may retrieve the stored real portrait image from local data and download the clothing material image from the network. The present application does not limit this. And it can be understood that the real portrait image may also be a real portrait image of a target individual obtained by the image synthesis device in real time based on a photographing instruction. The real portrait image is the first portrait image in this embodiment.

[0066] It is understandable that the real portrait image includes at least the face, neck and collar. Alternatively, the real portrait image may also include the top of the head to the shoulders, that is, a half-length portrait of the target individual taken in accordance with the requirements of the ID photo. It is also understandable that in this embodiment, the target individual can be male or female, and this embodiment does not limit this. For example, the real portrait image can be a daily photo of female user A. In order to synthesize the ID photo, her hairstyle is long hair, that is, part of the hair is draped in front of the body, that is, located on the front side of the torso.

[0067] The clothing material image at least includes a portrait model and a clothing image matching the portrait model, wherein the portrait model includes a preset neck area that is exposed outside the clothing image, and the preset neck area may be a blank area. For example, the clothing material image may be a workplace photo of a female portrait model wearing a white shirt.

[0068] The image synthesis device can synthesize the real portrait image and the clothing material image according to the existing dressing technology to obtain the second portrait image T. Specifically, the positioning point between the clothing material image and the real portrait image is determined, and then the texture image of the head area is cut out from the real portrait image and superimposed on the background base color layer, and then the clothing material image is superimposed on the texture image of the head area according to the positioning point, so as to obtain the second portrait image T. It can be understood that the existing dressing technology does not pay attention to the front and back relationship between the hair and the torso of the real portrait image. Regardless of whether the hair is in front (part of the hair is located on the front side of the torso) or in the back (part of the hair is located on the back side of the torso), after synthesis, the hair is in the back, that is, the area where the torso of the target individual in the second portrait image T is located does not show hair.

[0069] Step S200: determining whether the hair portion of the target individual in the first portrait image is located at the front side of the torso.

[0070] The image synthesis device determines whether the hair of the target individual in the first portrait image is located on the front side of the trunk, that is, detects the relationship between the front and back hair in the real portrait image.

[0071] Understandably, the relationship between front and back hair includes:

[0072] Frontal hair, i.e. the ends of the hair are located on the front side of the torso, so that the hair covers a portion of the torso of the target individual;

[0073] The hair is loose at the back, i.e. the ends of the hair are located behind the torso, i.e. the clothes in the chest area of ​​the target individual are fully exposed and not covered by the hair.

[0074] Step S300: if the hair part is located at the front side of the torso, extracting a hair area image from the first portrait image;

[0075] The hair region image S may be a partial region of the real portrait image that includes the hair portion of the target individual. The hair region image S may include a hair root portion image connected to the head, a hair middle portion image connected to the face, and a hair tip portion image. This step is to extract the hair region image S from the real portrait image.

[0076] It should be noted that the hair region image S may be a texture feature image including texture features of the target individual.

[0077] Step S400: Overlay the hair region image at the corresponding position in the second portrait image to obtain a target composite image.

[0078] See also Figure 3 When the judgment result is that part of the hair is located on the front side of the torso, in order to avoid the hair ends of the target individual in the obtained synthetic image being covered by the torso, additional mapping processing can be performed on the basis of the obtained second portrait image T, that is, the existing dressing synthetic image, that is, the hair area map is superimposed on the corresponding position of the second portrait image T, so that the front and back hair relationship of the obtained target synthetic image is consistent with the front and back hair relationship in the real portrait image, so as to obtain a more realistic synthetic image and improve the user experience.

[0079] It should be noted that the target composite image includes a background color layer, a human head layer, a clothing material layer, and a hair area image S layer in sequence.

[0080] For example, if user A has shoulder-length hair, this embodiment detects that part of user A's hair is located on the front side of the torso, and then, on the basis of superimposing the clothing material layer on the human head layer, additionally superimposes the hair area image S on the clothing material layer, so that the hair area image S completely covers the corresponding part of the clothing material layer, thereby obtaining a target composite image of user A. In the target composite image, the part of user A's shoulder-length hair is still located on the front side of the torso, which is consistent with the real portrait image.

[0081] Based on the above embodiments, a second embodiment of the image synthesis method of the present application is proposed. Figure 4 , Figure 4 This is a flowchart diagram of the second embodiment of the image synthesis method of the present application.

[0082] In this embodiment, the method includes:

[0083] Step S100, obtaining a first portrait image and a second portrait image of a target individual; wherein, in the second portrait image, the area where the torso of the target individual is located does not show hair;

[0084] Step S200A, determining whether the portion of the hair on one side of the target individual is located on the front side of the trunk; the hair on one side is either the hair on the left side or the hair on the right side;

[0085] Specifically, the hair region image S includes a single-side hair region image, and the single-side hair region image is a left-side hair region image or a right-side hair region image.

[0086] It is understandable that in the real portrait image, the front and back relationship of the left and right hair of the target individual may be inconsistent. For example, the real portrait image may be a daily photo of female user A. In order to synthesize the ID photo, her hairstyle is shoulder-length hair, in which the left hair is draped in front of the body, that is, the hair ends of the left hair are located in front of the torso, and the right hair is draped on the back, that is, the hair ends of the right hair are located behind the torso. Therefore, at this time, a single-side hair area image can be cut out from the real portrait image.

[0087] The image synthesis device determines whether the single-sided hair of the target individual in the first portrait image is located on the front side of the trunk, that is, detects the front-to-back hair relationship of the left and right hair in the real portrait image.

[0088] It can be understood that the relationship between the front and back of the hair on one side includes:

[0089] (1) The left side of the hair is worn in front, and the right side of the hair is worn in front, that is, at least the ends of the left side of the hair are located on the front side of the trunk, so that the left side of the hair covers a part of the trunk of the target individual, and at least the ends of the right side of the hair are located on the front side of the trunk, so that the right side of the hair covers a part of the trunk of the target individual;

[0090] (2) The left side of the hair is worn in front and the right side of the hair is worn in the back, that is, at least the ends of the left side of the hair are located in front of the torso, so that the left side of the hair covers part of the torso of the target individual, while at least the ends of the right side of the hair are located behind the torso, that is, the clothes on the right chest area of ​​the target individual are fully displayed and not covered by the hair.

[0091] (3) The hair on the right side is loose in front, and the hair on the left side is loose in the back, that is, at least the hair tips on the right side are located in front of the torso, so that the hair on the right side covers part of the torso of the target individual, while at least the hair tips on the left side are located behind the torso, that is, the clothes on the left chest area of ​​the target individual are fully displayed and not partially covered by the hair.

[0092] (4) The hair on the right side is a backward-draped hairstyle, and the hair on the left side is also a backward-draped hairstyle. That is, at least the tip part of the hair on the left side is located behind the torso. That is, the clothes in the left chest area of the target individual are fully displayed and not covered by the hair. And at least the tip part of the hair on the right side is located behind the torso. That is, the clothes in the right chest area of the target individual are fully displayed and not covered by the hair.

[0093] Step S300: If a part of the hair is located in front of the torso, extract the hair region image from the first portrait image.

[0094] Step S401: Segment the hair region image into two single-sided hair region images.

[0095] Generally, since changing clothes is usually for obtaining images such as ID photos, and the posing of the target individual in ID photos and the like is relatively formal, the decomposition line between the left hair region image and the right hair region image of the target individual is relatively obvious. For example, generally, the two single-sided hair region images are located on the left and right sides of the left and right images respectively, rather than being superimposed or covered, etc. Therefore, the hair region image can be segmented into two single-sided hair region images.

[0096] As an implementation method, the left hair region image or the right hair region image can be obtained through the following method:

[0097] (1) Input the first portrait image into the trained face key point detection model to obtain the chin key point and the nose bridge key point output by the face key point detection model.

[0098] (2) According to the chin key point and the nose bridge key point, segment the hair region image S into the left hair region image or the right hair region image.

[0099] It can be understood that after the image synthesis device obtains the real portrait image, the real portrait image can be scaled according to the ratio between the real portrait image and the target composite image. Then, the scaled real portrait image is input into the trained face key point detection model, and the face key point detection model detects the face key points of the target individual in the real portrait image. Among them, the face key points include the chin key point 16 and the nose bridge key point 43.

[0100] Use the straight line formed by the chin key point and the nose bridge key point to cut the hair region image S into the left hair region image or the right hair region image.

[0101] Step S402: Cover the single-sided hair region image at the corresponding position in the second portrait image to obtain the target composite image.

[0102] Specifically, in this embodiment, according to the detection result of the front-back hair distribution relationship of the unilateral hair, only the image of the corresponding side hair area with the detection result of front hair distribution is superimposed on the corresponding position of the second portrait T, thereby not only avoiding the extra waste of time by still superimposing the unilateral hair area image on the corresponding position of the second portrait T when the detection result of the front-back hair distribution relationship is back hair distribution, so as to further improve the synthesis efficiency, but also avoiding the situation of image distortion after multiple coverages, so as to improve the image quality of the synthesized image.

[0103] As an implementation manner, extracting the hair area image S from the first portrait includes:

[0104] (1) Performing portrait segmentation on the first portrait to obtain a human head area image and a user face area image;

[0105] (2) Subtracting the human head area image from the user face area image to obtain the hair area image.

[0106] Specifically, input the scaled real portrait into the trained hair-level portrait segmentation model to obtain a human head area image including hair and face. Input the scaled real portrait into the portrait semantic segmentation model to obtain the user face area image. Among them, both the human head area image and the user face area image can be mask images. After subtracting the human head area image from the user face area image, a hair area mask image is obtained. At this time, the hair area texture feature map can be cropped according to this hair area mask image.

[0107] Based on the above embodiments, the third embodiment of the image synthesis method of the present application is proposed. Refer to Figure 5 , Figure 5 is the schematic flow chart of the third embodiment of the image synthesis method of the present application.

[0108] In this embodiment, the step of determining whether a part of the unilateral hair of the target individual is located on the front side of the torso includes:

[0109] Step A10: Extract the chest area image from the first portrait;

[0110] The chest area image is an image of the shoulder-neck and chest of the target individual. It can be understood that when the hair of the target individual is in the front hair distribution state, the hair of the target individual hangs down naturally, and the hair tips will cover part of the shoulder-neck area and chest area of the target individual.

[0111] It is worth mentioning that the chest area image here can be a chest area mask image extracted from the real portrait.

[0112] As an example implementation manner, the chest area image can be extracted by the following method:

[0113] Step B10: Extract the chin curve of the target individual from the first portrait image;

[0114] It can be understood that after the image synthesis device obtains the real portrait image, the real portrait image can be scaled according to the ratio between the real portrait image and the target composite image. Then the scaled real portrait image is input into the trained face key point detection model, and the face key point detection model detects the face key points of the target individual in the real portrait image. Refer to Figure 6 , such as multiple key points 10 to 21 in the chin part.

[0115] According to key points such as 10 to 21, the chin curve of the target individual can be extracted. For example, the key points 10 to 21 can be fitted to obtain the chin curve.

[0116] Alternatively, through portrait semantic segmentation, the real portrait image can be input into the trained portrait semantic segmentation model to obtain the output chin curve. This embodiment does not limit this.

[0117] Step B20: Input the first portrait image into the trained shoulder and neck key point detection model to obtain at least two shoulder and neck key points output by the shoulder and neck key point detection model;

[0118] It should be noted that the shoulder and neck key point detection model is trained through deep learning on a large number of pre-labeled image data, so that multiple shoulder and neck points from the neck to the midpoint of the neck to the shoulder can be predicted for the input real portrait image. Refer to Figure 7 , the shoulder and neck key points may include 18 shoulder and neck key points such as 0 to 17. Specifically, on the left side of the real portrait image are shoulder and neck key points 0 to 8, and on the right side are shoulder and neck key points 9 to 17.

[0119] Step B30: Perform fitting processing on at least two shoulder and neck key points to obtain a shoulder and neck curve;

[0120] After the 18 shoulder and neck key points of the target individual are predicted by the shoulder and neck key point detection model, the 18 shoulder and neck points can be fitted to obtain a shoulder and neck curve. For example, the least squares method is used to fit the 9 points on the left and right shoulder and neck respectively to obtain 2 shoulder and neck curves, namely the left shoulder and neck curve and the right shoulder and neck curve.

[0121] Step B40: Generate a chest area image according to the chin curve and the shoulder and neck curve.

[0122] The image synthesis device can use the common point of the chin curve and the shoulder and neck curve as a reference point, connect the chin curve and the shoulder and neck curve to obtain a neck and shoulder line. Then the image synthesis device can build a chest area based on the neck and shoulder line and then fill the chest area to obtain a chest area mask image.

[0123] It is worth mentioning that, in order to make the chest area mask image more accurate, the chest area mask image can also be subtracted from the previously obtained user's face area image.

[0124] Step A20: Determine the intersection area between the unilateral hair area image and the chest area image;

[0125] Step A30: Based on the intersection area, determine whether a part of the unilateral hair of the target individual is located on the front side of the torso.

[0126] In this embodiment, based on the intersection area between the unilateral hair area image and the chest area image, it is determined whether a part of the unilateral hair of the target individual is located on the front side of the torso.

[0127] For example, if the intersection area between the unilateral hair area image and the chest area image is empty, that is, the unilateral hair area image and the chest area image do not intersect. At this time, the user's hair may be short hair, and at this time, a part of the unilateral hair of the target individual is not located on the front side of the torso.

[0128] Or, if there is an intersection area between the unilateral hair area image and the chest area image, that is, there is an intersection between the unilateral hair area image and the chest area image. At this time, the user's hair may be scattered on the chest, and a part of the unilateral hair of the target individual is located on the front side of the torso.

[0129] As an implementation manner, based on the intersection area, determining whether a part of the unilateral hair of the target individual is located on the front side of the torso includes:

[0130] Step A301: Determine the pixel quantity ratio between the pixel quantity of the intersection area and the total pixel quantity of the face area of the first portrait;

[0131] Step A302: Determine whether the pixel quantity ratio is greater than a preset threshold;

[0132] Step A303: If the pixel quantity ratio is greater than the preset threshold, determine that a part of the unilateral hair of the target individual is located on the front side of the torso;

[0133] Step A304: If the pixel quantity ratio is less than or equal to the preset threshold, determine that a part of the unilateral hair of the target individual is not located on the front side of the torso.

[0134] It can be understood that the pixel quantities FrontHairL and FrontHairR of the intersection areas between the left hair area image or the right hair area mask image and the chest area image can be calculated respectively. And the total pixel quantity FaceSum of the user's face area image is counted.

[0135] Calculate the pixel quantity ratio of the left exposed hair of the target individual according to the following formula:

[0136] RatioL = FrontHairL / FaceSum

[0137] Calculate the pixel quantity ratio of the hair exposed on the left side of the target individual according to the following formula:

[0138] RatioR = FrontHairR / FaceSum.

[0139] If the pixel quantity ratio is greater than the preset threshold, it is determined that the corresponding unilateral hair is front hair, that is, a part of the unilateral hair of the target individual is located in front of the torso.

[0140] In this embodiment, by counting the ratio of the intersection of the hair region mask images on the left and right sides and the chest region image to the effective region of the face region mask, it is determined whether the hair on this side is front hair, which can avoid misjudgment caused by factors such as image defects in the judgment result.

[0141] In addition, based on the same inventive concept, the present application also provides an image synthesis device. Refer to Figure 8 , including:

[0142] An image acquisition module, configured to acquire a first portrait image and a second portrait image of the target individual; wherein, the area where the torso of the target individual is located in the second portrait image does not show hair;

[0143] A state detection module, configured to determine whether a part of the hair of the target individual in the first portrait image is located in front of the torso;

[0144] An image extraction module, configured to extract a hair region image from the first portrait image if a part of the hair is located in front of the torso;

[0145] An image overlay module, configured to overlay the hair region image at a corresponding position in the second portrait image to obtain a target composite image

[0146] For other embodiments of the image synthesis device and the technical solutions and technical effects of the implementation manners, reference can be made to the above method embodiments, which will not be elaborated here.

[0147] In addition, an embodiment of the present invention further provides a computer storage medium, on which an image synthesis program is stored. When the image synthesis program is executed by a processor, the steps of the image synthesis method as described above are implemented. Therefore, details will not be described herein again. In addition, the beneficial effects of the same method will not be described again. For the technical details not disclosed in the embodiment of the computer-readable storage medium involved in this application, please refer to the description of the method embodiment of this application. By way of example, the program instructions can be deployed to be executed on one computing device, or on multiple computing devices located at one location, or alternatively, on multiple computing devices distributed at multiple locations and interconnected by a communication network.

[0148] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The above program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the above storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0149] In addition, it should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationships between the modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those of ordinary skill in the art can understand and implement without creative efforts.

[0150] Through the description of the above embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general hardware. Of course, it can also be implemented by dedicated hardware including application specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structures for implementing the same function can also be various, such as analog circuits, digital circuits or dedicated circuits. However, for the present invention, in more cases, software program implementation is a better embodiment. Based on such an understanding, the technical solution of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a readable storage medium, such as a floppy disk, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disc of a computer, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of the various embodiments of the present invention.

[0151] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. An image synthesis method, characterized in that, Including: Obtaining a first portrait image and a second portrait image of a target individual; wherein, in the second portrait image, the area where the torso of the target individual is located does not show hair; the second portrait image is obtained by synthesizing the first portrait image and a clothing material image; Judging whether the part of the hair of the target individual in the first portrait image is located in front of the torso; If the part of the hair is located in front of the torso, extracting a hair area image from the first portrait image; Covering the hair area image at the corresponding position in the second portrait image to obtain a target composite image.

2. The image synthesis method according to claim 1, wherein The hair area image includes a unilateral hair area image, and the unilateral hair area image is a left hair area image or a right hair area image; the judging whether the part of the hair of the target individual is located in front of the torso includes: Judging whether the part of the unilateral hair of the target individual is located in front of the torso; the unilateral hair is any one of the left hair or the right hair; The covering the hair area image at the corresponding position in the second portrait image to obtain a target composite image includes: Dividing the hair area image into two unilateral hair area images; Covering the unilateral hair area image at the corresponding position in the second portrait image to obtain the target composite image.

3. The image synthesis method according to claim 2, characterized in that The judging whether the part of the unilateral hair of the target individual is located in front of the torso includes: Extracting a chest area image from the first portrait image; Determining the intersection area between the unilateral hair area image and the chest area image; Judging whether the part of the unilateral hair of the target individual is located in front of the torso according to the intersection area.

4. The image synthesis method according to claim 3, characterized in that The judging whether the part of the unilateral hair of the target individual is located in front of the torso according to the intersection area includes: Determining the pixel quantity ratio between the pixel quantity of the intersection area and the total pixel quantity of the face area of the first portrait image; Judging whether the pixel quantity ratio is greater than a preset threshold; If the pixel quantity ratio is greater than the preset threshold, determining that the part of the unilateral hair of the target individual is located in front of the torso; If the pixel quantity ratio is less than or equal to the preset threshold, determining that the part of the unilateral hair of the target individual is not located in front of the torso.

5. The image synthesis method according to claim 3, wherein The extracting a chest area image from the first portrait image includes: Extracting the chin curve of the target individual from the first portrait image; Inputting the first portrait image into a trained shoulder and neck key point detection model to obtain at least two shoulder and neck key points output by the shoulder and neck key point detection model; Performing a fitting process on at least two of the shoulder and neck key points to obtain a shoulder and neck curve; Generating the chest area image according to the chin curve and the shoulder and neck curve.

6. The image synthesis method according to claim 2, characterized in that The dividing the hair area image into two unilateral hair area images includes: Inputting the first portrait image into a trained face key point detection model to obtain a chin key point and a nose bridge key point output by the face key point detection model; According to the chin key point and the nose bridge key point, the hair region image is segmented into a left hair region image or a right hair region image.

7. The image synthesis method according to any one of claims 1 to 6, characterized in that The extracting the hair region image from the first portrait image includes: Performing portrait segmentation on the first portrait image to obtain a human head region image and a user face region image; Subtracting the human head region image from the user face region image to obtain the hair region image.

8. An image synthesis device, characterized in that, Including: An image acquisition module, configured to acquire a first portrait image and a second portrait image of a target individual; wherein, in the second portrait image, the region where the torso of the target individual is located does not show any hair; the second portrait image is obtained by synthesizing the first portrait image and a clothing material image; A state detection module, configured to determine whether the part of the hair of the target individual in the first portrait image is located in front of the torso; An image extraction module, configured to extract the hair region image from the first portrait image if the part of the hair is located in front of the torso; An image overlay module, configured to overlay the hair region image at a corresponding position in the second portrait image to obtain a target composite image.

9. An image synthesis device, characterized in that, Including: A memory, a processor, and an image synthesis program stored on the memory and executable on the processor, the image synthesis program being configured to implement the steps of the image synthesis method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, An image synthesis program is stored on the computer-readable storage medium, and when the image synthesis program is executed by a processor, the steps of the image synthesis method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Picture processing method, device and equipment and computer storage medium

    CN110738595A

  • Hair classification method and device, equipment and storage medium

    CN114093011A