Image synthesis method, device and equipment and computer readable storage medium

By generating synthetic images based on depth values ​​and mask information in video conference background virtual technology, the problem of portraits blocking the background is solved and the harmony and naturalness of the images are improved.

CN118799445APending Publication Date: 2024-10-18CHINA MOBILE COMM LTD RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410014944.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-04
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

In the existing video conference background virtualization technology, the area where the portrait is located in the synthesized image will block the background indiscriminately, and when the selected synthesis position is relatively far away from the background image, the synthesized image will be disharmonious.

Method used

Generate a composite image by determining the depth value and mask of each object based on the first image and the second image, ensuring that the object with the smaller depth value covers the object with the larger depth value, thereby placing the object with the larger depth value as the background, Avoid blocking background areas.

Benefits of technology

The harmony of the composite image is achieved, ensuring that objects with larger depth values ​​do not block the background area, making the final image more natural and harmonious.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799445A_ABST
    Figure CN118799445A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an image synthesis method, device and equipment and a computer readable storage medium, and the method comprises the steps: determining the depth values and masks of N first objects based on a first image, N being a positive integer, and the first image comprising the N first objects; based on M second images, depth values and masks of M second objects are determined, M is a positive integer, and each second image in the M second images comprises one second object; generating a composite image and a mask corresponding to the composite image based on the first image, the M second images, the depth values and masks of the N first objects and the depth values and masks of the M second objects; the composite image comprises the N first objects and the M second objects, and the objects with smaller depth values in the composite image cover the objects with larger depth values.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to an image synthesis method, device, equipment and computer-readable storage medium. Background Art

[0002] Video conferencing and live broadcasting have been widely used in the past few years, and the usage has exploded. In order to protect the privacy of users and increase practicality and fun, background virtualization has become a hot research technology. The background virtualization task of video conferencing involves the task of portrait segmentation, which requires distinguishing the foreground (people) in the image and setting the background to a custom background image. However, in the existing background virtual portrait synthesis technology for video conferencing, the area where the portrait is located in the synthesized image will indiscriminately occlude the corresponding area in the background image, without considering setting the portrait far away from the camera as the background, and when the selected synthesis position is far away in the relative depth of the background image, it will cause the synthesized image to be disharmonious. Summary of the invention

[0003] In order to solve the above technical problems, the embodiments of the present application provide an image synthesis method, device, equipment and computer-readable storage medium.

[0004] The image synthesis method provided in the embodiment of the present application includes:

[0005] Determine, based on a first image, depth values ​​and masks of N first objects, where N is a positive integer, and the first image includes the N first objects;

[0006] Determine depth values ​​and masks of M second objects based on M second images, where M is a positive integer, and each second image in the M second images includes one second object;

[0007] Based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects, a composite image and a mask corresponding to the composite image are generated; the composite image includes the N first objects and the M second objects, and in the composite image, objects with smaller depth values ​​cover objects with larger depth values.

[0008] The image synthesis device provided in the embodiment of the present application includes:

[0009] A first determining unit, configured to determine depth values ​​and masks of N first objects based on a first image, where N is a positive integer and the first image includes the N first objects;

[0010] A second determining unit, configured to determine depth values ​​and masks of M second objects based on M second images, where M is a positive integer and each of the M second images includes one second object;

[0011] An image synthesis unit is used to generate a synthetic image and a mask corresponding to the synthetic image based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects; the synthetic image includes the N first objects and the M second objects, and in the synthetic image, the object with a smaller depth value covers the object with a larger depth value.

[0012] The image synthesis device provided in the embodiment of the present application includes: a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any one of the data synthesis methods provided in the embodiment of the present application.

[0013] The computer-readable storage medium provided in the embodiments of the present application stores a computer program thereon, wherein the computer program enables a computer to execute any one of the data synthesis methods provided in the embodiments of the present application.

