Image processing method, image synthesis method and related device

By acquiring a ternary image and performing matting technology processing, the problem of insufficient image processing accuracy in the existing technology is solved, and more sophisticated image edge processing and matting effects are achieved.

CN111080656BActive Publication Date: 2024-10-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911261574.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-10
Publication Date
2024-10-01
Estimated Expiration
2039-12-10

AI Technical Summary

Technical Problem

In existing image processing technology, segmentation-based methods are difficult to achieve high accuracy during the matting process, resulting in poor image processing results, especially when the edges of the target area are rough.

Method used

After acquiring the ternary images, use matting technology to obtain more detailed matting images, and superimpose them to improve the accuracy of image processing.

Benefits of technology

It improves the accuracy of image processing, especially in detail processing at the edge of the target area, and enhances the matting effect of the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111080656B_ABST
    Figure CN111080656B_ABST
Patent Text Reader

Abstract

The present application discloses an image processing method, an image synthesis method and related devices for improving the accuracy of image processing. The present application method includes: obtaining an image to be processed; obtaining a first image and a second image according to the image to be processed; determining a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to a first mixed area and a second mixed area; generating a target cutout image according to a third foreground image in the first cutout image and a fourth foreground image in the second cutout image. The present application uses the results obtained after image segmentation to obtain the first image and the second image respectively, and then uses the cutout technology to obtain the first cutout image and the second cutout image respectively. Compared with the image obtained by segmentation, the cutout image has a more refined structure, thereby improving the accuracy of image processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image processing method, an image synthesis method and related devices. Background Art

[0002] With the development of computer technology, image processing is becoming more and more common. In the field of image and video processing, image matting and image synthesis are important technical directions. Image-based matting refers to extracting people or other specified foreground objects in an image through matting technology. Video-based matting refers to extracting people or other specified foreground objects in a video stream frame by frame through matting technology.

[0003] Currently, the segmentation method can be used to classify each pixel in the image, so as to obtain the target area in the image, such as the hair area or the building area.

[0004] However, the segmentation-based method requires a fixed classification for each pixel, which can easily cause the edges of the target area to be rough. When the accuracy of the cutout is high, it is often difficult to meet the requirements, resulting in poor image processing effects. Summary of the invention

[0005] The embodiments of the present application provide an image processing method, an image synthesis method and related devices, which can use the results obtained after image segmentation to obtain a first image and a second image respectively, and the first image and the second image are both ternary images. The first cut-out image and the second cut-out image are then obtained respectively using the cut-out technology. Compared with the image obtained by segmentation, the first cut-out image and the second cut-out image have a finer structure. After superimposing the two, the object to be cut out can be cut out, thereby improving the accuracy of image processing.

[0006] In view of this, the first aspect of the present application provides an image processing method, comprising:

[0007] Acquire an image to be processed, wherein the image to be processed includes an object to be cut out;

[0008] Acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, and the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, and the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0009] Determine, according to the first mixed area and the second mixed area, a first cutout image corresponding to the first image and a second cutout image corresponding to the second image, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0010] A target cutout image is generated according to the first cutout image and the second cutout image.

[0011] A second aspect of the present application provides an image synthesis method, comprising:

[0012] Acquire an image to be processed and an image to be synthesized, wherein the image to be processed includes an object to be cut out;

[0013] Acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, and the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, and the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0014] Determine, according to the first mixed area and the second mixed area, a first cutout image corresponding to the first image and a second cutout image corresponding to the second image, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0015] Generate a target cutout image according to the first cutout image and the second cutout image;

[0016] Using the target cutout image to extract the area corresponding to the object to be cutout from the image to be processed;

[0017] The area corresponding to the object to be cut out is merged with the image to be synthesized to obtain a synthesized image.

[0018] A third aspect of the present application provides an image processing device, comprising:

[0019] An acquisition module, used for acquiring an image to be processed, wherein the image to be processed includes an object to be cut out;

[0020] The acquisition module is further used to acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0021] The acquisition module is further used to determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0022] The generating module is used to generate a target cutout image according to the first cutout image and the second cutout image acquired by the acquiring module.

[0023] In a possible design, in a first implementation of the third aspect of the embodiments of the present application,

[0024] An acquisition module is specifically used to acquire a target segmented image through an image segmentation model based on the image to be processed;

[0025] Generate a first image according to the target segmented image and the object to be cut out;

[0026] A second image is generated according to the target segmented image and the object to be cut out.

[0027] In a possible design, in a second implementation of the third aspect of the embodiments of the present application,

[0028] An acquisition module, specifically used to acquire a first feature map based on the image to be processed through M convolutional layers included in the image segmentation model, where M is an integer greater than or equal to 1;

[0029] Based on the image to be processed, obtaining a second feature map through N pooling layers included in the image segmentation model, where N is an integer greater than or equal to 1;

[0030] Based on the first feature map and the second feature map, a target segmented image is obtained through a feature fusion module included in the image segmentation model.

[0031] In a possible design, in a third implementation of the third aspect of the embodiments of the present application,

[0032] An acquisition module is specifically used to determine a first foreground area to be updated and a first background area to be updated according to the target segmented image and the object to be cut out, wherein the first foreground area to be updated includes the object to be cut out;

[0033] Obtaining a first contour line corresponding to a first foreground area to be updated;

[0034] According to the first contour line, a first contour area is generated by expanding inward along the first foreground area to be updated;

[0035] According to the first contour line, a second contour area is generated by expanding outward along the first background area to be updated;

[0036] Superimposing the first contour area with the second contour area to obtain a first mixed area;

[0037] Performing a cutout process on the first foreground area to be updated and the first contour area to obtain a first foreground area;

[0038] The first background area to be updated and the second contour area are removed to obtain a first background area.

[0039] In a possible design, in a fourth implementation of the third aspect of the embodiments of the present application,

[0040] An acquisition module, specifically used to determine a second foreground area to be updated and a second background area to be updated according to the target segmented image and the object to be cut out, wherein the second background area to be updated includes the object to be cut out;

[0041] Obtaining a second contour line corresponding to the second foreground area to be updated;

[0042] According to the second contour line, a third contour area is generated by expanding inward along the second foreground area to be updated;

[0043] According to the second contour line, a fourth contour area is generated by expanding outward along the second background area to be updated;

[0044] The third contour area is superimposed with the fourth contour area to obtain a second mixed area;

[0045] The second foreground area to be updated and the third contour area are removed to obtain a second foreground area;

[0046] The second background area to be updated and the fourth contour area are removed to obtain a second background area.

[0047] In a possible design, in a fifth implementation of the third aspect of the embodiments of the present application,

[0048] An acquisition module, specifically used to generate a first cutout image according to the image to be processed and a first mixed area corresponding to the first image;

[0049] A second cutout image is generated according to the image to be processed and the second mixed area corresponding to the second image.

[0050] In a possible design, in a sixth implementation of the third aspect of the embodiments of the present application,

[0051] an acquisition module, specifically used to acquire first color space coordinates and first spatial coordinates of a first pixel point from the image to be processed according to a first mixed area corresponding to the first image, wherein the first color space coordinates include a hue value, a saturation value, and a brightness corresponding to the first pixel point, and the first spatial coordinates include a horizontal coordinate and a vertical coordinate corresponding to the first pixel point in the image to be processed;

[0052] According to the first mixed area corresponding to the first image, obtaining the second color space coordinates and the second space coordinates of the second pixel point from the image to be processed, wherein the second color space coordinates include the hue value, saturation value and brightness corresponding to the second pixel point, and the second space coordinates include the horizontal coordinate and the vertical coordinate corresponding to the second pixel point in the image to be processed;

[0053] Calculate a first feature vector corresponding to the first pixel point according to the first color space coordinate and the first space coordinate;

[0054] Calculate and obtain a second eigenvector corresponding to the second pixel point according to the second color space coordinate and the second space coordinate;

[0055] Based on the kernel function, a first similarity matrix is ​​calculated according to the first eigenvector, the second eigenvector and the weight adjustment coefficient;

[0056] A first diagonal matrix is ​​obtained by calculating the first similarity matrix;

[0057] A first Laplace matrix is ​​calculated based on the first similarity matrix and the first diagonal matrix;

[0058] According to the first Laplacian matrix, a first cutout image corresponding to the first image is obtained.

[0059] In a possible design, in a seventh implementation of the third aspect of the embodiments of the present application,

[0060] an acquisition module, specifically used to acquire, according to the second mixed area corresponding to the second image, a third color space coordinate and a third spatial coordinate of a third pixel point from the image to be processed, wherein the third color space coordinate includes a hue value, a saturation value and a brightness corresponding to the third pixel point, and the third spatial coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the third pixel point in the image to be processed;

[0061] According to the second mixed area corresponding to the second image, obtaining a fourth color space coordinate and a fourth space coordinate of the second pixel point from the image to be processed, wherein the fourth color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the fourth pixel point, and the fourth space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the fourth pixel point in the image to be processed;

[0062] Calculate and obtain a third eigenvector corresponding to the third pixel point according to the third color space coordinate and the third space coordinate;

[0063] Calculate and obtain a fourth eigenvector corresponding to the fourth pixel point according to the fourth color space coordinate and the fourth space coordinate;

[0064] Based on the kernel function, a second similarity matrix is ​​calculated according to the third eigenvector, the fourth eigenvector and the weight adjustment coefficient;

[0065] A second diagonal matrix is ​​obtained by calculating according to the second similarity matrix;

[0066] A second Laplace matrix is ​​obtained by calculation according to the second similarity matrix and the second diagonal matrix;

[0067] According to the second Laplacian matrix, a second cutout image corresponding to the second image is obtained.

[0068] In a possible design, in an eighth implementation of the third aspect of the embodiments of the present application,

[0069] A generating module, specifically used to perform a cutout process on the first cutout image and the second cutout image to obtain a cutout image;

[0070] The cutout image is denoised to obtain a target cutout image.

[0071] In a possible design, in a ninth implementation of the third aspect of the embodiments of the present application,

[0072] A generation module, specifically used to generate a binary image according to the cutout image;

[0073] Obtaining the connected area in the background area according to the binary image;

[0074] Determine a connected area according to the connected region, wherein the connected area includes at least one pixel point;

[0075] If the connected area is less than or equal to the connected area threshold, the pixel value corresponding to the pixel point in the connected area is set to the pixel value corresponding to the pixel point in the background area.

[0076] In a possible design, in a tenth implementation of the third aspect of the embodiments of the present application,

[0077] A fourth aspect of the present application provides an image synthesis device, comprising:

[0078] An acquisition module, used for acquiring an image to be processed and an image to be synthesized, wherein the image to be processed includes an object to be cut out;

[0079] The acquisition module is further used to acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0080] The acquisition module is further used to determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0081] A generating module, used for generating a target cutout image according to the first cutout image and the second cutout image acquired by the acquiring module;

[0082] An extraction module, used for extracting a region corresponding to the object to be cut out from the image to be processed by using the target cut out image generated by the generation module;

[0083] The synthesis module is used to merge the area corresponding to the object to be cut out extracted by the extraction module with the image to be synthesized to obtain a synthesized image.

[0084] A fifth aspect of the present application provides an electronic device, including: a memory, a transceiver, a processor, and a bus system;

[0085] Wherein, the memory is used to store programs;

[0086] The processor is used to execute the program in the memory, including executing various implementations in the first aspect, or executing various implementations in the second aspect;

[0087] The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.

[0088] The sixth aspect of the present application provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the methods of the above aspects.