[0014] In the technical solution of the embodiment of the present application, by determining the depth values ​​and masks of the N first objects included in the first image based on the first image, and determining the depth values ​​and masks of the M second objects included in the M second images based on the M second images, a composite image and a mask corresponding to the composite image are generated based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects. In this way, based on the depth information and mask information of the background image and the object image, the object with a larger depth value can be set as the background, and the area where the object with a larger depth value is located will not block the corresponding area in the background, so that the final composite image is more harmonious. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1a A schematic diagram of an image before character segmentation provided in an embodiment of the present application;

[0016] Figure 1b A schematic diagram of an image after character segmentation provided in an embodiment of the present application;

[0017] Figure 2 A schematic diagram of annotation when performing a person segmentation task provided in an embodiment of the present application;

[0018] Figure 3 A schematic diagram of a flow chart of an image synthesis method in the prior art provided in an embodiment of the present application;

[0019] Figure 4A schematic diagram of a flow chart of an image synthesis method provided in an embodiment of the present application;

[0020] Figure 5 A flowchart of an application scenario of the image synthesis method provided in an embodiment of the present application;

[0021] Figure 6 A schematic diagram of the structure of an image synthesis device provided in an embodiment of the present application;

[0022] Figure 7 A schematic diagram of the composition structure of the image synthesis device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0024] It should be noted that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the embodiments of the present application, the character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0025] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between two items, or an association relationship between the two items, or a relationship between indication and being indicated, configuration and being configured, and the like.

[0026] To facilitate understanding of the technical solutions of the embodiments of the present application, the relevant technologies of the embodiments of the present application are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.

[0027] Video conferencing and live streaming have been widely used in the past few years, and the usage has exploded. In order to protect the privacy of users and increase practicality and fun, background virtualization has become a hot research technology. The background virtualization task of video conferencing involves the task of portrait segmentation, which requires distinguishing the foreground (people) in the image and setting the background to a custom background image, such as Figure 1a The image shown here is before the segmentation of the person. The background of the person is a diagonal grid pattern. Figure 1b For the image after character segmentation, separate the character and replace the background of the character with a white image.

[0028] Background virtualization for video conferencing is a special kind of portrait segmentation task. To avoid interference, the task expects to only consider the main area in the video as the foreground, while background objects and people who are far away or passing by are considered as the background. Figure 2 The figure shows a diagram of annotation when performing a person segmentation task. This task only requires segmenting person No. 1 in front of the camera and treating it as the foreground, and setting all other parts (including person No. 2) as the background.

[0029] like Figure 3 The figure shows a flow chart of image synthesis in the prior art, that is, a background image, a portrait image (foreground) and a segmentation result of the portrait image are required, and the portrait image and the background image are combined according to the segmentation result of the portrait image to obtain a synthesized image and the segmentation result of the synthesized image. However, since the area where the portrait is located in the synthesized image will indiscriminately block the corresponding area in the background image, it is not considered to set the portrait far from the camera as the background, and when the selected synthesis position is far relative to the background image, the synthesized image is not harmonious.

[0030] Based on the above technical problems, the present application embodiment proposes an image synthesis method. Figure 4 is a flow chart of the image synthesis method according to an embodiment of the present application, such as Figure 4 As shown, the method may include the following steps:

[0031] Step 401: Determine depth values ​​and masks of N first objects based on a first image.

[0032] Wherein, N is a positive integer, and the first image includes N first objects.

[0033] Here, the first image refers to a background image, the N first objects refer to N separable objects in the background image, and the depth values ​​and masks of the N first objects refer to the depth values ​​of the N objects and the masks of the N objects in the background image.