[0089] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0090] In an embodiment of the present application, a method for image processing is provided, which first obtains an image to be processed including an object to be cut out, and then obtains a first image including a first foreground area, a first background area and a first mixed area based on the image to be processed, and a second image including a second foreground area, a second background area and a second mixed area, wherein the first foreground area includes an area corresponding to the object to be cut out, and the second background area includes an area corresponding to the object to be cut out. Further, a first cutout image including a third foreground area and a third background area corresponding to the first image, and a second cutout image including a fourth foreground area and a fourth background area corresponding to the second image can be obtained, wherein the third foreground area includes an area corresponding to the object to be cut out, and the fourth background area includes an area corresponding to the object to be cut out. Finally, a target cutout image including an area corresponding to the object to be cut out can be generated based on the first cutout image and the second cutout image. Through the above method, the results obtained after image segmentation are used to obtain the first image and the second image respectively, and the first image and the second image are both ternary images. Then, the first cut-out image and the second cut-out image are obtained respectively using the cut-out technology. Compared with the image obtained by segmentation, the first cut-out image and the second cut-out image have a finer structure. After superimposing the two, the object to be cut out can be cut out, thereby improving the accuracy of image processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0091] Figure 1 A schematic diagram of a flow chart of an image processing method in an embodiment of the present application;

[0092] Figure 2 A schematic diagram of an embodiment of the image processing method in the embodiment of the present application;

[0093] Figure 3 A schematic diagram of an image processing method in an embodiment of the present application;

[0094] Figure 4 Another schematic diagram of the image processing method in the embodiment of the present application;

[0095] Figure 5 Another schematic diagram of the image processing method in the embodiment of the present application;

[0096] Figure 6 Another schematic diagram of the image processing method in the embodiment of the present application;

[0097] Figure 7 This is a schematic diagram of the network architecture of the bilateral segmentation network BiSeNet structure in an embodiment of the present application;

[0098] Figure 8 A schematic diagram of an embodiment of a method for acquiring a first image in an embodiment of the present application;

[0099] Fig. 9 A schematic diagram of an embodiment of a method for acquiring a second image in an embodiment of the present application;

[0100] Fig.10 Another schematic diagram of the image processing method in the embodiment of the present application;

[0101] Fig.11 This is a schematic diagram of another embodiment of the image processing method in the embodiment of the present application;

[0102] Fig.12 A schematic diagram of an embodiment of an image processing device in an embodiment of the present application;

[0103] Fig.13 A schematic diagram of an embodiment of an image synthesis device in an embodiment of the present application;

[0104] Fig.14 A schematic diagram of the structure of a terminal device in an embodiment of the present application;

[0105] Fig.15 A structural diagram of a server in an embodiment of the present application. DETAILED DESCRIPTION

[0106] The embodiments of the present application provide an image processing method, an image synthesis method and related devices, which are used to use the results obtained after image segmentation to respectively obtain a first image and a second image, both of which are ternary images, and then use the cutout technology to respectively obtain a first cutout image and a second cutout image. Compared with the image obtained by segmentation, the first cutout image and the second cutout image have a finer structure. After superimposing the two, the object to be cutout can be cut out, thereby improving the accuracy of image processing.

[0107] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "corresponding to" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0108] It should be understood that the present application can be applied to the scene of image processing. As the visual basis of human perception of the world, images are an important means for humans to obtain, express and transmit information. Image processing technology may include but is not limited to image transformation, image coding compression, image enhancement and restoration, image segmentation, image description, cutout technology and image classification. Among them, image segmentation is the process of subdividing an image into multiple image sub-regions (a collection of pixels, also known as superpixels). Image segmentation can extract meaningful feature parts from the image. Meaningful features may include but are not limited to edges or regions in the image. Image segmentation is the basis for further image recognition, analysis and understanding. And image segmentation can be applied to multiple fields such as transportation, medicine, remote sensing, communication and industrial automation. Cutout technology is one of the most commonly used operations in image processing. Cutout technology can separate a part of an image or image from the original image or image into a separate layer. Its main function is to prepare for later synthesis.

[0109] The image processing method can be applied to the scene in the medical field. The medical images that can be segmented in the medical field include but are not limited to brain images, heart images, chest images and cell images, and the formation of medical images will be affected by noise, field offset effect, local body effect and tissue movement. Because there are differences between individuals of organisms and the shape load of tissue structure, medical images are usually more blurred and non-uniform compared with ordinary images. Based on the characteristics of medical images, through the image processing method of the present application, medical images with high blur or non-uniformity can be processed using the results obtained after image segmentation to obtain the first image and the second image, which are both ternary images. The ternary image is a rough division of the medical image, roughly marking the foreground, background and mixed areas of the foreground and background. The ternary image is often used as the input of the cutout. Then, the first image and the second image are used as the input of the cutout, and the first cutout image and the second cutout image are obtained respectively by using the cutout technology, and the object to be cutout can be cut out after the two are superimposed. Since the first cutout image and the second cutout image have a finer structure than the image obtained by segmentation, the accuracy of medical image processing can be improved.

[0110] In another example, image processing can also be applied to scenes in the field of remote sensing. Due to the rapid development of information technology and space technology and the continuous improvement of satellite spatial resolution, high-resolution remote sensing images can be applied to ocean monitoring, land cover monitoring, marine pollution and maritime rescue. High-resolution remote sensing images have the characteristics of rich image detail information, significant geometric structure of ground objects, and complex target structure. For example, in high-resolution remote sensing images, the shadows of objects on the coastline are complex, the vegetation coverage area is large, or the segmentation of light and dark artificial facilities is not clear enough. Therefore, high-resolution remote sensing images are usually more detailed and more complex than ordinary images. Based on the characteristics of high-resolution remote sensing images, through the image processing method of the present application, the high-resolution remote sensing image can be processed using the result obtained after image segmentation, and then the first cut-out image and the second cut-out image, both of which are ternary images, are obtained by using the cut-out technology. Similar to the above, the first cut-out image and the second cut-out image have a finer structure than the image obtained by segmentation, and then the two are superimposed to remove the object to be cut out, and the details in the high-resolution remote sensing image can be obtained more accurately, thereby improving the accuracy of high-resolution remote sensing image processing.

[0111] It is understandable that the image formats exemplified above include but are not limited to bitmap (BMP) format, tag image file format (TIFF), graphics interchange format (GIF), and joint photographic expert group (JPEG).

[0112] In order to realize image processing of different images in the above-mentioned various scenarios and improve the accuracy of image processing, the embodiment of the present application provides an image processing method, please refer to Figure 1 , Figure 1 This is a flow chart of the method for image processing in the embodiment of the present application, specifically:

[0113] Step S1, obtaining an image to be processed;

[0114] Step S2: Based on the image to be processed, a target segmented image is obtained through an image segmentation model;

[0115] Step S31, generating a first image according to the target segmented image and the object to be cut out;

[0116] Step S32, generating a second image according to the target segmented image and the object to be cut out;

[0117] Step S41, acquiring a first cutout image corresponding to the first image according to the first mixed area;

[0118] Step S42: acquiring a second cutout image corresponding to the second image according to the second mixed area;

[0119] Step S5, performing a cutout process on the third foreground image in the first cutout image and the fourth foreground image in the second cutout image to obtain a cutout image;

[0120] S6. Perform denoising on the cutout image to obtain a target cutout image.

[0121] Among them, step S1 can obtain Figure 1 The image to be processed includes the object to be cut out as shown in (A), and then step S2 can be based on Figure 1 The image to be processed shown in (A) is obtained through the image segmentation model as follows Figure 1 In the target segmentation image shown in (B), further, step S31 can first determine the overlapping area between the first foreground area and the first background area in the first image as the first mixed area, and then generate the following according to the target segmentation image and the object to be cut out: Figure 1In step S32, the overlapping area between the second foreground area and the second background area in the second image is first determined as the second mixed area, and then the target segmentation image and the object to be cut out are generated as shown in FIG. Figure 1 The second image including the second mixed area is shown in (D), wherein the first foreground area corresponds to the second foreground area and the area corresponding to the object to be cut out. It should be understood that the generation of the first image and the second image has no time limit, that is, the first image and the second image are generated at the same time, or the first image and the second image are generated one after another. Step S41 can obtain the first image corresponding to the first mixed area according to the first mixed area. Figure 1 The first cutout image including the third foreground area is shown in (E), and step S41 can obtain the first image corresponding to the first mixed area according to the first mixed area. Figure 1 In (F), the first cutout image includes the fourth foreground area, wherein the third foreground area corresponds to the fourth foreground area and the area corresponding to the object to be cutout. In a further step S5, the third foreground image in the first cutout image and the fourth foreground image in the second cutout image are cutout to obtain the following: Figure 1 The cutout image shown in (G) is then processed in step S6. Figure 1 The cutout image shown in (G) is denoised, and the following Figure 1 The target cutout image shown in (H).

[0122] Combined with the above introduction, the image processing method in this application will be introduced below. Figure 2 , Figure 2 This is a schematic diagram of an embodiment of the method for image processing in an embodiment of the present application. As shown in the figure, an embodiment of the method for image processing in an embodiment of the present application includes:

[0123] 101. Acquire an image to be processed, wherein the image to be processed includes an object to be cut out;

[0124] In this embodiment, first, the image processing device can obtain an image to be processed including an object to be cut out. The image to be processed can be an image received by the image processing device through a wired network, or can be an image stored by the image processing device itself. Specifically, the image to be processed can include but is not limited to a landscape image, a person image, a medical image image, and a geographic image. Taking the image to be processed as a person image as an example, the object to be cut out can be the hair, mouth, ear, eyebrow, or eye in the person image, and taking the image to be processed as a landscape image as an example, the object to be cut out can be the tree, flower, or building in the landscape image. Taking the image to be processed as a medical image as an example, the object to be cut out can be the cell, bone, and internal organ in the medical image.

[0125] It should be noted that the image processing device can be deployed on a server or on a terminal device. This application is introduced by taking deployment on a terminal device as an example. However, this should not be understood as a limitation of this application.

[0126] 102. Acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, and the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, and the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0127] In this embodiment, the image processing device can obtain a first foreground area, a first background area and a first mixed area according to the image to be processed, and the first foreground area includes the area corresponding to the object to be cut out, and the first foreground area, the first background area and the first mixed area constitute a first image. The image processing device can also obtain a second foreground area, a second background area and a second mixed area according to the image to be processed, and the second background area includes the area corresponding to the object to be cut out, and the second foreground area, the second background area and the second mixed area constitute a second image.

[0128] For easier understanding, see Figure 3 , Figure 3 is a schematic diagram of an image processing method in an embodiment of the present application, such as Figure 3 As shown in (A), the image A1 to be processed is a person image. In this embodiment, the hair of the person in the image to be processed is used as an example for explanation. Therefore, first, the image A1 to be processed can be obtained as follows: Figure 3 The first image A2 shown in (B) includes a first foreground area A21, a first background area A22 and a first mixed area A23, and the first foreground area A21 includes an area corresponding to the hair of the cutout object. Figure 3 The second image A3 shown in (C) includes a second foreground area A31, a second background area A32 and a second mixed area A33, and the second background area A32 includes an area corresponding to the hair of the cutout object. It should be understood that in actual applications, other parts of the character image can also be used as the cutout image and the corresponding first image and second image can be obtained.

[0129] 103. Determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0130] In this embodiment, the image processing device can obtain a first cutout image corresponding to the first image, including a third foreground area and a third background area, and the third foreground area includes an area corresponding to the object to be cutout. In addition, a second cutout image of a fourth foreground area and a fourth background area corresponding to the second image can also be obtained, and the fourth background area includes an area corresponding to the object to be cutout. In actual applications, since noise points may be generated when the background and foreground are segmented, some noise points may appear in the third background area and the fourth foreground area, and the third background area and the fourth foreground area may include a small part of the hair.