[0034] Among them, the depth value of an object refers to the distance of the object in three-dimensional space, which is used to indicate the distance of the object in the image. In the field of image processing, the depth value of an object in an image can be predicted by other technologies such as a depth estimation network model or binocular stereo vision technology. Mask is a method used to indicate a specific area in an image, which is usually used to segment, extract and identify objects in an image. The mask of an object can be understood as a binary image used to distinguish the object from the background image. In the binary image of the object, 1 indicates the location of the object in the background image, representing white, and 0 indicates the background or other objects in the background image, representing black. In addition, the mask of an object can also be described in other ways, such as: object segmentation label, object segmentation annotation, etc.

[0035] In the embodiment of the present application, the depth values ​​and masks of the N first objects may be determined based on the first image. In other words, the depth values ​​and masks of the N objects contained in the background image may be determined based on the background image.

[0036] In some implementations, determining the depth values ​​and masks of N first objects based on the first image may be implemented by following steps 4011 to 4013, which specifically include:

[0037] Step 4011: perform depth estimation on the first image to generate a depth map of the first image.

[0038] In the embodiment of the present application, the first image can be input into the depth estimation network to perform depth estimation on the first image, and the depth value of each pixel in the first image can be predicted to obtain a depth map of the first image. The maximum depth value and the minimum depth value in the depth map of the first image can be determined by the depth value of each pixel in the depth map, and the depth value range (first depth interval) of the depth map of the first image can be obtained.

[0039] Here, the depth estimation network can be any model that can estimate the depth of an image, such as a Convolutional Neural Networks (CNN) model, a Recurrent Neural Network (RNN) model, etc.

[0040] In some implementations, binocular stereo vision technology or depth sensor (such as infrared sensor or laser radar) and other technologies may be used to estimate the depth of the first image.

[0041] Step 4012: Perform object segmentation on the first image to generate N masks of the first object.

[0042] In an embodiment of the present application, the first image can be input into an image segmentation network to segment all objects in the first image to obtain a segmentation result of the first image, that is, to obtain masks of N first objects in the first image.

[0043] Here, the image segmentation network can be any model that can segment an image, such as Segment Anything Model (SAM), Pyramid Scene Parseing Network (PSPNet), etc. The image segmentation network extracts features from the image through multiple layers of convolution and nonlinear activation functions, then maps these features back to the original image size and generates a segmentation mask to identify and separate different objects in the image.

[0044] Step 4013: Determine depth values ​​of the N first objects based on the depth map and the masks of the N first objects.

[0045] In the embodiment of the present application, after obtaining the depth map of the first image and the masks of the N first objects in the first image, the average depth value of each of the N first objects may be calculated based on the depth map of the first image and the masks of the N first objects in the first image, wherein the formula for calculating the average depth value of each of the N first objects is as follows:

[0046] D i =Mean(d background *b_mask i ),i=1,2,...,N (1)

[0047] Among them, D i is the average depth value of each first object in the N first objects, d background is the depth map of the first image, b_mask i is the mask of each first object in the N first objects, and Mean is the average function.

[0048] In some implementations, after calculating the average depth value of each of the N first objects in the first image, the N first objects may be arranged in descending order of the average depth value to obtain sorted N first objects.

[0049] Step 402: Determine depth values ​​and masks of M second objects based on the M second images.

[0050] Wherein, M is a positive integer, and each of the M second images includes a second object.

[0051] Here, the second image refers to an image of an object of interest, such as a portrait image.

[0052] In the embodiment of the present application, the depth values ​​and masks of the M second objects may be determined based on the M second images. That is, the depth value of the second object in each of the M object images of interest and the mask of the second object in each of the object images of interest may be determined based on the M object images of interest.

[0053] In some implementations, determining the depth values ​​and masks of the M second objects based on the M second images may be implemented by the following steps 4021-4022, which specifically include:

[0054] Step 4021: perform object segmentation on each of the M second images to generate masks of M second objects.

[0055] In an embodiment of the present application, M second images can be input into an image segmentation network to segment objects in each second image respectively to obtain a segmentation result for each second image, that is, to obtain masks of M second objects in the M second images.

[0056] Here, the image segmentation network can be any model that can segment an image, such as SAM, PSPNet, etc.

[0057] Step 4022: Select a depth value for each of the M second objects within the first depth interval.

[0058] In an embodiment of the present application, a depth value can be randomly set for each of the M second objects within a first depth interval, wherein the first depth interval is defined by a first depth value and a second depth value, the first depth value is the minimum depth value in the depth map of the first image, and the second depth value is the maximum depth value in the depth map of the first image.

[0059] In some implementations, after selecting a depth value for each of the M second objects in the first depth interval, the M second objects may be arranged in descending order of depth value to obtain sorted M second objects.

[0060] In some embodiments, the M second images and the masks of the M second objects may be graphically transformed so that the sizes of the M second images and the masks of the M second objects after the graphical transformation are the same as the size of the first image.

[0061] Step 403: Generate a composite image and a mask corresponding to the composite image based on the first image, the M second images, the N depth values ​​and masks of the first objects, and the M depth values ​​and masks of the second objects.

[0062] In an embodiment of the present application, the first image and the M second images may be combined based on the first image, the M second images, the depth values ​​of the N first objects, the masks of the N first objects, the depth values ​​of the M second objects, and the masks of the M second objects to generate a composite image and a mask corresponding to the composite image. The composite image includes the N first objects and the M second objects, and in the composite image, an object with a smaller depth value covers an object with a larger depth value.

[0063] In some embodiments, generating a composite image and a mask corresponding to the composite image based on the first image, the M second images, the N depth values ​​and masks of the first objects, and the M depth values ​​and masks of the second objects may be implemented by the following steps 4031 to 4033, which specifically include:

[0064] Step 4031: N first objects and M second objects are assembled into a first object set in descending order of depth values.

[0065] In the embodiment of the present application, the first object set can be formed by arranging N first objects and M second objects in descending order of depth values.

[0066] In some implementations, the first object set may be formed by arranging the sorted N first objects and the sorted M second objects in descending order of depth values.

[0067] Step 4032: Initialize the composite image and the mask corresponding to the composite image.

[0068] In an embodiment of the present application, two new composite images of the same size as the background image and masks corresponding to the composite images are created, and the composite images and masks corresponding to the composite images are initialized so that the depth values ​​of the composite images and masks corresponding to the composite images are both 0.

[0069] Step 4033: traverse each object in the first object set and perform the following operations: update the composite image based on the mask of the object and the image where the object is located, and when the object is the second object and the depth value of the object meets the preset conditions, update the mask corresponding to the composite image based on the mask of the object.

[0070] In an embodiment of the present application, the composite image can be updated by traversing each object in the first object set and based on the mask of each object and the image (first image or second image) in which each object is located. Moreover, when an object in the first object set is the second object and the depth value of the object meets a preset condition, the mask corresponding to the composite image can be updated based on the mask of the object.

[0071] In some implementations, updating the synthesized image based on the mask of the object and the image where the object is located may be implemented through steps s1 to s4, specifically including:

[0072] Step s1: Based on the mask of the object, determine the inverse mask of the object.

[0073] In the embodiment of the present application, the inverse mask of each object can be obtained based on the mask of each object in the first object set, wherein the calculation formula of the inverse mask of each object is as follows:

[0074] w_mask j =1-mask j ,j=1,2,...,N+M (2)

[0075] Among them, mask j is the mask of each object in the first object set, w_mask j is the inverse mask of each object in the first object set.

[0076] Here, the inverse mask is a binary image opposite to the mask, where 0 represents the location of the object and 1 represents the background or other objects. That is, the inverse mask is to invert each pixel value in the mask. Therefore, when 1 is subtracted from the mask of the object, the inverse mask of the object can be obtained.

[0077] Step s2: Generate a background image based on the object's inverse mask and the current composite image.