[0131] For easier understanding, see Figure 4 , Figure 4 is another schematic diagram of the image processing method in the embodiment of the present application. Figure 4 As shown in (A), the first cutout image B1 includes a third foreground area B11 and a third background area B12, and the third foreground area B11 includes an area corresponding to the hair of the cutout object. Figure 4 The hair area included in the third foreground area B11 shown in (A) is Figure 3 The hair area included in the first foreground area A21 shown in (B) is more detailed and close to the image effect of the hair outline itself. Figure 4 As shown in (B), the second cutout image B2 includes a fourth foreground area B21 and a fourth background area B22, and the fourth background area B22 includes an area corresponding to the hair of the cutout object. Figure 4 The hair area included in the fourth background area B22 shown in (B) is compared with Figure 3 The hair area included in the second background area A32 shown in (C) is more detailed, and is close to the image effect required by the inner contour of the hair close to the face.

[0132] 104. Generate a target cutout image according to the third foreground image in the first cutout image and the fourth foreground image in the second cutout image.

[0133] In this embodiment, the image processing device may further generate a target cutout image including a region corresponding to the object to be cutout according to the acquired first cutout image and the second cutout image.

[0134] For easier understanding, see Figure 5 , Figure 5 Another schematic diagram of the image processing method in the embodiment of the present application is shown in the figure. Figure 5 The first cutout image C1 shown in (A) and Figure 5 The second cutout image C2 shown in (B) can generate the following Figure 5 In the target cutout image C3 shown in (C), it can be seen that the target cutout image is the area corresponding to the hair part in the image to be processed.

[0135] In an embodiment of the present application, a method for image processing is provided. Through the above-mentioned method, a first image and a second image are obtained respectively using the result obtained after image segmentation, and the first image and the second image are both ternary images. Then, a first cut-out image and a second cut-out image are obtained respectively using a cut-out technology. Compared with the image obtained by segmentation, the first cut-out image and the second cut-out image have a finer structure. After superimposing the two, the object to be cut out can be cut out, thereby improving the accuracy of image processing.

[0136] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiments of the present application, obtaining the first image and the second image according to the image to be processed may include:

[0137] Based on the image segmentation model, a target segmentation image is obtained through the image segmentation model;

[0138] Generate a first image according to the target segmented image and the object to be cut out;

[0139] A second image is generated according to the target segmented image and the object to be cut out.

[0140] In this embodiment, the image processing device can obtain a target segmented image through an image segmentation model based on the image to be processed, and then generate a first image according to the target segmented image and the object to be cut out, and generate a second image according to the target segmented image and the object to be cut out.

[0141] For easier understanding, see Figure 6 , Figure 6 is another schematic diagram of the image processing method in the embodiment of the present application. Figure 6 As shown in (B), the target segmentation image D2 is Figure 6 The image to be processed D1 shown in (A) is an image generated by an image segmentation model, and then a first image is generated based on the hair and human body in the object to be cut out as the foreground image and the target segmentation image D2, and a second image can also be generated based on the human body excluding hair in the object to be cut out as the foreground image and the target segmentation image D2.

[0142] Specifically, the image segmentation model is used to segment the target segmented image from the image to be processed. The image segmentation model can be a semantic image segmentation model, and the semantic image segmentation can mark the object category to which each pixel in the image to be processed belongs, that is, to assign a semantic label to each pixel in the image to be processed, such as road, sky, person, dog or other object. It should be understood that this needs to be distinguished from instance segmentation, because the semantic image segmentation model does not separate instances of the same category. The semantic image segmentation model segments the category of each pixel in the image to be processed. If there are two objects of the same category in the image to be processed, it is difficult for the semantic image segmentation model to distinguish them as separate objects.

[0143] The semantic image segmentation model includes but is not limited to the encoder-decoder structure, the dilated convolution structure, and DeepLab-v3+.

[0144] Specifically, in the encoder-decoder structure, the encoder can use the pooling layer to gradually reduce the spatial dimension of the input data, while the decoder gradually restores the details of the target and the corresponding spatial dimension through the deconvolution layer or other network layers. Therefore, there is usually a direct information connection between the encoder and the decoder, which can further help the decoder to better restore the details of the target. In the encoder-decoder structure, the image to be processed is used as input, and then the spatial resolution of the input is downsampled to generate a feature map with lower resolution, where the feature map can classify the object category more efficiently. Upsampling can restore the features of the image to be processed to a full-resolution segmented image, that is, a target segmented image. The encoder-decoder structure can increase the receptive field and improve the ability to obtain remote information.

[0145] The structure of the dilated convolution can increase the distance between two adjacent weights in the convolution kernel, that is, the receptive field of the central pixel of the convolution kernel is increased. In addition, the structure of the dilated convolution can be similar to the encoder-decoder structure, and the output feature map resolution can be controlled by setting the output step size, that is, the structure of the dilated convolution can not only adjust the receptive field (multi-scale information) but also control the resolution. The conditional random field (CRF) method is usually used to improve the segmentation effect. This method is an image model that performs "smooth" segmentation based on the pixel intensity of the underlying image. DeepLab-v3+ is an extension of DeepLab-v3. On the basis of DeepLab-v3, a decoder module is added. The decoder module can refine the segmentation results and can also process the edges of objects more accurately. The deep convolutional neural network is further applied to the spatial pyramid pooling (SPP) and decoder to improve the ability to process object sizes and different aspect ratios, and finally obtain an accurate semantic segmentation encoder-decoder network.

[0146] In an embodiment of the present application, a method for obtaining a first image and a second image is provided. Through the above-mentioned method, the object category to which each pixel of the image to be processed belongs is annotated according to the image segmentation model, and the target segmented image is output through the required object to be cut out, thereby improving the accuracy of the target segmented image, and further generating the first image and the second image through the target segmented image with high accuracy, so that the accuracy of the target cutout image can also be improved, thereby improving the practicality and accuracy of the embodiment of the present application.

[0147] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiments of the present application, based on the image to be processed, obtaining a target segmented image through an image segmentation model may include:

[0148] Based on the image to be processed, obtaining a target segmented image through an image segmentation model may include:

[0149] Based on the image to be processed, obtaining a first feature map through M convolutional layers included in the image segmentation model, where M is an integer greater than or equal to 1;

[0150] Based on the image to be processed, obtaining a second feature map through N pooling layers included in the image segmentation model, where N is an integer greater than or equal to 1;

[0151] Based on the first feature map and the second feature map, a target segmented image is obtained through a feature fusion module included in the image segmentation model.

[0152] In this embodiment, when the image segmentation model is a bilateral segmentation network BiSeNet structure, the image processing device can obtain a first feature image through the M convolutional layers included in BiSeNet, and can also obtain a second feature image based on the image to be processed through the N pooling layers included in BiSeNet. Finally, based on the first feature image and the second feature image, the target segmentation image is obtained through the feature fusion module included in BiSeNet.

[0153] Specifically, the network framework of the bilateral segmentation network BiSeNet structure includes a spatial path (SP) and a context path (CP). The spatial path can obtain a feature image of 1 / 8 the size of the image to be processed by stacking three convolutional layers. The feature image retains the rich spatial details in the image to be processed and can obtain the detail information of the image to be processed. Specifically, spatial information mainly refers to the local detail information of the image, especially for images with rich edges. However, due to the large scale of the convolutional network, the input image size is generally required to be small, and the image to be processed needs to be cropped or resized. This process will lose the detailed spatial information. Therefore, by setting a spatial path containing only 3 networks, rich spatial information can be retained, and low-dimensional spatial detail information can be integrated with high-dimensional information.

[0154] The context path uses the structure of the Xception network, which includes 4 downsampling layers, and will eventually obtain a feature image of 1 / 32 the size of the image to be processed. In this way, each point on the feature image obtained will have a larger receptive field, and the overall information of the image to be processed can be obtained. Among them, the overall information of the image to be processed can be used to determine the reasonable position of each component in the image to be processed within a global range, and the detailed information of the image to be processed can help to segment the position of each component more finely. Therefore, this embodiment uses the bilateral segmentation network BiSeNet structure to segment the image to be processed, and can locate the position to be segmented to the position corresponding to the hair. Then, the first feature image is obtained by the 3 convolution layers of the spatial path, and the second feature image is obtained by the 4 pooling layers of the context path. It should be understood that this application uses maximum pooling as an example. Maximum pooling can extract the most obvious features in the image to be processed. In practical applications, average pooling can also be used. Average pooling can add all pixel values ​​in the image to be processed and then average them, taking into account every pixel in the image to be processed.

[0155] In the context path, since the global context is captured through global average pooling and the attention vector is calculated, an attention optimization module can be added after the context path output. The attention optimization module can optimize the output features of each stage in the context path to facilitate the integration of global context information, thereby reducing the computational cost.

[0156] Since the spatial information captured by the spatial path encodes the vast majority of rich detail information, that is, the first feature image encodes rich detail information, and the output features of the context path encode the encoded context information, that is, the second feature image encodes the context information, the features of the two networks are not the same, so the information encoded in the first feature image and the second feature image generated by the two networks is also different, so the information in the first feature image and the second feature image cannot be simply weighted. At this time, it is necessary to use the feature fusion module (FFM) included in BiSeNet to fuse the information in the first feature image and the second feature image to obtain the target segmented image after the two information are fused. It should be understood that this embodiment takes 3 convolutional layers and 4 pooling layers as an example. In practical applications, as long as the number of convolutional layers and pooling layers is greater than or equal to 1, 3 convolutional layers and 4 pooling layers should not be understood as a limitation of this application.

[0157] For easier understanding, see Figure 7 , Figure 7This is a schematic diagram of the network architecture of the bilateral segmentation network BiSeNet structure in the embodiment of the present application. As shown in the figure, the image E1 to be processed is input into the spatial path E2, and the image E1 to be processed can also be input into the context path E3. After the image E1 to be processed is input, the three convolutional layers E21 in the spatial path E2 perform batch normalization and linear rectification function (rectified linear unit, ReLU) processing on the image E1 to be processed, wherein each E21 contains a convolution with a stride of 2, and finally outputs the first feature image, which retains a relatively high degree of spatial information. After the image E1 to be processed is input, the convolutional layers E31, E32, E33 and E34 in the context path E3 downsample the image E1 to be processed, wherein E31 corresponds to the first downsampling layer, that is, E31 samples the image E1 to be processed by 1 / 4, and then E32 corresponds to the second downsampling layer, that is, E32 samples the image E1 to be processed by 1 / 8 under the 1 / 4 sampling completed by E31, and so on, E33 samples the image E1 to be processed by 1 / 16, and finally, E32 samples the image E1 to be processed by 1 / 32, thereby obtaining a second feature image of 1 / 32 size based on the image E1 to be processed, and the second feature image has the feature of a large receptive field, and then the feature fusion module corresponding to E4 in the figure can perform fusion processing based on the obtained first feature image and the second feature image, and then output it as the target segmentation image E5.

[0158] In an embodiment of the present application, a method for obtaining a target segmentation image is provided. Through the above-mentioned method, since the spatial path in BiSeNet is used alone to retain spatial information to obtain the first feature image, the context path can directly use the classical network to extract deep features to obtain the second feature image, and the feature fusion module is used to fuse the obtained first feature image and the second feature image to obtain the target segmentation image, the receptive field can be expanded and the integrity of the spatial information can be guaranteed, thereby making the target segmentation image complete and accurate, thereby improving the accuracy of the embodiment of the present application.

[0159] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiment of the present application, generating a first image according to the target segmented image and the object to be cut out may include:

[0160] Determine a first foreground area to be updated and a first background area to be updated according to the target segmented image and the object to be cut out, wherein the first foreground area to be updated includes the object to be cut out;

[0161] Obtaining a first contour line corresponding to a first foreground area to be updated;

[0162] According to the first contour line, a first contour area is generated by expanding inward along the first foreground area to be updated;

[0163] According to the first contour line, a second contour area is generated by expanding outward along the first background area to be updated;

[0164] Superimposing the first contour area with the second contour area to obtain a first mixed area;

[0165] Performing a cutout process on the first foreground area to be updated and the first contour area to obtain a first foreground area;

[0166] The first background area to be updated and the second contour area are removed to obtain a first background area.

[0167] In this embodiment, the image processing device can first determine the first background area to be updated and the first foreground area to be updated according to the target segmented image and the object to be cut out, the first foreground area to be updated is the most initial foreground area that has not been processed, and the first background area to be updated is the most initial background area that has not been processed, and then the first contour line corresponding to the first foreground area to be updated can be obtained, and according to the first contour line, the first foreground area to be updated is expanded inwardly to generate the first contour area, and according to the first contour line, the first background area to be updated is expanded outwardly to generate the second contour area. The first contour area and the second contour area are superimposed to obtain a first mixed area, the first foreground area to be updated and the first contour area are cut out to obtain the first foreground area, and the first background area to be updated and the second contour area are cut out to obtain the first background area.

[0168] Specifically, a ternary graph (Trimap) can be automatically generated according to the target segmented image and the object to be cut out. Trimap is a rough division of a given image, roughly marking the foreground, background and mixed area of ​​foreground and background, which is generally used as the input of the cut out. The generation of Trimap is by finding the contour of the object to be cut out, and then obtaining the mixed area of ​​foreground and background in the vicinity of the contour corresponding to the object to be cut out. That is, firstly, a binary graph can be generated according to the target segmented image. The binary graph has two types of foreground 255 and background 0, that is, the foreground is white and the background is black. Then, in this embodiment, since the object to be cut out can be hair, the face and hair parts can be marked as foreground, and the rest are background. Then, the find contours function of opencv is used to find the contour of the foreground part. After finding the contour, a line is drawn on the contour, and then the first contour line is marked as 128 (grayscale) as the mixed area of ​​foreground and background, so that the first image can be obtained. And the find contours function mainly includes a single-channel image matrix, a first vector, a second vector, an index number, a retrieval mode, an approximation method and an offset. The single-channel image matrix can be, but is not limited to, a grayscale image and a binary image, and the binary image is usually a binary image processed by edge detection operators such as Laplace. The first vector is usually a double vector. For each element of the target segmented image, the first vector stores a vector of a set of points consisting of continuous points. Each set of points is a contour, that is, the number of contours is the number of elements in the first vector. For each element of the target segmented image, the second vector stores an array containing 4 int integers. The elements of the target segmented image in the second vector correspond to the elements in the first vector one by one, and the capacity of the vector is the same. The index number can usually be, but is not limited to, the index number of the next contour, the previous contour, the parent contour, or the embedded contour of the i-th contour. If the current contour does not have a corresponding next contour, the previous contour, the parent contour, or the embedded contour, the corresponding bit of the index number is set to the default value -1. The offset is the offset of all contour information relative to the corresponding point of the original image, which is equivalent to adding the offset to each detected contour point.

[0169] It is understandable that the retrieval mode of the contour includes but is not limited to the following value acquisition methods:

[0170] Value 1: Only the outermost contour is detected, and the inner contour contained in the outer contour is ignored;

[0171] Value 2: Detect all contours, including inner and outer contours, but the detected contours are independent of each other and have no hierarchical relationship. This means that there is no parent contour or embedded contour in this retrieval mode, so the 3rd and 4th components of all elements in the second vector will be set to the default value -1;

[0172] Value three: Detect all contours, but only establish two hierarchical relationships among all contours. The outer contour is the top layer. If the inner contour within the outer contour also contains other contour information, all contours within the inner contour belong to the top layer.

[0173] Value 4: Detect all contours and build a hierarchical tree structure for all contours. The outer contour contains the inner contour, and the inner contour can continue to contain embedded contours.

[0174] It is understood that the contour approximation methods include but are not limited to the following methods:

[0175] Value 1: Save all continuous contour points on the object boundary into the first vector;

[0176] Value 2: Only save the inflection point information of the contour, save all the points at the inflection points of the contour into the first vector, and do not retain the information points on the straight line segment between the inflection points.

[0177] For easier understanding, see Figure 8 , Figure 8 FIG. 1 is a schematic diagram of an embodiment of a method for obtaining a first image in an embodiment of the present application. Figure 8 As shown in (A), F11 is the first background area to be updated, F12 is the first foreground area to be updated, and F13 is the first contour line. According to the first contour line F13, the first foreground area to be updated F12 is extended inwardly, and the following can be generated: Figure 8 The first contour area F2 shown in (B) is expanded outward along the first background area F11 to be updated according to the first contour line F13, that is, the following can be generated: Figure 8 The second contour area F3 shown in (C) is obtained by superimposing the first contour area F2 and the second contour area F3. The superimposition process is to add the first contour area F2 and the second contour area F3, and then the following can be obtained: Figure 8In the first mixed area F41 shown in (D), for example, the area of ​​the first contour area is 100 pixels, the area of ​​the second contour area is 120 pixels, and the area of ​​the first mixed area is 220 pixels (i.e., the sum of the area of ​​the first contour area and the area of ​​the second contour area). The first foreground area F12 to be updated and the first contour area F2 are subtracted, and the subtraction process is to subtract the first contour area F2 from the first foreground area F12 to be updated, and then obtain the first foreground area F42 that does not include the first contour area F2, for example, the area of ​​the first contour area is 100 pixels, the area of ​​the first foreground area to be updated is 2000 pixels, and the area of ​​the first foreground area is 1900 pixels (i.e., the difference between the area of ​​the first foreground area to be updated and the area of ​​the first contour area). Similarly, the first background area F11 to be updated and the second contour area F3 are subjected to a subtraction process, and the subtraction process is to subtract the second contour area F3 from the first background area F11 to be updated, and then the first background area F43 excluding the second contour area F3 can be obtained. For example, the area of ​​the second contour area is 120 pixels, the area of ​​the first background area to be updated is 1500 pixels, and the area of ​​the first background area is 1380 pixels (i.e., the difference between the area of ​​the first background area to be updated and the area of ​​the second contour area). Finally, the first mixed area F41, the first foreground area F42 and the first background area F43 obtained through the above-mentioned process can be composed as follows: Figure 8 The first image F4 is shown in (D).

[0178] In an embodiment of the present application, a method for obtaining a first image is provided, wherein a first foreground area to be updated and a first background area to be updated including the object to be cut out are determined according to a target segmented image and an object to be cut out, wherein the first foreground area to be updated includes the object to be cut out, and a first contour line is obtained thereby, and according to the first contour line, the first foreground area to be updated and the first background area to be updated are expanded inwardly or outwardly to generate a first contour area and a second contour area, and a first mixed area, a first foreground area and a first background area are further obtained, and then the first mixed area, the first foreground area and the first background area constitute a first image. In the above manner, the accuracy of the first image can be improved, thereby improving the accuracy of image processing. Moreover, the entire process is automated and does not require manual annotation.

[0179] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiment of the present application, generating a second image according to the target segmented image and the object to be cut out may include:

[0180] Determine a second foreground area to be updated and a second background area to be updated according to the target segmented image and the object to be cut out, wherein the second background area to be updated includes the object to be cut out;

[0181] Obtaining a second contour line corresponding to the second foreground area to be updated;

[0182] According to the second contour line, a third contour area is generated by expanding inward along the second foreground area to be updated;

[0183] According to the second contour line, a fourth contour area is generated by expanding outward along the second background area to be updated;

[0184] The third contour area is superimposed with the fourth contour area to obtain a second mixed area;

[0185] The second foreground area to be updated and the third contour area are removed to obtain a second foreground area;

[0186] The second background area to be updated and the fourth contour area are removed to obtain a second background area.

[0187] In this embodiment, the image processing device determines the second foreground area to be updated and the second background area to be updated according to the target segmented image and the object to be cut out. The method is similar to the method of determining the first foreground area to be updated and the first background area to be updated according to the target segmented image and the object to be cut out, and will not be repeated here.

[0188] For easier understanding, see Fig. 9 , Fig. 9 FIG. 1 is a schematic diagram of an embodiment of a method for obtaining a second image in an embodiment of the present application. Fig. 9 As shown in (A), G11 is the second background area to be updated, G12 is the second foreground area to be updated, and G13 is the second contour line. According to the second contour line G13, the second foreground area to be updated G12 is extended inwardly, and the following can be generated: Fig. 9 The third contour area G2 shown in (B) is expanded outward along the second background area G11 to be updated according to the second contour line G13, that is, the following can be generated: Fig. 9 The fourth contour area G3 shown in (C) is processed by superimposing the third contour area G2 and the fourth contour area G3. The superimposition process adds the third contour area G2 and the fourth contour area G3, and then the following can be obtained: Fig. 9In the second mixed area G41 shown in (D), for example, the area of ​​the third contour area is 300 pixels, the area of ​​the fourth contour area is 400 pixels, and the area of ​​the second mixed area is 700 pixels (i.e., the sum of the area of ​​the third contour area and the area of ​​the fourth contour area). The second foreground area G12 to be updated and the third contour area G2 are subjected to a subtraction process, and the subtraction process is to subtract the third contour area G2 from the second foreground area G12 to be updated, and then obtain the second foreground area G42 that does not include the third contour area G2, for example, the area of ​​the third contour area is 300 pixels, the area of ​​the second foreground area to be updated is 2000 pixels, and the area of ​​the second foreground area is 1700 pixels (i.e., the difference between the area of ​​the second foreground area to be updated and the area of ​​the third contour area). Similarly, the second background area G11 to be updated and the fourth contour area G3 are subjected to a subtraction process, which is to subtract the fourth contour area G3 from the second background area G11 to be updated, and then the second background area G43 excluding the fourth contour area G3 can be obtained. For example, the area of ​​the fourth contour area is 400 pixels, the area of ​​the second background area to be updated is 1500 pixels, and the area of ​​the second background area is 1100 pixels (i.e., the difference between the area of ​​the second background area to be updated and the area of ​​the fourth contour area). Finally, the first mixed area G41, the second foreground area G42, and the second background area G43 obtained through the above process can be composed as follows: Fig. 9 The first image G4 is shown in (D).

[0189] In an embodiment of the present application, a method for acquiring a second image is provided. Through the above method, the accuracy of the second image can be improved, thereby improving the accuracy of image processing.

[0190] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiment of the present application, determining the first cutout image corresponding to the first image and the second cutout image corresponding to the second image according to the first mixed area and the second mixed area may include:

[0191] Generate a first cutout image according to the image to be processed and a first mixed area corresponding to the first image;

[0192] A second cutout image is generated according to the image to be processed and the second mixed area corresponding to the second image.

[0193] In this embodiment, the image processing device can obtain a first cutout image based on the first image and the image to be processed according to the cutout technology, that is, the cutout technology can separate a part of the first image and the image to be processed from other parts, and divide the first image and the image to be processed into two layers, the separated layer becomes the foreground image, and the other parts of the image are called the background image, that is, the foreground information and the background information in the image to be processed can be separated by the cutout technology. Similarly, the second cutout image can also be obtained based on the second image and the image to be processed according to the cutout technology.

[0194] Specifically, a K-nearest neighbor (KNN) matting algorithm is used to generate a first matting image, and a K-nearest neighbor matting algorithm can also be used to generate a second matting image based on the second image and the image to be processed. It should be understood that there is no time sequence limitation for generating the first matting image and the second matting image, that is, the first matting image and the second matting image can be generated at the same time, or the first matting image and the second matting image can be generated one after another. It should be understood that the present embodiment adopts the K-nearest neighbor matting algorithm, but in actual applications, other methods can also be used to generate the first matting image and the second matting image, such as Bayes matting, closed formed matting, and global sampling matting. Several other matting techniques are described below.