[0078] In the embodiment of the present application, after obtaining the inverse mask of each object in the first object set, a background image corresponding to each object may be generated based on the inverse mask of each object and the current synthesized object, wherein the calculation formula for generating the background image corresponding to each object is:

[0079] b_image j =s_image j-1 *w_mask j ,j=1,2,...,N+M (3)

[0080] Among them, b_image j is the background image corresponding to each object in the first object set, s_image j-1 is the composite image before each update during the traversal process (the current composite image), w_mask j is the inverse mask of each object in the first object set.

[0081] Here, in the inverse mask of the object, 0 represents the location of the object, representing black, and 1 represents the background or other objects, representing white. Therefore, the inverse mask of the object and the current synthetic image are combined, that is, each corresponding pixel value in the inverse mask of the object is ANDed with each corresponding pixel value in the current synthetic image to generate a background image corresponding to the object.

[0082] Step s3: Generate an image of interest based on the mask of the object and the image where the object is located.

[0083] In the embodiment of the present application, an image of interest corresponding to each object may be generated based on the mask of each object in the first object set and the image (first image or second image) where each object is located, wherein the calculation formula for generating the image of interest corresponding to each object is:

[0084] h_image j =image j *mask j ,j=1,2,...,N+M (4)

[0085] Among them, h_image j is the image of interest corresponding to each object in the first object set, image j is the image where each object in the first object set is located, mask j is the mask of each object in the first object set.

[0086] Here, in the mask of the object, 1 represents the location of the object, representing white, and 0 represents the background or other objects, representing black. Therefore, the mask of the object and the image where the object is located are combined, that is, each corresponding pixel value in the mask of the object is ANDed with each corresponding pixel value in the image where the object is located, thereby generating an image of interest corresponding to the object.

[0087] Step s4: superimpose the background image and the image of interest to generate an updated composite image.

[0088] In the embodiment of the present application, after obtaining the background image corresponding to each object and the image of interest corresponding to each object, the background image corresponding to each object and the image of interest corresponding to each object may be superimposed respectively to generate an updated composite image, wherein the calculation formula for generating the updated composite image is:

[0089] s_image j =b_image j +h_image j ,j=1,2,...,N+M (5)

[0090] Among them, s_image j b_image is the composite image after each update during the traversal process. j is the background image corresponding to each object in the first object set, h_image j is an image of interest corresponding to each object in the first object set.

[0091] In some embodiments, when the object is a second object and the depth value of the object meets a preset condition, the mask corresponding to the composite image is updated based on the mask of the object. Specifically, when the object is a second object and the depth value of the object is less than or equal to a preset threshold a, the mask of the object and the mask corresponding to the current composite image are superimposed to generate a mask corresponding to an updated composite image.

[0092] Here, since it is necessary to set the second object with a smaller depth value as the foreground and the second object with a larger depth value as the background, a preset threshold a is set to determine whether the second object is the foreground or the background, that is, when the object is the second object and the depth value of the object is less than the preset threshold a, the object is set as the foreground, and the mask of the object and the mask corresponding to the current synthetic image are superimposed, otherwise the object is set as the background. Moreover, when the object (the second object) is set as the background, the object with a smaller depth value (the first object or the second object) will cover the object with a larger depth value (the first object or the second object).

[0093] In the technical solution of the embodiment of the present application, by determining the depth values ​​and masks of the N first objects included in the first image based on the first image, and determining the depth values ​​and masks of the M second objects included in the M second images based on the M second images, a composite image and a mask corresponding to the composite image are generated based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects. In this way, based on the depth information and mask information of the background image and the object image, the object with a larger depth value can be set as the background, and the area where the object with a larger depth value is located will not block the corresponding area in the background, so that the final composite image is more harmonious.

[0094] Based on the above embodiments, the present application also proposes an application scenario of an image synthesis method. Figure 5 The flowchart of the application scenario of the image synthesis method of the embodiment of the present application is as follows: Figure 5 As shown in the figure, this application scenario includes three stages, including:

[0095] Background image processing stage:

[0096] 1. Input the background image into the depth estimation network, perform depth estimation on the background image, predict the depth value of each pixel in the background image, and obtain a depth map. The size of the depth map is H*W, where H is the height of the background image and W is the width of the background image. The maximum and minimum depth values ​​in the depth map are determined through the depth value of each pixel in the depth map to obtain the depth value range of the depth map.

[0097] 2. Input the background image into SAM, segment all objects in the background image, and obtain the segmentation result of the background image, where the size of the segmentation result is 6*H*W, and 6 represents the number of extracted objects.

[0098] 3. Extract the segmentation result of the background image to obtain the mask of each object in the background image, that is, obtain the masks of 6 objects, where the size of the mask of each object is H*W. And calculate the average depth value of each object based on the depth map of the background image and the mask of each object, that is, obtain the average depth value of the 6 objects. After obtaining the average depth value of each object, arrange each object in order from large to small according to the average depth value.

[0099] Portrait image processing stage:

[0100] 1. Input portrait image 1 and portrait image 2 into SAM respectively, segment the portraits in portrait image 1 and portrait image 2, and obtain the segmentation results: mask of portrait 1 (portrait 1) and mask of portrait 2 (portrait 2).

[0101] 2. Randomly set a depth value within the depth value range of the depth map for portrait 1 and portrait 2 respectively, and arrange portrait 1 and portrait 2 in descending order of depth value.

[0102] 3. Perform image transformation on portrait 1 and the mask of portrait 1 and portrait 2 and the mask of portrait 2, such as cropping, enlarging, etc., so that the sizes of portrait 1 and the mask of portrait 1 and portrait 2 and the mask of portrait 2 after the image transformation are the same as the size of the background image, that is, the sizes are all H*W.

[0103] Image synthesis stage:

[0104] 1. Rearrange the six objects and two portraits (portrait 1 and portrait 2) in descending order of depth values ​​to form an object set.

[0105] 2. Create two composite images and composite image masks of the same size as the background image, and initialize the composite image and the composite image mask (set the depth value of the composite image and the composite image mask to 0).

[0106] 3. Traverse each object in the object set and perform the following operations: based on the mask of the object, obtain the inverse mask of the object, based on the inverse mask of the object and the current synthetic image, generate the background image corresponding to the object, based on the mask of the object and the image where the object is located, generate the object image corresponding to the object, and superimpose the background image corresponding to the object and the object image corresponding to the object to generate an updated synthetic image. Furthermore, when the object is a portrait (portrait 1 or portrait 2) and the depth value of the object is less than or equal to the preset threshold a, superimpose the mask of the object and the mask of the current synthetic image to generate the mask of the updated synthetic image.

[0107] Until the traversal is completed, the final generated composite image and the composite image mask are obtained. In the final generated composite image, since the depth value of portrait 2 is greater than the preset threshold a, portrait 2 is set as the background, and the depth value of portrait 1 is less than the preset threshold a, so portrait 1 is set as the foreground. In addition, since the depth value of portrait 2 is greater than the depth value of one of the six objects, part of the area of ​​portrait 2 will be covered by the object area.

[0108] In this way, based on the depth information and mask information of the background image and the portrait image, the portrait with a larger depth value can be set as the background, and the area where the portrait with a larger depth value is located will not block the corresponding area in the background, making the final synthesized image more harmonious.

[0109] The present application also provides an image synthesis device. Figure 6 is a schematic diagram of the structure of the image synthesis device according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:

[0110] The first determining unit 601 is configured to determine depth values ​​and masks of N first objects based on a first image, where N is a positive integer and the first image includes N first objects.

[0111] The second determining unit 602 is configured to determine depth values ​​and masks of M second objects based on M second images, where M is a positive integer and each of the M second images includes a second object.