[0195] The alpha channel is a linear mixture representation method of foreground and background colors. An image to be processed should contain a foreground image and a background image. Therefore, the image to be processed can be regarded as a composite image of the foreground image and the background image. The alpha of the foreground image is 1, and the alpha of the background image is 0. Therefore, the value of alpha in the image to be processed can be between 0 and 1 to represent the linear combination of the foreground and background images. In most natural images, pixels usually belong to the absolute foreground or the absolute background.

[0196] Bayesian matting can sample related pixels from the domain pixels of the undetermined pixel through domain sampling, use the color value features of image pixels to establish a pixel color model with a directional Gaussian model, and then use the maximum likelihood method to estimate the α value. Closed matting can use the color features of the image through the propagation method, that is, allowing the α value to propagate from the known area to the unknown domain.

[0197] The Laplacian matrix (matting Laplacian matrix) proposed by the closed cutout method is widely used in other cutout methods. For example, the K nearest neighbor cutout algorithm used in this embodiment calculates the α value by taking k nearest points in the feature space to calculate the Laplacian matrix. The K nearest neighbor cutout algorithm, a non-local cutout method, focuses on processing sparser trimaps and does not require additional constraint input. It directly performs segmentation by distinguishing the foreground and background attributes of the image to be processed.

[0198] The Bayesian cutout algorithm is based on the assumption of local color consistency of the image. The closed cutout algorithm presupposes a color linear model. Both the Bayesian cutout algorithm and the closed cutout algorithm presuppose a color distribution model. Considering that color distribution does not necessarily obey a certain model, the image features used by the Bayesian cutout and the closed cutout are color, while the features used by the K-nearest neighbor cutout algorithm are HSV color and pixel coordinates. In addition, more other image features can be added to the K-nearest neighbor cutout algorithm model to increase pixel recognition capabilities.

[0199] In an embodiment of the present application, another image processing method is provided. Through the above method, the pixels of the cutout image can be improved and the details of the image can be refined through the K-nearest neighbor cutout algorithm, thereby improving the accuracy of image processing.

[0200] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiments of the present application, generating a first cutout image according to the image to be processed and the first mixed area corresponding to the first image may include:

[0201] According to the first mixed area corresponding to the first image, obtaining the first color space coordinates and the first space coordinates of the first pixel point from the image to be processed, wherein the first color space coordinates include the hue value, saturation value and brightness corresponding to the first pixel point, and the first space coordinates include the horizontal coordinate and the vertical coordinate corresponding to the first pixel point in the image to be processed;

[0202] According to the first mixed area corresponding to the first image, obtaining the second color space coordinates and the second space coordinates of the second pixel point from the image to be processed, wherein the second color space coordinates include the hue value, saturation value and brightness corresponding to the second pixel point, and the second space coordinates include the horizontal coordinate and the vertical coordinate corresponding to the second pixel point in the image to be processed;

[0203] Calculate a first feature vector corresponding to the first pixel point according to the first color space coordinate and the first space coordinate;

[0204] Calculate and obtain a second eigenvector corresponding to the second pixel point according to the second color space coordinate and the second space coordinate;

[0205] Based on the kernel function, a first similarity matrix is ​​calculated according to the first eigenvector, the second eigenvector and the weight adjustment coefficient;

[0206] A first diagonal matrix is ​​obtained by calculating the first similarity matrix;

[0207] A first Laplace matrix is ​​calculated based on the first similarity matrix and the first diagonal matrix;

[0208] According to the first Laplacian matrix, a first cutout image corresponding to the first image is obtained.

[0209] In this embodiment, the image processing device can obtain the first color space coordinates and the first space coordinates from the image to be processed according to the first mixed area corresponding to the first image. According to the second mixed area corresponding to the second image, the second color space coordinates and the second space coordinates including the horizontal coordinates and the vertical coordinates corresponding to the second pixel point in the image to be processed are obtained from the image to be processed. Then, according to the first color space coordinates and the first space coordinates, and the second color space coordinates and the second space coordinates, the first eigenvector corresponding to the first pixel point and the second eigenvector corresponding to the second pixel point are calculated respectively. Further, based on the kernel function, according to the first eigenvector, the second eigenvector and the weight adjustment coefficient, the first similarity matrix can be calculated, and the first diagonal matrix can be calculated according to the first similarity matrix, and then the first Laplacian matrix can be calculated according to the first similarity matrix and the first diagonal matrix, and finally, according to the calculated first Laplacian matrix, the first cutout image corresponding to the first image is obtained.

[0210] Specifically, this embodiment describes a method for performing matting based on a K-nearest neighbor matting algorithm. The matting technology can separate a portion of the first image and the image to be processed from other portions, and divide the first image and the image to be processed into two layers, the separated layer becomes the foreground image, and the other portions of the image are called the background image, and each pixel in the image is composed of a combination of the foreground color and the background color, wherein the proportion of the foreground color is called the alpha factor. Therefore, the alpha factor can be calculated based on the formula of fine matting, and the specific formula is as follows:

[0211] I = αF + (1-α)β;

[0212] Among them, I represents the original image, F represents the foreground, β represents the background, and α is the transparency (also the alpha value of the pixel). In this formula, these three values ​​are unknown. To understand this formula, the original image can be regarded as a superposition of the foreground and background according to a certain weight (α transparency). The goal of this formula is to solve the alpha value, which represents the proportion of the foreground color. However, according to the above formula, when only I is known, solving F, β and alpha values ​​is an insufficient constraint problem.

[0213] Therefore, in a very small window, for example, a white area is selected, and the white area is a 3*3 window, that is, within the 9 pixels of the white area, there is not much difference between the foreground and the background, so F and β can be assumed to be constant values, or a black area is selected, and the black area is a 2*2 window, that is, within the 4 pixels of the black area, there is not much difference between the foreground and the background, so F and β can be assumed to be constant values. In this way, the problem of insufficient constraints can be solved, and it can be reduced to the following formula, that is, the alpha value is solved in the K nearest neighbor cutout algorithm by the following formula:

[0214]

[0215] Wherein, S represents a manually marked area, S(i) represents a pixel value in the manually marked area, L represents a Laplacian matrix, and i represents the i-th pixel point in the first image.

[0216] The K-nearest neighbor matting algorithm proposes a Laplacian matrix calculation method based on KNN. The specific steps are to calculate the eigenvector, calculate the kernel function, find the similarity matrix and the diagonal matrix, and obtain the matting image through the Laplacian matrix. The following is a detailed introduction to each step:

[0217] The feature vector of pixel i in the image to be processed can be calculated according to the following formula:

[0218] X(i)=(cos(h),sin(h),s,v,x,y);

[0219] Among them, h represents the hue value (hue) corresponding to the pixel point i in the HSV color space coordinates, s represents the saturation value (saturation) corresponding to the pixel point i in the HSV color space coordinates, v represents the brightness (value) corresponding to the pixel point i in the HSV color space coordinates, (x, y) represents the coordinates of the pixel point i in the image to be processed, that is, x represents the horizontal coordinate of the pixel point i in the image to be processed, and y represents the vertical coordinate of the pixel point i in the image to be processed.

[0220] Specifically, this embodiment can obtain the first color space coordinates and the first space coordinates of the first pixel point i1 from the image to be processed according to the first mixed area corresponding to the first image, and the first color space coordinates include the hue value h1, saturation value s1 and brightness v1 corresponding to the first pixel point i1, and the first space coordinates include the horizontal coordinate x1 and the vertical coordinate y1 corresponding to the first pixel point i1 in the image to be processed. It is also possible to obtain the second color space coordinates and the second space coordinates of the second pixel point j1 from the image to be processed according to the first mixed area corresponding to the first image, and the second color space coordinates include the hue value h2, saturation value s2 and brightness v2 corresponding to the second pixel point j1, and the second space coordinates include the horizontal coordinate x2 and the vertical coordinate y2 corresponding to the image to be processed.

[0221] The first eigenvector of the first pixel i1 is expressed as:

[0222] X(i1)=(cos(h1),sin(h1),s1,v1,x1,y1);

[0223] The second eigenvector of the second pixel j1 is expressed as:

[0224] X(j1)=(cos(h2),sin(h2),s2,v2,x2,y2);

[0225] After obtaining the first eigenvector and the second eigenvector, the kernel function needs to be calculated. The kernel function can be calculated according to the following formula:

[0226]

[0227] Among them, C represents the weight adjustment coefficient, which can ensure that k(i,j)∈[0,1],||X(i)-X(j)|| is the 1 norm, that is, the sum of the absolute values ​​of the differences between the two eigenvectors.

[0228] For the first eigenvector and the second eigenvector, the corresponding kernel function is:

[0229]

[0230] Wherein, k(i1,j1) represents the kernel function corresponding to the first eigenvector and the second eigenvector.

[0231] The relationship between the similarity matrix and the kernel function is shown in the following formula:

[0232] Aij=k(i,j);

[0233] Among them, the similarity matrix is ​​another form of the kernel function. According to the kernel function corresponding to the first eigenvector and the second eigenvector, the first similarity matrix is ​​obtained as follows:

[0234] Ai1j1=k(i1,j1);

[0235] The relationship between the diagonal matrix and the similarity matrix is ​​shown as follows:

[0236]

[0237] According to the first similarity matrix Ai1j1, the first diagonal matrix can be obtained:

[0238]

[0239] The relationship between the Laplace matrix, the diagonal matrix and the similarity matrix is ​​shown in the following formula:

[0240] L = DA;

[0241] According to the first similarity matrix and the first diagonal matrix, the first Laplace matrix is ​​calculated:

[0242] L1=Dj1j1-Ai1j1;

[0243] Finally, the first cutout image corresponding to the first image can be obtained according to the first Laplacian matrix L1.

[0244] In an embodiment of the present application, a method for generating a first cutout image is provided. Through the above method, the K nearest neighbor cutout algorithm provides a simple and fast algorithm to generate a higher quality cutout image, thereby improving the pixels of the cutout image and refining the details of the image, thereby improving the accuracy of image processing.

[0245] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiments of the present application, generating a second cutout image according to the image to be processed and the second mixed area corresponding to the second image may include:

[0246] According to the second mixed area corresponding to the second image, obtaining a third color space coordinate and a third space coordinate of a third pixel point from the image to be processed, wherein the third color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the third pixel point, and the third space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the third pixel point in the image to be processed;

[0247] According to the second mixed area corresponding to the second image, obtaining a fourth color space coordinate and a fourth space coordinate of the second pixel point from the image to be processed, wherein the fourth color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the fourth pixel point, and the fourth space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the fourth pixel point in the image to be processed;

[0248] Calculate and obtain a third eigenvector corresponding to the third pixel point according to the third color space coordinate and the third space coordinate;

[0249] Calculate and obtain a fourth eigenvector corresponding to the fourth pixel point according to the fourth color space coordinate and the fourth space coordinate;

[0250] Based on the kernel function, a second similarity matrix is ​​calculated according to the third eigenvector, the fourth eigenvector and the weight adjustment coefficient;

[0251] A second diagonal matrix is ​​obtained by calculating according to the second similarity matrix;

[0252] A second Laplace matrix is ​​obtained by calculation according to the second similarity matrix and the second diagonal matrix;

[0253] According to the second Laplacian matrix, a second cutout image corresponding to the second image is obtained.

[0254] In this embodiment, the way in which the image processing device generates the second cutout image based on the second image and the image to be processed is similar to the way in which the image processing device generates the first cutout image based on the first image and the image to be processed, and will not be elaborated here.

[0255] Specifically, this embodiment can obtain the third color space coordinates and the third spatial coordinates of the third pixel point i2 from the image to be processed according to the second mixed area corresponding to the second image, and the third color space coordinates include the hue value h3, saturation value s3 and brightness v3 corresponding to the third pixel point i2, and the third spatial coordinates include the horizontal coordinate x3 and the vertical coordinate y3 corresponding to the third pixel point i2 in the image to be processed. Secondly, the fourth color space coordinates and the fourth spatial coordinates of the fourth pixel point j2 can also be obtained from the image to be processed according to the second mixed area corresponding to the second image, and the fourth color space coordinates include the hue value h4, saturation value s4 and brightness v4 corresponding to the fourth pixel point j2, and the fourth spatial coordinates include the horizontal coordinate x4 and the vertical coordinate y4 corresponding to the image to be processed.

[0256] The third eigenvector of the third pixel i1 is expressed as:

[0257] X(i2)=(cos(h3),sin(h3),s3,v3,x3,y3);

[0258] The fourth eigenvector of the fourth pixel j1 is expressed as:

[0259] X(j2)=(cos(h4),sin(h4),s4,v4,x4,y4);

[0260] After obtaining the third eigenvector and the fourth eigenvector, the kernel function needs to be calculated. The kernel function can be calculated according to the following formula:

[0261]

[0262] Among them, C represents the weight adjustment coefficient, which can ensure that k(i,j)∈[0,1],||X(i)-X(j)|| is the 1 norm, that is, the sum of the absolute values ​​of the differences between the two eigenvectors.

[0263] Therefore, for the third eigenvector and the fourth eigenvector, the corresponding kernel function is:

[0264]

[0265] Wherein, k(i1,j1) represents the kernel function corresponding to the third eigenvector and the fourth eigenvector.

[0266] The relationship between the similarity matrix and the kernel function is shown as follows:

[0267] Aij=k(i,j);

[0268] Among them, the similarity matrix is ​​another form of kernel function. According to the kernel function corresponding to the third eigenvector and the fourth eigenvector, the second similarity matrix is ​​obtained as follows:

[0269] Ai2j2=k(i2,j2);

[0270] The relationship between the diagonal matrix and the similarity matrix is ​​shown as follows:

[0271]

[0272] According to the second similarity matrix Ai1j1, the second diagonal matrix can be obtained:

[0273]

[0274] The relationship between the Laplace matrix, the diagonal matrix and the similarity matrix is ​​shown in the following formula:

[0275] L = DA;

[0276] According to the second similarity matrix and the second diagonal matrix, the second Laplace matrix is ​​calculated:

[0277] L2=Dj2j2-Ai2j2;

[0278] Finally, the second cutout image corresponding to the second image can be obtained according to the second Laplace matrix L2.

[0279] In an embodiment of the present application, a method for generating a second cutout image is provided, and the K nearest neighbor cutout algorithm provides a simple and fast algorithm to produce a higher quality cutout image, thereby improving the pixels of the cutout image and refining the details of the image, thereby improving the accuracy of image processing.

[0280] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiment of the present application, generating a target cutout image according to the third foreground image in the first cutout image and the fourth foreground image in the second cutout image may include:

[0281] Performing a cutout process on the third foreground image in the first cutout image and the fourth foreground image in the second cutout image to obtain a cutout image;

[0282] The cutout image is denoised to obtain a target cutout image.

[0283] In this embodiment, after acquiring the first cutout image and the second cutout image, the image processing device may perform cutout processing on the first cutout image and the second cutout image to obtain a cutout image, and then perform denoising processing on the obtained cutout image to obtain a target cutout image.

[0284] For easier understanding, see Fig.10 , Fig.10 This is another schematic diagram of the image processing method in the embodiment of the present application, as shown in the figure, Fig.10 The foreground of the first cutout image H1 shown in (A) is a portrait foreground, and Fig.10 The foreground of the second cutout image H2 shown in (B) is the foreground of the portrait without the hair area, so the first cutout image H1 shown in (A) of 10 is combined with Fig.10 The second cutout image H2 shown in (B) is subjected to a cutout process. The cutout process is to subtract the sum of the foreground of the first cutout image H1 and the foreground of the second cutout image H2 from the image. After the subtraction, the hair area can be retained, thereby obtaining the following: Fig.10 In the cutout image H3 shown in (C), due to the noise points existing during segmentation, it can be seen that in the cutout image H3, there are small white dots on the hair matting map. Therefore, it is necessary to perform denoising on the cutout image H3 so as to obtain a noise-free image. Fig.10 The target cutout image H4 is shown in (D).

[0285] In an embodiment of the present application, a method for obtaining a target cutout image is provided. Through the above method, since the cutout image can be denoised, the accuracy of the obtained target cutout image is improved, thereby improving the accuracy of image processing.

[0286] Optionally, in the above Figure 2 On the basis of the corresponding embodiments, in an optional embodiment of the image processing method provided in the embodiments of the present application, denoising the cutout image to obtain the target cutout image may include:

[0287] Generate a binary image based on the cutout image;

[0288] Obtaining the connected area in the background area according to the binary image;

[0289] Determine a connected area according to the connected region, wherein the connected area includes at least one pixel point;

[0290] If the connected area is less than or equal to the connected area threshold, the pixel value corresponding to the pixel point in the connected area is set to the pixel value corresponding to the pixel point in the background area.

[0291] In this embodiment, due to the noise points existing during segmentation, the cutout image may have noise points, so a binary image can be generated based on the cutout image, and then a connected area in the background area is obtained based on the binary image, and a connected area including at least one pixel point is further determined from the connected area, and when the connected area is less than or equal to the connected area threshold, the pixel value corresponding to the pixel point in the connected area is set to the pixel value corresponding to the pixel point in the background area. Finally, the target cutout image can be obtained.

[0292] Specifically, cv2.threshold is used to convert the cutout image into a binary image, where the binary image is a black and white image with foreground 255 and background 0. Then the measure.label function is used to calculate the connected area of ​​the binary image. At this time, multiple connected areas can be obtained, and the connected area including at least one pixel in each connected area is further calculated, and a threshold t is preset through the image to be processed. In this embodiment, the threshold t is 30 as an example. If the connected area is less than 30, then all points in the area with a connected area less than 30 are marked as background 0, that is, processed as black, because the area with a smaller area is often some noise points. Therefore, the noise area in the cutout image can be removed through the above steps, and then the denoised target cutout image can be obtained.

[0293] In an embodiment of the present application, a method for denoising a cutout image is provided, which specifically performs denoising on the cutout image through a binary image and a threshold judgment method, thereby improving the accuracy of the target cutout image obtained, thereby improving the precision of image processing, and secondly, improving the feasibility of the embodiment of the present application.

[0294] In combination with the above introduction, the image synthesis method in this application will be introduced below. Fig.11 , Fig.11 This is a schematic diagram of an embodiment of a method for image synthesis in an embodiment of the present application. As shown in the figure, an embodiment of a method for image synthesis in an embodiment of the present application includes:

[0295] 201. Acquire an image to be processed and an image to be synthesized, wherein the image to be processed includes an object to be cut out;

[0296] In this embodiment, first, the image synthesis device can obtain the image to be synthesized and the image to be processed. It should be noted that the image synthesis device can be deployed on a server or on a terminal device. This application takes deployment on a terminal device as an example for introduction. However, this should not be understood as a limitation on the present application.

[0297] Specifically, the image to be processed may be a photo of person A, the image to be synthesized may be a photo of person B, and the object to be cut out may be person A's hair.

[0298] 202. Acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, and the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, and the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0299] In this embodiment, the image synthesis device can obtain a first foreground area, a first background area and a first mixed area according to the image to be processed, and the first foreground area includes the area corresponding to the object to be cut out, and the first foreground area, the first background area and the first mixed area constitute a first image. Secondly, the second foreground area, the second background area and the second mixed area can also be obtained according to the image to be processed, and the second background area includes the area corresponding to the object to be cut out, and the second foreground area, the second background area and the second mixed area constitute a second image. For details, please refer to Figure 3 The content described is not repeated here.

[0300] 203. Determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0301] In this embodiment, the image synthesis device can obtain a first cutout image corresponding to the first image, including a third foreground area and a third background area, and the third foreground area includes an area corresponding to the object to be cutout. In addition, a second cutout image of a fourth foreground area and a fourth background area corresponding to the second image can also be obtained, and the fourth background area includes an area corresponding to the object to be cutout. It should be understood that in actual applications, since noise points may be generated when the background and foreground are segmented, some noise points may appear in the third background area and the fourth foreground area, and the third background area and the fourth foreground area may include a small part of hair. For details, please refer to Figure 4 The content described is not repeated here.

[0302] 204. Generate a target cutout image according to the third foreground image in the first cutout image and the fourth foreground image in the second cutout image;

[0303] In this embodiment, the image synthesis device can further generate a target cutout image including a region corresponding to the object to be cutout according to the acquired first cutout image and the second cutout image. Figure 5 The content described is not repeated here.

[0304] 205. Using the target cutout image, extracting a region corresponding to the object to be cutout from the image to be processed;

[0305] In this embodiment, the image synthesis device uses the target cutout image to cut out the area corresponding to the object to be cutout from the image to be processed, for example, the area corresponding to the hair.

[0306] 206. Merge the area corresponding to the object to be cut out and the image to be synthesized to obtain a synthesized image.

[0307] In this embodiment, the image synthesis device cuts out the area corresponding to the object to be cut out, for example, the area corresponding to the hair, so that the image to be synthesized can be used as the first layer, and the area corresponding to the hair can be used as the second layer, and the second layer can be covered on the first layer, so that the hair of character B can be displayed on character A.

[0308] In an embodiment of the present application, a method for image synthesis is provided. Through the above-mentioned method, a first image and a second image are obtained respectively using the result obtained after image segmentation, and both the first image and the second image are ternary images. Then, a first cut-out image and a second cut-out image are obtained respectively using a cut-out technique. Compared with the image obtained by segmentation, the first cut-out image and the second cut-out image have a finer structure. After superimposing the two, the object to be cut out can be cut out. The object to be cut out by cutting out the target cut-out image is merged with the image to be synthesized, which can better perform image fusion and improve the synthesis effect of image synthesis.

[0309] The image processing device in this application is described in detail below. Fig.12 , Fig.12 This is a schematic diagram of an embodiment of an image processing device in an embodiment of the present application. The image processing device 30 includes:

[0310] An acquisition module 301 is used to acquire an image to be processed, wherein the image to be processed includes an object to be cut out;

[0311] The acquisition module 301 is further used to acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0312] The acquisition module 301 is further used to determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0313] The generating module 302 is used to generate a target cutout image according to the first cutout image and the second cutout image acquired by the acquiring module 301 .

[0314] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0315] The acquisition module 301 is specifically used to acquire a target segmented image through an image segmentation model based on the image to be processed;

[0316] Generate a first image according to the target segmented image and the object to be cut out;

[0317] A second image is generated according to the target segmented image and the object to be cut out.

[0318] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application, the image segmentation model is a bilateral segmentation network BiSeNet structure;

[0319] An acquisition module 301 is specifically used to acquire a first feature map based on the image to be processed through M convolutional layers included in BiSeNet, where M is an integer greater than or equal to 1;

[0320] Based on the image to be processed, a second feature map is obtained through N pooling layers included in BiSeNet, where N is an integer greater than or equal to 1;

[0321] Based on the first feature map and the second feature map, the target segmentation image is obtained through the feature fusion module included in BiSeNet.

[0322] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0323] The acquisition module 301 is specifically used to determine a first foreground area to be updated and a first background area to be updated according to the target segmented image and the object to be cut out, wherein the first foreground area to be updated includes the object to be cut out;

[0324] Obtaining a first contour line corresponding to a first foreground area to be updated;

[0325] According to the first contour line, a first contour area is generated by expanding inward along the first foreground area to be updated;

[0326] According to the first contour line, a second contour area is generated by expanding outward along the first background area to be updated;

[0327] Superimposing the first contour area with the second contour area to obtain a first mixed area;

[0328] Performing a cutout process on the first foreground area to be updated and the first contour area to obtain a first foreground area;