[0112] The image synthesis unit 603 is used to generate a synthetic image and a mask corresponding to the synthetic image based on the first image, M second images, the depth values ​​and masks of N first objects, and the depth values ​​and masks of M second objects; the synthetic image includes N first objects and M second objects, and in the synthetic image, the object with a smaller depth value covers the object with a larger depth value.

[0113] In some embodiments, the first determination unit 601 is specifically used to perform depth estimation on the first image to generate a depth map of the first image; perform object segmentation on the first image to generate masks of N first objects; and determine depth values ​​of the N first objects based on the depth map and the masks of the N first objects.

[0114] In some embodiments, the second determination unit 602 is specifically used to perform object segmentation on each of the M second images to generate masks of the M second objects; select a depth value for each of the M second objects within a first depth interval; wherein the first depth interval is defined by a first depth value and a second depth value, the first depth value is the minimum depth value in the depth map, and the second depth value is the maximum depth value in the depth map.

[0115] In some embodiments, the apparatus further comprises a transforming unit:

[0116] The transformation unit is used to perform graphic transformation on the M second images and the masks of the M second objects, wherein the sizes of the M second images and the masks of the M second objects after the graphic transformation are the same as the size of the first image.

[0117] In some embodiments, the image synthesis unit 603 is specifically used to form a first object set by combining N first objects and M second objects in descending order of depth value; initializing a synthesized image and a mask corresponding to the synthesized image; traversing each object in the first object set to perform the following operations: updating the synthesized image based on the mask of the object and the image where the object is located, and updating the mask corresponding to the synthesized image based on the mask of the object when the object is a second object and the depth value of the object meets a preset condition.

[0118] In some embodiments, the image synthesis unit 603 is further specifically used to determine the reverse mask of the object based on the mask of the object; generate a background image based on the reverse mask of the object and the current synthesized image; generate an image of interest based on the mask of the object and the image in which the object is located; and superimpose the background image and the image of interest to generate an updated synthesized image.

[0119] In some embodiments, the image synthesis unit 603 is further specifically configured to superimpose the mask of the object and the mask corresponding to the current synthesized image to generate a mask corresponding to an updated synthesized image when the object is a second object and the depth value of the object is less than or equal to a preset threshold.

[0120] In the technical solution of the embodiment of the present application, by determining the depth values ​​and masks of the N first objects included in the first image based on the first image, and determining the depth values ​​and masks of the M second objects included in the M second images based on the M second images, a composite image and a mask corresponding to the composite image are generated based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects. In this way, based on the depth information and mask information of the background image and the object image, the object with a larger depth value can be set as the background, and the area where the object with a larger depth value is located will not block the corresponding area in the background, so that the final composite image is more harmonious.

[0121] In the embodiment of the present application, the first determination unit 601, the second determination unit 602 and the image synthesis unit 603 in the above-mentioned image synthesis device can all be implemented by a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a programmable gate array (FPGA) in actual applications.

[0122] It should be noted that: when the image synthesis device provided in the above embodiment performs image synthesis, only the division of the above program units is used as an example. In actual applications, the above processing can be assigned to different program units as needed, that is, the internal structure of the device is divided into different program units to complete all or part of the above-described processing. In addition, the image synthesis device provided in the above embodiment and the image synthesis method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0123] The embodiment of the present application also provides an image synthesis device, Figure 7 FIG. 1 is a schematic diagram of the hardware structure of the image synthesis device according to an embodiment of the present application. Figure 7 As shown, the device includes a memory 701, a processor 702, and a computer program stored in the memory 701 and executable on the processor 702. When the processor 702 executes the above program, the steps of the method described in the embodiment of the present application are implemented.

[0124] It is understood that the image synthesis device also includes a communication interface 703. The various components in the device can be coupled together through a bus system 704. It is understood that the bus system 704 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 7Various buses are labeled as bus system 704 .