[0329] The first background area to be updated and the second contour area are removed to obtain a first background area.

[0330] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0331] The acquisition module 301 is specifically used to determine a second foreground area to be updated and a second background area to be updated according to the target segmented image and the object to be cut out, wherein the second background area to be updated includes the object to be cut out;

[0332] Obtaining a second contour line corresponding to the second foreground area to be updated;

[0333] According to the second contour line, a third contour area is generated by expanding inward along the second foreground area to be updated;

[0334] According to the second contour line, a fourth contour area is generated by expanding outward along the second background area to be updated;

[0335] The third contour area is superimposed with the fourth contour area to obtain a second mixed area;

[0336] The second foreground area to be updated and the third contour area are removed to obtain a second foreground area;

[0337] The second background area to be updated and the fourth contour area are removed to obtain a second background area.

[0338] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0339] An acquisition module 301 generates a first cutout image according to the image to be processed and a first mixed area corresponding to the first image;

[0340] A second cutout image is generated according to the image to be processed and the second mixed area corresponding to the second image.

[0341] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0342] The acquisition module 301 is specifically used to acquire the first color space coordinates and the first space coordinates of the first pixel point from the image to be processed according to the first mixed area corresponding to the first image, wherein the first color space coordinates include the hue value, saturation value and brightness corresponding to the first pixel point, and the first space coordinates include the horizontal coordinate and the vertical coordinate corresponding to the first pixel point in the image to be processed;

[0343] According to the first mixed area corresponding to the first image, obtaining the second color space coordinates and the second space coordinates of the second pixel point from the image to be processed, wherein the second color space coordinates include the hue value, saturation value and brightness corresponding to the second pixel point, and the second space coordinates include the horizontal coordinate and the vertical coordinate corresponding to the second pixel point in the image to be processed;

[0344] Calculate a first feature vector corresponding to the first pixel point according to the first color space coordinate and the first space coordinate;

[0345] Calculate and obtain a second eigenvector corresponding to the second pixel point according to the second color space coordinate and the second space coordinate;

[0346] Based on the kernel function, a first similarity matrix is ​​calculated according to the first eigenvector, the second eigenvector and the weight adjustment coefficient;

[0347] A first diagonal matrix is ​​obtained by calculating the first similarity matrix;

[0348] A first Laplace matrix is ​​calculated based on the first similarity matrix and the first diagonal matrix;

[0349] According to the first Laplacian matrix, a first cutout image corresponding to the first image is obtained.

[0350] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0351] The acquisition module 301 is specifically used to acquire the third color space coordinates and the third spatial coordinates of the third pixel point from the image to be processed according to the second mixed area corresponding to the second image, wherein the third color space coordinates include the hue value, saturation value and brightness corresponding to the third pixel point, and the third spatial coordinates include the horizontal coordinate and the vertical coordinate corresponding to the third pixel point in the image to be processed;

[0352] According to the second mixed area corresponding to the second image, obtaining a fourth color space coordinate and a fourth space coordinate of the second pixel point from the image to be processed, wherein the fourth color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the fourth pixel point, and the fourth space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the fourth pixel point in the image to be processed;

[0353] Calculate and obtain a third eigenvector corresponding to the third pixel point according to the third color space coordinate and the third space coordinate;

[0354] Calculate and obtain a fourth eigenvector corresponding to the fourth pixel point according to the fourth color space coordinate and the fourth space coordinate;

[0355] Based on the kernel function, a second similarity matrix is ​​calculated according to the third eigenvector, the fourth eigenvector and the weight adjustment coefficient;

[0356] A second diagonal matrix is ​​obtained by calculating according to the second similarity matrix;

[0357] A second Laplace matrix is ​​obtained by calculation according to the second similarity matrix and the second diagonal matrix;

[0358] According to the second Laplacian matrix, a second cutout image corresponding to the second image is obtained.

[0359] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0360] The generating module 302 is specifically used to perform a cutout process on the third foreground image in the first cutout image and the fourth foreground image in the second cutout image to obtain a cutout image;

[0361] The cutout image is denoised to obtain a target cutout image.

[0362] Optionally, in the above Fig.12 On the basis of the corresponding embodiment, in another embodiment of the image processing device 30 provided in the embodiment of the present application,

[0363] A generating module 302 is specifically used to generate a binary image according to the cutout image;

[0364] Obtaining the connected area in the background area according to the binary image;

[0365] Determine a connected area according to the connected region, wherein the connected area includes at least one pixel point;

[0366] If the connected area is less than or equal to the connected area threshold, the pixel value corresponding to the pixel point in the connected area is set to the pixel value corresponding to the pixel point in the background area.

[0367] The image synthesis device in this application is described in detail below. Fig.13 , Fig.13 This is a schematic diagram of an embodiment of an image synthesis device in an embodiment of the present application. The image synthesis device 40 includes:

[0368] An acquisition module 401 is used to acquire an image to be processed and an image to be synthesized, wherein the image to be processed includes an object to be cut out;

[0369] The acquisition module 401 is further used to acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out;

[0370] The acquisition module 401 is further used to determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout;

[0371] A generating module 402, configured to generate a target cutout image according to the first cutout image and the second cutout image acquired by the acquiring module;

[0372] An extraction module 403 is used to extract a region corresponding to the object to be cut out from the image to be processed using the target cutout image generated by the generation module 402;

[0373] The synthesis module 404 is used to merge the area corresponding to the object to be cut out extracted by the extraction module 403 with the image to be synthesized to obtain a synthesized image.

[0374] The present application also provides another image processing device and an image synthesis device. The image processing device and the image synthesis device can be deployed on an electronic device, which can be a terminal device, such as Fig.14 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The terminal device can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (PDA), a point of sales (POS), a car computer, etc., taking the mobile phone as an example:

[0375] Fig.14 FIG. 1 is a block diagram showing a partial structure of a mobile phone related to a terminal device provided in an embodiment of the present application. Fig.14 The mobile phone includes: a radio frequency (RF) circuit 510, a memory 520, an input unit 530, a display unit 540, a sensor 550, an audio circuit 560, a wireless fidelity (WiFi) module 570, a processor 580, and a power supply 590. Those skilled in the art will understand that Fig.14 The structure of the mobile phone shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Fig.14 A detailed introduction to the various components of the mobile phone:

[0376] The RF circuit 510 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 580 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 510 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 510 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.

[0377] The memory 520 can be used to store software programs and modules. The processor 580 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 520. The memory 520 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 520 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0378] The input unit 530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 530 may include a touch panel 531 and other input devices 532. The touch panel 531, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 531 or near the touch panel 531 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 531 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 580, and can receive and execute commands sent by the processor 580. In addition, the touch panel 531 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 531, the input unit 530 may also include other input devices 532. Specifically, other input devices 532 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.

[0379] The display unit 540 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 540 may include a display panel 541. Optionally, the display panel 541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 531 may cover the display panel 541. When the touch panel 531 detects a touch operation on or near it, it is transmitted to the processor 580 to determine the type of touch event. Subsequently, the processor 580 provides a corresponding visual output on the display panel 541 according to the type of touch event. Although in Fig.14 In the embodiment, the touch panel 531 and the display panel 541 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 531 and the display panel 541 can be integrated to realize the input and output functions of the mobile phone.

[0380] The mobile phone may also include at least one sensor 550, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 541 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 541 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

[0381] The audio circuit 560, the speaker 561, and the microphone 562 can provide an audio interface between the user and the mobile phone. The audio circuit 560 can transmit the received audio data to the speaker 561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 560 and converted into audio data, and then the audio data is output to the processor 580 for processing, and then sent to another mobile phone through the RF circuit 510, or the audio data is output to the memory 520 for further processing.

[0382] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the WiFi module 570. It provides users with wireless broadband Internet access. Fig.14 A WiFi module 570 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.

[0383] The processor 580 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes various functions of the mobile phone and processes data by running or executing software programs and / or modules stored in the memory 520, and calling data stored in the memory 520. Optionally, the processor 580 may include one or more processing units; optionally, the processor 580 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 580.

[0384] The mobile phone also includes a power supply 590 (such as a battery) for supplying power to various components. Optionally, the power supply can be logically connected to the processor 580 through a power management system, so that the power management system can manage charging, discharging, power consumption management, etc. Although not shown, the mobile phone can also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0385] In the embodiment of the present application, the processor 580 included in the terminal device is used to execute the following Figure 2 The corresponding embodiments, or the execution as follows Fig.11 Corresponding embodiments.

[0386] The embodiment of the present application further provides another image processing device and an image synthesis device. The image processing device and the image synthesis device can be deployed on an electronic device, which can be a server. Fig.15 6 is a schematic diagram of a server structure provided in an embodiment of the present application. The server 600 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 622 (for example, one or more processors) and a memory 632, and one or more storage media 630 (for example, one or more mass storage devices) storing application programs 642 or data 644. Among them, the memory 632 and the storage medium 630 may be short-term storage or permanent storage. The program stored in the storage medium 630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 622 may be configured to communicate with the storage medium 630 to execute a series of instruction operations in the storage medium 630 on the server 600.

[0387] The server 600 may also include one or more power supplies 626, one or more wired or wireless network interfaces 650, one or more input and output interfaces 658, and / or one or more operating systems 641, such as Windows Server 2000 or Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM etc.

[0388] The steps performed by the server in the above embodiment can be based on the Fig.15 The server structure shown.

[0389] In the embodiment of the present application, the CPU 622 included in the server is used to execute the following Figure 2 The corresponding embodiments, or the execution as follows Fig.11 Corresponding embodiments.

[0390] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0391] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, 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 integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0392] 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 distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0393] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0394] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0395] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for image processing, characterized in that: include: Acquire an image to be processed, wherein the image to be processed includes an object to be cut out; Acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out; Determining a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout; generating a target cutout image according to the third foreground area in the first cutout image and the fourth foreground area in the second cutout image; Wherein, acquiring the first image and the second image according to the image to be processed includes: Based on the image to be processed, obtaining a target segmented image through an image segmentation model; Generate the first image according to the target segmented image and the object to be cut out; The second image is generated according to the target segmented image and the object to be cut out.

2. The method according to claim 1, characterized in that The step of obtaining a target segmented image based on the image to be processed by using an image segmentation model includes: Based on the image to be processed, obtaining a first feature map through M convolutional layers included in the image segmentation model, wherein M is an integer greater than or equal to 1; Based on the image to be processed, obtaining a second feature map through N pooling layers included in the image segmentation model, wherein N is an integer greater than or equal to 1; Based on the first feature map and the second feature map, the target segmented image is acquired through a feature fusion module included in the image segmentation model.

3. The method according to claim 1, characterized in that The step of generating the first image according to the target segmented image and the object to be cut out comprises: Determine a first foreground area to be updated and a first background area to be updated according to the target segmented image and the object to be cut out, wherein the first foreground area to be updated includes the object to be cut out; Acquire a first contour line corresponding to the first foreground area to be updated; According to the first contour line, a first contour area is generated by expanding inward along the first foreground area to be updated; According to the first contour line, a second contour area is generated by expanding outward along the first background area to be updated; Superimposing the first contour area with the second contour area to obtain the first mixed area; Performing a subtraction process on the first to-be-updated foreground area and the first contour area to obtain the first foreground area; The first background area to be updated and the second contour area are removed to obtain the first background area.

4. The method according to claim 1, characterized in that: The step of generating the second image according to the target segmented image and the object to be cut out comprises: Determine a second foreground area to be updated and a second background area to be updated according to the target segmented image and the object to be cut out, wherein the second background area to be updated includes the object to be cut out; Acquire a second contour line corresponding to the second foreground area to be updated; According to the second contour line, a third contour area is generated by expanding inward along the second foreground area to be updated; According to the second contour line, a fourth contour area is generated by expanding outward along the second background area to be updated; Superimposing the third contour area with the fourth contour area to obtain the second mixed area; Performing a subtraction process on the second foreground area to be updated and the third contour area to obtain the second foreground area; The second background area to be updated and the fourth contour area are removed to obtain the second background area.

5. The method according to claim 1, characterized in that The determining, according to the first mixed area and the second mixed area, a first cutout image corresponding to the first image and a second cutout image corresponding to the second image comprises: generating the first cutout image according to the image to be processed and the first mixed area corresponding to the first image; The second cutout image is generated according to the image to be processed and the second mixed area corresponding to the second image.

6. The method according to claim 5, characterized in that The step of generating the first cutout image according to the image to be processed and the first mixed area corresponding to the first image includes: According to the first mixed area corresponding to the first image, obtaining a first color space coordinate and a first space coordinate of a first pixel point from the image to be processed, wherein the first color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the first pixel point, and the first space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the first pixel point in the image to be processed; According to the first mixed area corresponding to the first image, obtaining a second color space coordinate and a second space coordinate of a second pixel point from the image to be processed, wherein the second color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the second pixel point, and the second space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the second pixel point in the image to be processed; Calculating a first feature vector corresponding to the first pixel point according to the first color space coordinates and the first space coordinates; Calculate and obtain a second eigenvector corresponding to the second pixel point according to the second color space coordinates and the second space coordinates; Based on the kernel function, a first similarity matrix is ​​calculated according to the first eigenvector, the second eigenvector and the weight adjustment coefficient; Calculate a first diagonal matrix according to the first similarity matrix; Calculate a first Laplace matrix according to the first similarity matrix and the first diagonal matrix; According to the first Laplacian matrix, the first cutout image corresponding to the first image is acquired.

7. The method according to claim 5, characterized in that The step of generating the second cutout image according to the image to be processed and the second mixed area corresponding to the second image includes: According to the second mixed area corresponding to the second image, obtaining a third color space coordinate and a third space coordinate of a third pixel point from the image to be processed, wherein the third color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the third pixel point, and the third space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the third pixel point in the image to be processed; According to the second mixed area corresponding to the second image, obtaining a fourth color space coordinate and a fourth space coordinate of the second pixel point from the image to be processed, wherein the fourth color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the fourth pixel point, and the fourth space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the fourth pixel point in the image to be processed; Calculating a third eigenvector corresponding to the third pixel point according to the third color space coordinates and the third space coordinates; Calculating a fourth eigenvector corresponding to the fourth pixel point according to the fourth color space coordinates and the fourth space coordinates; Based on the kernel function, a second similarity matrix is ​​calculated according to the third eigenvector, the fourth eigenvector and the weight adjustment coefficient; Calculate a second diagonal matrix according to the second similarity matrix; Calculate a second Laplace matrix according to the second similarity matrix and the second diagonal matrix; According to the second Laplacian matrix, the second cutout image corresponding to the second image is obtained.

8. The method according to any one of claims 1 to 7, characterized in that Generating a target cutout image according to the third foreground area in the first cutout image and the fourth foreground area in the second cutout image comprises: Performing a cutout process on the third foreground area in the first cutout image and the fourth foreground area in the second cutout image to obtain a cutout image; The cutout image is subjected to denoising processing to obtain the target cutout image.

9. The method according to claim 8, characterized in that The denoising process is performed on the cutout image to obtain the target cutout image, including: Generate a binary image according to the cutout image; Acquire a connected region in the background region according to the binary image; Determining a connected area according to the connected region, wherein the connected area includes at least one pixel point; If the connected area is less than or equal to the connected area threshold, the pixel value corresponding to the pixel point in the connected area is set as the pixel value corresponding to the pixel point in the background area.

10. A method for image synthesis, characterized in that: include: Acquire an image to be processed and an image to be synthesized, wherein the image to be processed includes an object to be cut out; Acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out; Determining a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout; generating a target cutout image according to the third foreground area in the first cutout image and the fourth foreground area in the second cutout image; Using the target cutout image to extract the area corresponding to the object to be cutout from the image to be processed; Merging the area corresponding to the object to be cut out with the image to be synthesized to obtain a synthesized image; Wherein, acquiring the first image and the second image according to the image to be processed includes: Based on the image to be processed, obtaining a target segmented image through an image segmentation model; Generate the first image according to the target segmented image and the object to be cut out; The second image is generated according to the target segmented image and the object to be cut out.

11. An image processing device, characterized in that: include: An acquisition module, used for acquiring an image to be processed, wherein the image to be processed includes an object to be cut out; The acquisition module is further used to acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out; The acquisition module is further used to determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout; a generating module, configured to generate a target cutout image according to the third foreground area in the first cutout image and the fourth foreground area in the second cutout image acquired by the acquiring module; Wherein, the acquisition module is specifically used for: Based on the image to be processed, obtaining a target segmented image through an image segmentation model; Generate the first image according to the target segmented image and the object to be cut out; The second image is generated according to the target segmented image and the object to be cut out.

12. The device according to claim 11, characterized in that The acquisition module is specifically used for: Based on the image to be processed, obtaining a first feature map through M convolutional layers included in the image segmentation model, wherein M is an integer greater than or equal to 1; Based on the image to be processed, obtaining a second feature map through N pooling layers included in the image segmentation model, wherein N is an integer greater than or equal to 1; Based on the first feature map and the second feature map, the target segmented image is acquired through a feature fusion module included in the image segmentation model.

13. The device according to claim 11, characterized in that The acquisition module is specifically used for: Determine a first foreground area to be updated and a first background area to be updated according to the target segmented image and the object to be cut out, wherein the first foreground area to be updated includes the object to be cut out; Acquire a first contour line corresponding to the first foreground area to be updated; According to the first contour line, a first contour area is generated by expanding inward along the first foreground area to be updated; According to the first contour line, a second contour area is generated by expanding outward along the first background area to be updated; Superimposing the first contour area with the second contour area to obtain the first mixed area; Performing a subtraction process on the first to-be-updated foreground area and the first contour area to obtain the first foreground area; The first background area to be updated and the second contour area are removed to obtain the first background area.

14. The device according to claim 11, characterized in that The acquisition module is specifically used for: Determine a second foreground area to be updated and a second background area to be updated according to the target segmented image and the object to be cut out, wherein the second background area to be updated includes the object to be cut out; Acquire a second contour line corresponding to the second foreground area to be updated; According to the second contour line, a third contour area is generated by expanding inward along the second foreground area to be updated; According to the second contour line, a fourth contour area is generated by expanding outward along the second background area to be updated; Superimposing the third contour area with the fourth contour area to obtain the second mixed area; Performing a subtraction process on the second foreground area to be updated and the third contour area to obtain the second foreground area; The second background area to be updated and the fourth contour area are removed to obtain the second background area.

15. The device according to claim 11, characterized in that The acquisition module is specifically used for: generating the first cutout image according to the image to be processed and the first mixed area corresponding to the first image; The second cutout image is generated according to the image to be processed and the second mixed area corresponding to the second image.

16. The device according to claim 15, characterized in that The acquisition module is specifically used for: According to the first mixed area corresponding to the first image, obtaining a first color space coordinate and a first space coordinate of a first pixel point from the image to be processed, wherein the first color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the first pixel point, and the first space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the first pixel point in the image to be processed; According to the first mixed area corresponding to the first image, obtaining a second color space coordinate and a second space coordinate of a second pixel point from the image to be processed, wherein the second color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the second pixel point, and the second space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the second pixel point in the image to be processed; Calculating a first feature vector corresponding to the first pixel point according to the first color space coordinates and the first space coordinates; Calculate and obtain a second eigenvector corresponding to the second pixel point according to the second color space coordinates and the second space coordinates; Based on the kernel function, a first similarity matrix is ​​calculated according to the first eigenvector, the second eigenvector and the weight adjustment coefficient; Calculate a first diagonal matrix according to the first similarity matrix; Calculate a first Laplace matrix according to the first similarity matrix and the first diagonal matrix; According to the first Laplacian matrix, the first cutout image corresponding to the first image is acquired.

17. The device according to claim 15, characterized in that The acquisition module is specifically used for: According to the second mixed area corresponding to the second image, obtaining a third color space coordinate and a third space coordinate of a third pixel point from the image to be processed, wherein the third color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the third pixel point, and the third space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the third pixel point in the image to be processed; According to the second mixed area corresponding to the second image, obtaining a fourth color space coordinate and a fourth space coordinate of the second pixel point from the image to be processed, wherein the fourth color space coordinate includes a hue value, a saturation value, and a brightness corresponding to the fourth pixel point, and the fourth space coordinate includes a horizontal coordinate and a vertical coordinate corresponding to the fourth pixel point in the image to be processed; Calculating a third eigenvector corresponding to the third pixel point according to the third color space coordinates and the third space coordinates; Calculating a fourth eigenvector corresponding to the fourth pixel point according to the fourth color space coordinates and the fourth space coordinates; Based on the kernel function, a second similarity matrix is ​​calculated according to the third eigenvector, the fourth eigenvector and the weight adjustment coefficient; Calculate a second diagonal matrix according to the second similarity matrix; Calculate a second Laplace matrix according to the second similarity matrix and the second diagonal matrix; According to the second Laplacian matrix, the second cutout image corresponding to the second image is obtained.

18. The device according to any one of claims 11 to 17, characterized in that The generating module is specifically used for: Performing a cutout process on the third foreground area in the first cutout image and the fourth foreground area in the second cutout image to obtain a cutout image; The cutout image is subjected to denoising processing to obtain the target cutout image.

19. The device according to claim 18, characterized in that The generating module is specifically used for: Generate a binary image according to the cutout image; Acquire a connected region in the background region according to the binary image; Determining a connected area according to the connected region, wherein the connected area includes at least one pixel point; If the connected area is less than or equal to the connected area threshold, the pixel value corresponding to the pixel point in the connected area is set as the pixel value corresponding to the pixel point in the background area.

20. An image synthesis device, characterized in that: include: An acquisition module, used for acquiring an image to be processed and an image to be synthesized, wherein the image to be processed includes an object to be cut out; The acquisition module is further used to acquire a first image and a second image according to the image to be processed, wherein the first image includes a first mixed area, the second image includes a second mixed area, the first mixed area is an overlapping area between a first foreground area and a first background area in the first image, the second mixed area is an overlapping area between a second foreground area and a second background area in the second image, and the first foreground area corresponds to the second foreground area and an area corresponding to the object to be cut out; The acquisition module is further used to determine a first cutout image corresponding to the first image and a second cutout image corresponding to the second image according to the first mixed area and the second mixed area, wherein the first cutout image includes a third foreground area, the second cutout image includes a fourth foreground area, and the third foreground area corresponds to the fourth foreground area and an area corresponding to the object to be cutout; a generating module, configured to generate a target cutout image according to the third foreground area in the first cutout image and the fourth foreground area in the second cutout image acquired by the acquiring module; An extraction module, configured to extract a region corresponding to the object to be cut out from the image to be processed by using the target cutout image generated by the generation module; A synthesis module, used for merging the area corresponding to the object to be cut out extracted by the extraction module with the image to be synthesized to obtain a synthesized image; Wherein, the acquisition module is specifically used for Based on the image to be processed, obtaining a target segmented image through an image segmentation model; Generate the first image according to the target segmented image and the object to be cut out; The second image is generated according to the target segmented image and the object to be cut out.

21. An electronic device, characterized in that: include: memories, transceivers, processors, and bus systems; Wherein, the memory is used to store programs; The processor is used to execute the program in the memory, including executing the method as described in any one of claims 1 to 9 above, or executing the method as described in claim 10 above; The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.

22. A computer-readable storage medium comprising instructions, which, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 9, or the method according to claim 10.