[0125] The method disclosed in the above embodiment of the present application can be applied to the processor 702, or implemented by the processor 702. The processor 702 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor 702 or an instruction in the form of software. The above processor 702 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 702 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 701, and the processor 702 reads the information in the memory 701 and completes the steps of the above method in combination with its hardware.

[0126] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method described in the embodiment of the present application are implemented.

[0127] In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0128] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0129] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0130] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.

[0131] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0132] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. An image synthesis method, characterized in that: The method comprises: Determine, based on a first image, depth values ​​and masks of N first objects, where N is a positive integer, and the first image includes the N first objects; Determine depth values ​​and masks of M second objects based on M second images, where M is a positive integer, and each second image in the M second images includes one second object; Based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects, a composite image and a mask corresponding to the composite image are generated; the composite image includes the N first objects and the M second objects, and in the composite image, objects with smaller depth values ​​cover objects with larger depth values.

2. The method according to claim 1, characterized in that The step of determining the depth values ​​and masks of N first objects based on the first image includes: Performing depth estimation on the first image to generate a depth map of the first image; Performing object segmentation on the first image to generate N masks of the first object; Determining depth values ​​of the N first objects based on the depth map and the masks of the N first objects.

3. The method according to claim 2, characterized in that The determining, based on the M second images, depth values ​​and masks of the M second objects comprises: Performing object segmentation on each of the M second images to generate masks of the M second objects; A depth value is selected for each of the M second objects within a first depth interval.

4. The method according to claim 3, characterized in that The first depth interval is defined by a first depth value and a second depth value, wherein the first depth value is a minimum depth value in the depth map, and the second depth value is a maximum depth value in the depth map.

5. The method according to any one of claims 1 to 4, characterized in that Before generating the composite image, the method further includes: A graphic transformation is performed on the M second images and the masks of the M second objects, wherein the sizes of the M second images and the sizes of the masks of the M second objects after the graphic transformation are the same as the size of the first image.

6. The method according to any one of claims 1 to 4, characterized in that The generating a composite image and a mask corresponding to the composite image based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects includes: The N first objects and the M second objects are grouped into a first object set in descending order of depth values; Initialize a composite image and a mask corresponding to the composite image; Traversing each object in the first object set, the following operations are performed: updating the synthesized image based on the mask of the object and the image where the object is located, and updating the mask corresponding to the synthesized image based on the mask of the object when the object is the second object and the depth value of the object meets a preset condition.

7. The method according to claim 6, characterized in that The updating of the synthesized image based on the mask of the object and the image where the object is located comprises: Based on the mask of the object, determining an inverse mask of the object; generating a background image based on the inverse mask of the object and the current composite image; Generate an image of interest based on the mask of the object and the image where the object is located; The background image and the image of interest are superimposed to generate the updated composite image.

8. The method according to claim 6, characterized in that When the object is the second object and the depth value of the object satisfies a preset condition, updating the mask corresponding to the synthesized image based on the mask of the object includes: When the object is the second object and the depth value of the object is less than or equal to a preset threshold, the mask of the object and the mask corresponding to the current synthetic image are superimposed to generate an updated mask corresponding to the synthetic image.

9. An image synthesis device, characterized in that: The device comprises: A first determining unit, configured to determine depth values ​​and masks of N first objects based on a first image, where N is a positive integer and the first image includes the N first objects; A second determining unit, configured to determine depth values ​​and masks of M second objects based on M second images, where M is a positive integer and each of the M second images includes one second object; An image synthesis unit is used to generate a synthetic image and a mask corresponding to the synthetic image based on the first image, the M second images, the depth values ​​and masks of the N first objects, and the depth values ​​and masks of the M second objects; the synthetic image includes the N first objects and the M second objects, and in the synthetic image, the object with a smaller depth value covers the object with a larger depth value.

10. An image synthesis device, characterized in that: The device comprises: a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: A computer program is stored thereon, the computer program causing a computer to execute the method according to any one of claims 1 to 8.