A cutout processing method, program product, electronic device and storage medium

Through the foreground and background confidence estimator and progressive thinning network, the problem of poor matting effect of transparent objects is solved. By gradually thinning the transparency mask, the accuracy and robustness of matting are improved, and better matting is achieved. Picture effect.

CN118521602BActive Publication Date: 2024-10-29UNIV OF ELECTRONICS SCI & TECH OF CHINA ZHONGSHAN INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410978031.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-10-29
Estimated Expiration
2044-07-22

AI Technical Summary

Technical Problem

Existing matting technology has poor results when dealing with transparent objects. This is mainly due to the translucency of transparent objects, which results in less known information and difficulty in accurately marking foreground pixels, thus affecting the accuracy and effect of matting.

Method used

The foreground-background confidence estimator and the foreground-background guided progressive refinement network are used to obtain the confidence information of the foreground and background through the three-dimensional map, and the transparency mask is gradually refined to improve the accuracy and effect of matting.

Benefits of technology

Through the combination of the foreground and background confidence estimator and the progressive refinement network, more confidence information and multi-scale predictions are provided, which significantly improves the accuracy and effect of transparent object matting and enhances the robustness of matting processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118521602B_ABST
    Figure CN118521602B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for image cutout processing, the method comprising: obtaining a tripartite map corresponding to an image to be processed; inputting the image to be processed and the tripartite map into a foreground-background confidence estimator, predicting pixels in an unknown area, and obtaining a foreground confidence map and a background confidence map; obtaining a temporary transparent mask, a temporary foreground image and a temporary background image by cascading the image to be processed, the tripartite map, the foreground confidence map and the background confidence map into an encoder-decoder; using the foreground-background guided progressive refinement network to obtain a transparency mask, a foreground image and a background image after image cutout processing of the image to be processed according to the temporary transparent mask, the temporary foreground image and the temporary background image. The confidence map provides confidence information that pixels in the unknown area are absolute foreground pixels and absolute background pixels. The transparency mask is gradually refined using the absolute foreground and absolute background information to improve the effect and accuracy of the image cutout processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a cutout processing method, a program product, an electronic device and a storage medium. Background Art

[0002] Image cutout is an important technology in image and video processing and has been widely used in various fields. Image cutout refers to extracting the object of interest from any image, that is, extracting the transparency mask. Current image cutout technology still faces huge challenges in processing transparent objects. The characteristics of transparent objects determine that most of their areas are semi-transparent. This characteristic makes it possible to provide less known information when cutting out transparent objects. Even if the method of using a tripartite map to mark known information as an auxiliary input is adopted, the known foreground information that can be marked is often less, so the effect of image cutout processing is poor. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a cutout processing method, device, electronic device and storage medium for improving the cutout effect of images containing transparent objects.

[0004] In a first aspect, an embodiment of the present application provides a method for cutout processing, comprising: obtaining a tripartite map corresponding to an image to be processed; the tripartite map is used to indicate different areas in the image that need to be processed; the areas include known foreground areas, known background areas, and unknown areas; the tripartite map and the image to be processed are input into a preset foreground-background confidence estimator, and pixels in the unknown areas are predicted to obtain a foreground confidence map and a background confidence map; the foreground confidence map, the background confidence map, the image to be processed, and the tripartite map are feature transformed through an encoder-decoder structure to obtain a temporary image; the temporary image includes a temporary foreground map, a temporary background map, and a temporary transparent mask; and a foreground-background guided progressive refinement network is used to obtain a transparency mask, a foreground image, and a background image after the cutout processing of the image to be processed according to the temporary image.

[0005] In the above implementation process, the foreground confidence map and the background confidence map are obtained based on the trigraph by the foreground-background confidence estimator. The confidence map provides confidence information that the pixels in the unknown area are absolute foreground pixels and absolute background pixels. The foreground-background guided progressive refinement network uses the foreground and background information to help predict the transparency of pixels in the transparent area, and improves the effect and accuracy of the cutout processing by gradually refining the transparency mask.

[0006] Optionally, in an embodiment of the present application, before obtaining the foreground confidence map and the background confidence map, the method further includes: obtaining transparency values ​​of pixels in the unknown area of ​​the sample tri-map and the unknown area of ​​the sample tri-map; and setting the category label of the pixel according to the transparency value; the category label includes a foreground class, a background class and a transparent class; determining a foreground attenuation coefficient and a background attenuation coefficient respectively according to the transparency value; obtaining a weight function according to the number of pixels of the foreground class, the background class and / or the transparent class in the unknown area of ​​the sample tri-map, the weight function including a foreground weight function and a background weight function; obtaining an initial foreground prediction value and an initial background prediction value obtained after predicting the unknown area of ​​the sample tri-map using an initial confidence estimator; performing loss calculation according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain a foreground loss; performing loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain a background loss; training the initial confidence estimator according to the foreground loss and the background loss, adjusting the network parameters of the initial confidence estimator through an optimization algorithm, and obtaining the foreground background confidence estimator.

[0007] In the above implementation process, the foreground background confidence estimator is used to predict the pixels in the unknown area to obtain the foreground confidence map and the background confidence map. The foreground confidence map and the background confidence map provide the confidence information of the absolute foreground and the absolute background of the unknown area in the tri-image, and the subsequent cutout processing operation provides more guidance to improve the effect and accuracy of the cutout processing.

[0008] Optionally, in an embodiment of the present application, a weight function is obtained according to the number of pixels of the foreground class, the background class and / or the transparent class in the unknown area of ​​the sample tripartite map, and the weight function includes a foreground weight function and a background weight function, including: obtaining the foreground weight function according to the number of pixels of the foreground class and the transparent class in the unknown area of ​​the sample tripartite map; obtaining the foreground weight function according to the number of pixels of the background class and the transparent class in the unknown area of ​​the sample tripartite map.

[0009] In the above implementation process, the weight function is determined according to the number of foreground classes, background classes and transparent classes, and the attention paid to each type of pixel in the cutout process is balanced, so that the cutout process is more accurate.

[0010] Optionally, in an embodiment of the present application, performing loss calculation according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss includes: using a foreground loss function to perform loss calculation according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss; wherein the foreground loss function includes:

[0011]

[0012] Represents pixel Prospect loss, represents the foreground weight function, represents the category label, represents the foreground attenuation coefficient, represents the initial outlook forecast value; Representative pixels;

[0013] The step of performing loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain background loss comprises: performing loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value using a background loss function to obtain the background loss; wherein the background loss function comprises:

[0014]

[0015] Represents pixel The background loss, represents the background weight function, represents the category label, represents the background attenuation coefficient, represents the initial background prediction value; Representative Pixels.

[0016] In the above implementation process: by calculating the foreground loss function and the background loss function separately, a clear goal is provided for the optimization process of the foreground-background confidence estimator. By minimizing the loss function, the foreground-background confidence estimator can be optimized so that the predicted value is as close to the true value as possible, thereby improving the effect of the cutout.

[0017] Optionally, in an embodiment of the present application, the foreground-background guided progressive refinement network includes a first-layer refinement module, a second-layer refinement module, and a third-layer refinement module; the foreground-background guided progressive refinement network is used to obtain the transparency mask, foreground image, and background image of the image to be processed after the matting process according to the temporary image, including: obtaining the foreground guide mask of the first layer, the background guide mask of the first layer, and the self-guided mask of the first layer according to the tri-image; the foreground guide mask is used to identify the non-background area; the background guide mask is used to identify the non-foreground area; the self-guided mask is used to identify the transparent area; through the first-layer refinement module, a first-layer foreground image is generated according to the foreground guide mask of the first layer and the temporary foreground image; a first-layer background image is generated according to the background guide mask of the first layer and the temporary background image; and a first-layer transparency mask is generated according to the self-guided mask of the first layer and the temporary transparency mask; a second-layer foreground image is generated according to the first-layer transparency mask The invention relates to a method for generating a plurality of image elements of the plurality of images of the plurality of background images, wherein the plurality of images are subjected to the plurality of filtering modes and the plurality of filtering modes are respectively a plurality of filtering modes and a plurality of filtering modes. The method comprises the steps of: generating a first layer of image elements, a second layer of image elements, a second layer of image elements, a second layer of image elements, a second layer of image elements, a second layer of image elements, a third layer of image elements, a second layer of image elements, a third layer of image elements, a third layer of image elements, a third layer of image elements, a fourth layer of image elements, a fourth layer of image elements, a fourth layer of image elements, a fifth ...

[0018] In the above implementation process: the non-background area of ​​the foreground self-guided mask, the non-foreground area of ​​the background self-guided mask and the transparent area of ​​the self-guided mask are expanded to provide better robustness for the network. In addition, the foreground and background guide the progressive refinement network to predict the absolute foreground and absolute background pixels at multiple scales. The absolute foreground and absolute background information predicted by each layer will help the next layer, thereby gradually refining the transparency mask at multiple scales to improve the quality of the cutout.

[0019] Optionally, in an embodiment of the present application, obtaining a foreground guidance mask of the first layer, a background guidance mask of the first layer, and a self-guiding mask of the first layer according to the tripartite map includes: performing a downsampling operation on the tripartite map to obtain a sampled tripartite map; obtaining a foreground guidance mask of the first layer according to a non-background area in the sampled tripartite map; the non-background area includes the known foreground area and the unknown area; obtaining a background guidance mask of the first layer according to the non-foreground area in the sampled tripartite map; the non-foreground area includes the known background area and the unknown area; obtaining the background guidance mask of the first layer according to the unknown area in the sampled tripartite map.

[0020] In the above implementation process: the non-background area of ​​the foreground self-guided mask, the non-foreground area of ​​the background self-guided mask and the transparent area of ​​the self-guided mask are respectively expanded to provide better robustness for the network.

[0021] Optionally, in an embodiment of the present application, before obtaining the transparency mask, foreground image and background image after the image to be processed is matted out according to the temporary image by using the foreground background to guide the progressive refinement network, the method further includes: obtaining a sample tripartite map and a true foreground value and a true background value of the sample tripartite map and a true value of the transparency mask; obtaining an initial foreground prediction value and an initial background prediction value after predicting the sample tripartite map using an initial refinement network; downsampling the first layer refinement module, the second layer refinement module and the third layer refinement module respectively, calculating a first similarity between the true foreground value and the initial foreground prediction value, and calculating a second similarity between the true background value and the initial background prediction value, to obtain a level loss value; calculating a foreground background loss value according to the level loss value; calculating a transparency mask level loss according to a preset weight of each level in the initial refinement network; adding the foreground background loss value and the transparency mask level loss to obtain a network loss value, and using the network loss value to train the initial refinement network to obtain the foreground background guided progressive refinement network.

[0022] In the above implementation process, by training the foreground and background to guide the progressive refinement network, the multi-level feature information of absolute foreground and absolute background is utilized in the decoding stage to improve the quality of the transparency mask predicted by the quantitative cutout method, so that the transparency mask has a smoother surface and clearer edges.

[0023] In the second aspect, an embodiment of the present application also provides a cutout processing device, including: a tripartite map module, used to obtain a tripartite map corresponding to an image to be processed; the tripartite map is used to indicate different areas in the image that need to be processed; the areas include known foreground areas, known background areas and unknown areas; a confidence estimator module, used to input the tripartite map and the image to be processed into a preset foreground background confidence estimator, predict the pixels in the unknown area, and obtain a foreground confidence map and a background confidence map; an encoding and decoding module, used to perform feature transformation on the foreground confidence map, the background confidence map, the image to be processed and the tripartite map through an encoder-decoder structure to obtain a temporary image; the temporary image includes a temporary foreground image, a temporary background image and a temporary transparent mask; a refinement network module, used to use the foreground background to guide the progressive refinement network to obtain the transparency mask, foreground image and background image of the image to be processed after the cutout processing according to the temporary image.

[0024] In a third aspect, an embodiment of the present application further provides a computer program product, including computer program instructions, which, when executed by a processor, execute the method provided by the first aspect or any one of the implementations of the first aspect.

[0025] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising: a processor and a memory, the memory storing computer program instructions, and the computer program instructions, when executed by the processor, execute the method provided by the first aspect or any one of the implementations of the first aspect.

[0026] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method provided by the first aspect or any one of the implementations of the first aspect is executed.

[0027] The present application provides a method, device, electronic device and storage medium for image cutout processing. A foreground confidence map and a background confidence map are obtained based on a tripartite map and an image to be processed by a foreground-background confidence estimator. The confidence map provides confidence information that pixels in unknown areas of the tripartite map are absolute foreground pixels and absolute background pixels. The foreground-background guided progressive refinement network uses foreground and background information to help predict the transparency of pixels in transparent areas, and improves the effect and accuracy of image cutout processing by gradually refining the transparency mask. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 A schematic diagram of a process flow of a cutout processing method provided in an embodiment of the present application;

[0030] Figure 2 A schematic diagram of a foreground confidence map and a background confidence map provided in an embodiment of the present application;

[0031] Figure 3 The overall flow chart of the transparent object cutout method based on foreground and background prediction provided in the embodiment of the present application;

[0032] Figure 4 A schematic diagram of the structure of a cutout processing device provided in an embodiment of the present application;

[0033] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The following embodiments of the technical solution of the present application are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.

[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0036] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0037] Image matting is a core task in the field of image and video editing. Its wide application covers image synthesis, film post-production, virtual reality, and visual effects. The main purpose of this technology is to predict the transparency mask, that is, the foreground opacity, which is crucial for achieving high-quality image editing. Traditional color key matting technology has been widely used due to its high precision. However, this technology has a significant limitation, that is, it requires the background of the image to be processed to be a pre-set single color. In order to meet this constraint, it is usually necessary to invest a huge amount of manpower and material resources to build a special studio. In order to overcome this problem, researchers began to explore natural image matting technology.

[0038] Unlike color key matting, natural image matting technology is no longer restricted by the image background, and there is no need to set up a solid color curtain when shooting. This allows the matting work to be performed in any natural scene, greatly broadening the application field of matting technology. However, when matting transparent objects, since most areas of transparent objects are semi-transparent, there are only a small number of scattered absolute foreground pixels scattered in them. This feature makes it difficult for these foreground pixels to be accurately marked in the transparent area and provided to the matting network as prior information. The known foreground marked in the tripartite map of the transparent object often has limited contribution to the prediction of the transparency mask, because the characteristics of these areas are not significantly different from those of the transparent area, resulting in poor matting effect.

[0039] It is very important to study the cutout technology of transparent objects, not only because transparent objects are very common in practical applications, but also because improving the cutout performance of transparent objects can also help optimize the cutout effect of opaque objects. For example, when dealing with opaque objects such as people or animals, there are also situations where large transparent areas (such as hair and clothing mesh) need to be predicted.

[0040] A cutout processing method provided in an embodiment of the present application is a transparent object cutout method based on foreground and background prediction, including a foreground background confidence estimator and a foreground background guided progressive refinement network. The foreground background confidence estimator predicts a foreground confidence map and a background confidence map, and provides confidence information that pixels in unknown areas are absolute foreground pixels and absolute background pixels. The foreground background guided progressive refinement network uses foreground and background information at multiple scales to help the next layer, thereby gradually refining the transparency mask at multiple scales.

[0041] See also Figure 1A flowchart of a cutout processing method provided by an embodiment of the present application is shown. The cutout processing method provided by an embodiment of the present application can be applied to an electronic device, which may include a physical device such as a server, a PC, a tablet computer, or a smart phone, or a virtual device such as a virtual machine or a container. The electronic device may be a single device, or a combination of multiple devices or a cluster of a large number of devices. The cutout processing method may include:

[0042] Step S110: obtaining a tripartite map corresponding to the image to be processed; the tripartite map is used to indicate different areas in the image that need to be processed; the areas include a known foreground area, a known background area, and an unknown area.

[0043] Step S120: input the trisection image and the image to be processed into a preset foreground-background confidence estimator, predict the pixels in the unknown area, and obtain a foreground confidence map and a background confidence map.

[0044] Step S130: Concatenate the foreground confidence map, the background confidence map, the image to be processed and the three-part image through the encoder-decoder structure to perform feature transformation to obtain a temporary image; the temporary image includes a temporary foreground image, a temporary background image and a temporary transparent mask.

[0045] Step S140: using the foreground and background to guide the progressive refinement network, according to the temporary image output by the decoder, to obtain the transparency mask, foreground image and background image after the image to be processed is matted.

[0046] In step S110, the image to be processed is an image that needs to be cut out, which may contain some transparent areas. The triplicate map is an image of the same size as the image to be processed, which is used to indicate different areas in the image that need to be processed. For example, the triplicate map divides the image to be processed into three areas: a known foreground area, a known background area, and an unknown area. Among them, the area where the transparency mask true value of the image to be processed is 1 is marked as a known foreground area; the area where the pixel transparency mask true value of the image to be processed is 0 is marked as a known background area; the area where the pixel transparency mask true value of the image to be processed is between 0 and 1 is marked as an unknown area. Among them, the transparency mask is a special image layer or matrix that determines the visibility or transparency of each pixel in the image.

[0047] In step S120, after the image to be processed and its corresponding tripartite map are cascaded, they are used as the input of the foreground background confidence estimator to predict the pixels in the unknown area and output two confidence maps, the foreground confidence map and the background confidence map. The foreground confidence map provides confidence information of the absolute foreground in the unknown area of ​​the tripartite map; the background confidence map provides confidence information of the absolute background in the unknown area of ​​the tripartite map. The foreground confidence map and the background confidence map provide more guidance for the subsequent cutout process. The foreground background confidence estimator is pre-trained, and the specific training process will be introduced later. The backbone network of the foreground background confidence estimator can be a network of the VGG-16 or ResNet series, or other networks.

[0048] See also Figure 2 The schematic diagram of the foreground confidence map and the background confidence map provided by the embodiment of the present application is shown. For example, Figure 2 In the figure, "image" refers to the image to be processed, the triplicate map refers to the triplicate map corresponding to the image to be processed, and the foreground confidence map and background confidence map are obtained after prediction by the foreground and background confidence estimators, respectively. In the visualization of the foreground confidence map and the background confidence map, the whiter the color in the foreground confidence map, the more likely this part of the area is to be the foreground, and the whiter the color in the background confidence map, the higher the confidence level of the background.

[0049] In an optional embodiment, the foreground confidence map, the background confidence map, the image to be processed, and the tri-map may be cascaded to obtain a cascaded image. Cascade processing refers to the operation of connecting or combining multiple images or graphs in a preset manner. This can be achieved through network cascading in deep learning (such as multi-graph cascading in TensorFlow). The cascaded image is then input into the encoder-decoder structure for feature conversion to obtain a temporary image.

[0050] In step S120 and step S130, the encoder-decoder structure includes an encoder and a decoder, wherein the main function of the encoder is to convert the input image data into a low-dimensional representation to capture the key features of the cascaded image. The main function of the decoder is to convert the low-dimensional feature vector output by the encoder back to the original data space to generate a temporary image. The temporary transparency mask refers to a temporary or initial transparency mask.

[0051] The encoder uses the multi-level sliding window Transformer encoder proposed by Swin Transformer. In addition, the prior attention window self-attention module is used to introduce the global prior of the three-part image division into the local window self-attention calculation. The decoder is a convolutional decoder composed of a series of convolutional layers and upsampling layers of ResNet34.

[0052] Step S130 may be performed as follows: in the encoder, the input image is firstly divided into multiple small blocks through the block embedding module and embedded into a high-dimensional space. Then, these embedded blocks are processed by multiple Swin Transformer layers, and high-level features are extracted through local self-attention mechanism and hierarchical downsampling to generate encoding features in a low-dimensional space but with a high number of channels.

[0053] In particular, in this work, the processing results of each encoder layer are also processed through two convolutions, activation functions and normalization operations, and then the features of the lower layer of the decoder are downsampled by deconvolution. Figure 1 Input into the decoder of the same layer.

[0054] In the decoder, the decoder receives the output feature map of the encoder and gradually increases the spatial dimension of the feature map through a series of deconvolution layers or upsampling layers. Then, the features are refined and restored through multiple residual blocks in ResNet34. Finally, through a convolution layer and an appropriate activation function, the feature map is mapped back to the original image space to generate a reconstructed image similar to the original image.

[0055] In step S140, the foreground-background guided progressive refinement network may include multiple layers of refinement modules, each layer of refinement modules uses the transparency mask output by the previous layer of refinement modules to help feature decoding of this layer of refinement modules, thereby achieving the purpose of improving the prediction accuracy of the final transparency mask.

[0056] In the above implementation process, the foreground confidence map and background confidence map are obtained based on the tripartite map and the image to be processed by the foreground-background confidence estimator. The confidence map provides confidence information that the pixels in the unknown area of ​​the tripartite map are absolute foreground pixels and absolute background pixels. The foreground-background guided progressive refinement network uses the foreground and background information to help predict the transparency of pixels in the transparent area, and improves the effect and accuracy of the cutout processing by gradually refining the transparency mask.

[0057] Optionally, in an embodiment of the present application, before obtaining the foreground confidence map and the background confidence map, a foreground background confidence estimator is pre-trained, and the training method includes the following steps:

[0058] (1) Obtain the sample tripartite map, the image to be processed, and the true transparency value of the pixel; and set the category label of the pixel according to the transparency value; the category label includes foreground class, background class, and transparent class. For example, the pixels in the unknown area of ​​the tripartite map will be divided into one of the following three categories: foreground class (denoted as F), background class (denoted as B), and transparent class (denoted as U). The transparency value is denoted as α value, and the pixels with the true α value of 1 will be classified into the foreground class, while the pixels with the true α value of 0 will be classified into the background class, and the pixels with the true α value in the range of (0, 1) will be classified into the transparent class. In an optional embodiment, the foreground class F can represent the absolute foreground class, and the background class F can represent the absolute background class.

[0059] (2) Determine the foreground attenuation coefficient and the background attenuation coefficient according to the transparency value. The value of the foreground attenuation coefficient is equal to the transparency value, and the value of the background attenuation coefficient is equal to (1-transparency value). The specific contents of the foreground attenuation coefficient and the background attenuation coefficient will be introduced later.

[0060] For pixels of foreground class F and background class B, cross entropy loss can be used for prediction. For the true category labels of pixels of foreground class F and background class B, the category label of foreground class F can be set to 1, and the category label of background class B can be set to 0. For pixels of transparent class U, they can be regarded as absolute foreground class in the foreground confidence map prediction process, and their true category label is recorded as 1. They can be regarded as absolute background class in the background confidence map prediction process, and their true category label is recorded as 1.

[0061] (3) Obtain a weight function based on the number of pixels of the foreground class, background class and / or transparent class in the unknown area of ​​the sample trigraph. The weight function includes a foreground weight function and a background weight function. Considering that when the number of pixels belonging to the transparent class U in the unknown area significantly exceeds the number of pixels of the foreground class F, these pixels of the foreground class F can provide less local representation information, it is necessary to pay more attention to the pixels close to the foreground class F in the transparent class U, so as to find more information about features close to the absolute foreground. When the number of pixels of the foreground class F is much larger than the number of pixels belonging to the transparent class U in the unknown area, the pixels of the foreground class F can provide more useful information, so it is necessary to pay more attention to the pixels of the foreground class F. Therefore, the information of the foreground class F and the transparent class U can be balanced by using a weight function. The same is true for the background weight function. The specific contents of the foreground weight function and the background weight function will be introduced later.

[0062] (4) Obtaining an initial foreground prediction value and an initial background prediction value after using the initial confidence estimator to predict the sample triplicate image and the image to be processed; the initial foreground prediction value and the initial background prediction value can be used to reflect the current state of the initial confidence estimator so as to train and optimize the initial confidence estimator.

[0063] (5) The loss is calculated based on the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss. And (6) The loss is calculated based on the background attenuation coefficient, the background weight function and the initial background prediction value to obtain the background loss. It can be understood that the foreground loss refers to the foreground confidence loss; the background loss refers to the background confidence loss. The foreground loss is used to measure the difference between the initial foreground prediction value of the model and the true transparency value of the foreground class; the background loss is used to measure the difference between the initial background prediction value of the model and the true transparency value of the background class.

[0064] (7) The initial confidence estimator is trained according to the foreground loss and the background loss, and the network parameters of the initial confidence estimator are adjusted through the optimization algorithm to obtain the foreground-background confidence estimator. By minimizing the loss function (i.e., the foreground loss and the background loss), the initial confidence estimator can continuously improve its parameters, thereby optimizing its prediction performance and obtaining the final trained foreground-background confidence estimator. The trained foreground-background confidence estimator can be used to predict new images, such as the image to be processed and its corresponding tripartite map.

[0065] In the implementation process of the above embodiment: the pixels in the unknown area are predicted through the foreground background confidence estimator to obtain the foreground confidence map and the background confidence map. The foreground confidence map and the background confidence map provide confidence information of the absolute foreground and the absolute background of the unknown area in the tri-image, and the subsequent cutout processing operation provides more guidance to improve the effect and accuracy of the cutout processing.

[0066] Optionally, in an embodiment of the present application, a weight function is obtained according to the number of pixels of the foreground class, the background class and / or the transparent class in the sample three-part image, and the weight function includes a foreground weight function and a background weight function, including: obtaining a foreground weight function according to the number of pixels of the foreground class and the transparent class in the sample three-part image. The foreground weight function includes:

[0067]

[0068]

[0069] in, represents the foreground weight function, Used to limit the result range of the weight function, represents the number of pixels in the foreground class F, represents the number of pixels in the transparent class U, Representative pixels, represents the foreground class, and U represents the transparent class.

[0070] According to the number of background and transparent pixels in the sample three-part image, the foreground weight function is obtained. The foreground weight function includes:

[0071]

[0072]

[0073] in, represents the foreground weight function, Used to limit the result range of the weight function, represents the number of pixels in the background class B, represents the number of pixels in the transparent class U, Representative pixels, Represents the background class, and U represents the transparent class.

[0074] In the implementation process of the above embodiment: a weight function is determined according to the number of foreground classes, background classes and transparent classes, and the attention paid to each type of pixel in the cutout process is balanced, so that the cutout process is more accurate.

[0075] Optionally, based on the true transparency value, obtain the foreground attenuation coefficient and background attenuation coefficient. include:

[0076]

[0077] Background attenuation coefficient include:

[0078]

[0079] in, Represents the true transparency value.

[0080] Optionally, in the embodiment of the present application, the loss is calculated according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss, including:

[0081] The foreground loss function is used to calculate the loss according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss; wherein the foreground loss function includes:

[0082]

[0083] Represents pixel Prospect loss, represents the foreground weight function, represents the category label, represents the foreground attenuation coefficient, represents the initial outlook forecast value; Representative Pixels.

[0084] Similar to the foreground confidence map, for the background confidence map, when pixel i belongs to the background class B, its true category label is recorded as 1, when pixel i belongs to the foreground class F, its true category label is recorded as 0, and when pixel i belongs to the transparent class U, its true category label is recorded as 1, that is, the transparent class is regarded as the absolute background class. At the same time, the background attenuation coefficient is also introduced, and the value of the background attenuation coefficient is equal to (1-transparency value).

[0085] The loss is calculated according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain the background loss, including: using the background loss function to calculate the loss according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain the background loss; wherein the background loss function includes:

[0086]

[0087] Represents pixel The background loss, represents the background weight function, represents the category label, represents the background attenuation coefficient, represents the initial background prediction value; Representative Pixels.

[0088] Foreground loss function for comprehensive foreground confidence map and the background loss function of the background confidence map , the total loss of the foreground-background confidence estimator is as follows:

[0089]

[0090] in, represents the total loss of the foreground-background confidence estimator, represents the foreground loss function, Represents the background loss function.

[0091] In the implementation process of the above embodiment: by calculating the foreground loss function and the background loss function respectively, a clear goal is provided for the optimization process of the foreground background confidence estimator. By minimizing the loss function, the foreground background confidence estimator can be optimized so that the predicted value is as close to the true value as possible, thereby improving the effect of the cutout.

[0092] Optionally, in an embodiment of the present application, a foreground-background guided progressive refinement network includes a first-layer refinement module and a subsequent-layer refinement module; wherein the subsequent-layer refinement module is executed after the first-layer refinement module, and the subsequent-layer refinement module may include one or more, for example, the subsequent-layer refinement module may include a second-layer refinement module and a third-layer refinement module, and may also include more or fewer refinement modules, so that multi-level feature information of absolute foreground and absolute background can be utilized in the decoding stage.

[0093] Using the foreground background to guide the progressive refinement network, according to the temporary image, a transparency mask, a foreground image and a background image after the image to be processed is obtained, including the following steps:

[0094] For the subsequent layer refinement modules, the foreground guide mask and the background guide mask are generated based on the transparency mask output by the previous layer refinement module. For example, the foreground guide mask of the second layer and the background guide mask of the second layer can be generated based on the transparency mask of the first layer output by the first layer refinement module. However, since the first layer refinement module (i.e., the bottom layer refinement module) does not have a transparency mask, the foreground guide mask of the first layer, the background guide mask of the first layer, and the self-guided mask of the first layer are generated based on the trisection map.

[0095] The foreground guide mask of the first layer, the background guide mask of the first layer and the self-guided mask of the first layer can be obtained according to the tri-map; the foreground guide mask is used to identify the non-background area; the background guide mask is used to identify the non-foreground area; and the self-guided mask is used to identify the transparent area.

[0096] Then, through the first layer refinement module, a first layer foreground image is generated according to the foreground guide mask of the first layer and the temporary foreground map; a first layer background image is generated according to the background guide mask of the first layer and the temporary background map; and a first layer transparency mask is generated according to the self-guided mask of the first layer and the transparency mask and the tri-map. Exemplarily: the foreground guide mask of the first layer and the temporary foreground map are multiplied to generate the first layer foreground image; the background guide mask of the first layer and the temporary background map are multiplied to generate the first layer background image; and the self-guided mask of the first layer and the transparency mask are multiplied and added to the product of the inverse of the self-guided mask and the tri-map to generate the first layer transparency mask.

[0097] After the first layer transparency mask is generated, the foreground guide mask, background guide mask and self-guided mask of the subsequent layers can be generated according to the first layer transparency mask. Here, it can be the foreground guide mask of the second layer, the background guide mask of the second layer and the self-guided mask of the second layer. This involves upsampling operation. The foreground guide mask is generated as follows:

[0098]

[0099] in, Represents the transparency mask of the first layer (L-1 layer), represents the foreground guidance mask of the subsequent layer (L layer), Represents the transparency value of the pixels in the first layer (layer L-1). It can represent the position of a pixel.

[0100] The background guidance mask is generated as follows:

[0101]

[0102] in, Represents the transparency mask of the first layer (L-1 layer), represents the background guidance mask of the subsequent layer (L layer), Represents the transparency value of the pixels in the first layer (layer L-1). It can represent the position of a pixel.

[0103] According to the self-guided mask of the second layer, the transparency mask of the first layer is updated to obtain the transparency mask of the second layer; according to the foreground guide mask of the second layer, the foreground image of the first layer is updated to obtain the foreground image of the second layer; and according to the background guide mask of the second layer, the background image of the first layer is updated to obtain the background image of the second layer. As an updating implementation method, the image corresponding to the foreground guide mask of the second layer can be used as the foreground image of the second layer after the first layer foreground image is updated.

[0104] Taking the foreground-background guided progressive refinement network including the first-layer refinement module, the second-layer refinement module and the third-layer refinement module as an example, after generating the second-layer self-guided mask, the second-layer transparency mask is generated according to the second-layer self-guided mask through the second-layer refinement module; then the third-layer self-guided mask is generated according to the second-layer transparency mask, and the third-layer transparency mask is generated according to the third-layer self-guided mask through the third-layer refinement module, that is, the transparency mask of the image to be processed after the matting processing output by the foreground-background guided progressive refinement network.

[0105] In the implementation process of the above embodiment: the foreground area and the background area are respectively expanded to obtain the non-background area and the non-foreground area, providing better robustness for the network. And the foreground and background guide the progressive refinement network to predict the absolute foreground and absolute background pixels at multiple scales. The absolute foreground and absolute background information predicted by each layer will help the next layer, thereby gradually refining the transparency mask at multiple scales to improve the quality of the cutout.

[0106] Optionally, in an embodiment of the present application, obtaining a foreground guide mask of the first layer, a background guide mask of the first layer, and a self-guide mask of the first layer according to the trisection map includes the following steps:

[0107] Downsampling is performed on the triplicate image to obtain a sampled triplicate image. In image processing, downsampling reduces the complexity and amount of computation of data processing by reducing the resolution or size of the image (i.e., reducing the number of pixels). The specific size of the downsampling operation can be set according to requirements.

[0108] According to the non-background area in the sampled triplicate image, a foreground guidance mask of the first layer is obtained; the non-background area includes a known foreground area and an unknown area; according to the non-foreground area in the sampled triplicate image, a background guidance mask of the first layer is obtained; the non-foreground area includes a known background area and an unknown area; according to the unknown area in the sampled triplicate image, a background guidance mask of the first layer is obtained.

[0109] In the implementation process of the above embodiment: before obtaining the foreground guided mask of the first layer, the background guided mask of the first layer and the self-guided mask of the first layer, the foreground area and the background area are respectively expanded to obtain the non-background area and the non-foreground area, so as to provide better robustness for the network.

[0110] Optionally, in the embodiment of the present application, before using the foreground background to guide the progressive refinement network to obtain the transparency mask, the foreground image and the background image after the image to be processed is matted according to the temporary image, the method further includes:

[0111] The true foreground value of the foreground image and the true background value of the background image are obtained. The above-mentioned downsampling operation can also be performed on the true foreground image and the background image. The true foreground value and the true background value are used to supervise the foreground image and the background image output by the Lth layer.

[0112] The initial foreground prediction value and the initial background prediction value are obtained after processing the temporary foreground prediction value and the temporary background prediction value using the initial refinement network.

[0113] The layer loss value is obtained by calculating a first similarity between the true foreground value and the initial foreground prediction value, and calculating a second similarity between the true background value and the initial background prediction value.

[0114] The calculation formula of the layer loss value includes:

[0115]

[0116] in, Represents the layer loss value of the Lth layer, represents the regression loss, represents the true foreground value, represents the foreground guidance mask of layer L, represents the initial outlook forecast value, represents the true background value, represents the background guidance mask of layer L, represents the initial background prediction value.

[0117] In the formula, the first half ( ) is the first similarity, the second half is the second similarity.

[0118] Regression Loss The calculation formula is:

[0119]

[0120] in, represents the predicted value, Represents the number of pixels, represents the true value, Representative pixels.

[0121] According to the layer loss values, the foreground-background loss values ​​are calculated; for example, the layer loss values ​​of the three layers are added together to obtain the foreground-background loss values.

[0122] According to the preset weights of each level in the initial refinement network, the transparency mask level loss is calculated, for example, the first layer transparency mask, the second layer transparency mask and the third layer transparency mask are upsampled to the input size, and the similarity, synthesis loss and Laplace loss are calculated with the true transparency value respectively. The preset weights of each level in the initial refinement network add the similarity, synthesis loss and Laplace loss of the transparency mask of each level to calculate the transparency mask level loss.

[0123] The network loss value is obtained by adding the foreground background loss value and the transparency mask level loss, and the initial refinement network is trained using the network loss value to obtain the foreground background guided progressive refinement network. Since the loss function is applied to each output of each semantic level, that is, the loss function is applied to each output of the refinement module of each layer, the total loss of the foreground background loss value is calculated using the following expression:

[0124]

[0125] in, Represents the foreground background loss value, Represents the layers of the foreground-background guided progressive refinement network, Represents the preset weight of each level, Represents the layer loss value of the Lth layer.

[0126] The network loss value is obtained by adding the foreground-background loss value and the transparency mask level loss. The network loss value is used to train the initial refinement network to obtain the foreground-background guided progressive refinement network.

[0127] In an optional embodiment, the foreground and background progressive refinement modules are set to work at output layers of 1 / 8, 1 / 4 and 1 / 1 of the original size respectively. Different from the processing of the transparency mask, because the transparency mask is to upsample the output to the original size to calculate the loss, while the foreground and background are to downsample the true value to the output size for loss calculation, so the loss weights of each layer of the foreground and background can be set to: w0: w1: w2 = 1: 1: 1. w0 is the weight of the first layer refinement module, w1 is the weight of the second layer refinement module, and w2 is the weight of the third layer refinement module.

[0128] In the implementation process of the above embodiment: by training the foreground background to guide the progressive refinement network, the multi-level feature information of the absolute foreground and absolute background is utilized in the decoding stage to improve the quality of the transparency mask predicted by the quantitative cutout method, so that the transparency mask has a smoother surface and clearer edges.

[0129] In an optional embodiment, the transparent object cutout method based on absolute foreground and background prediction uses three loss functions to calculate the loss of the transparency mask. The three loss functions are: regression loss , synthetic loss , and the Laplace loss . The actual transparency value is , the predicted transparency value is , the transparency value is the transparency mask value. The transparency loss function of the network is recorded as :

[0130] =

[0131] The synthetic loss , is to represent the absolute difference between the real RGB value of the image and the predicted RGB value, which are obtained by the cutout formula. For the sake of derivability, a small value is added, and the weight of each pixel is set to 1 in the unknown area and set to 0 in the known foreground and background areas of the triplicate image:

[0132]

[0133] in, represents the synthetic loss, represents the predicted RGB value, Represents the true RGB value, represents the weight of each pixel (in the range [0,1]), Represents a differentiable value.

[0134] Laplace loss function The Laplacian function is defined as the absolute difference between two Laplacian pyramid representations. This loss function can capture both local and global differences, and the contribution of each Laplacian level to the loss is scaled according to its spatial size.

[0135] For the prediction of the transparency mask, the predicted transparency mask is also output at the output layer of 1 / 8, 1 / 4 and 1 / 1 of the original size. First, the transparency mask output of all levels is upsampled to the input size to match the size. For the current level l, we use the following function to extract the cutout output from the previous level , follow the following function to generate the bootstrap mask:

[0136]

[0137] in, Represents the transparency mask of the first layer (L-1 layer), represents the bootstrap mask, Represents the transparency value of the pixels in the first layer (layer L-1). It can represent the position of a pixel.

[0138] Bootstrap Mask The transparent area (i.e., 0<α<1) is defined as unknown, and the unknown area of ​​αl−1 is replaced by the original output α of the current level to obtain the updated αl ∈ R of the current level. The process is expressed as the following formula, where the symbol ⊙ represents pixel-level multiplication.

[0139]

[0140] in, represents the updated transparency value of the current level, Represents the temporary transparency mask of the current level. represents the bootstrap mask, Represents the transparency value of the previous layer.

[0141] According to the above steps, the final outputs of transparency masks at different levels are obtained, α0, α1 and α2. Then, these outputs at different levels are supervised, and the final total transparency loss is expressed as follows:

[0142]

[0143] in, Represents the final total transparency loss, Represents the preset weight of each level, represents the bootstrap mask, Represents the true transparency value, Represents the predicted transparency value. The weight parameters of each layer in the initial refinement network are expressed as w0: w1: w2 = 1: 2: 3, and L represents the layer loss value.

[0144] In an alternative embodiment, see Figure 3 The overall flow chart of the transparent object cutout method based on foreground and background prediction provided by the embodiment of the present application is shown.

[0145] The transparent object cutout method based on absolute foreground and background prediction first uses an image and the corresponding tripartite map as input, and then outputs a transparency mask, a foreground and a background image. The transparent object cutout method based on absolute foreground and background prediction consists of four modules: foreground-background confidence estimator, Transformer encoder, convolutional neural network decoder and foreground-background guided progressive refinement network. The foreground-background confidence estimator is used to estimate the confidence of the absolute foreground and absolute background in the unknown area of ​​the tripartite map. The Transformer encoder extracts the features required for the cutout task, and the convolutional neural network decoder converts the features into the results of transparency mask, foreground and background. The foreground-background guided progressive refinement network gradually refines the output at different semantic layers to help the decoder produce the final prediction result.

[0146] The foreground-background confidence estimator uses the image and its corresponding tripartite map as input, and outputs two confidence maps, the foreground confidence map and the background confidence map. These two confidence maps provide confidence information of the absolute foreground and absolute background in the unknown area of ​​the tripartite map, providing more guidance for the subsequent cutout work. Next, the foreground confidence map and the background confidence map will be cascaded with the input image and the corresponding tripartite map and then input into the subsequent cutout network.

[0147] See also Figure 4 The structure diagram of the cutout processing device provided in the embodiment of the present application is shown; the embodiment of the present application provides a cutout processing device 200, including:

[0148] The tripartite map module 210 is used to obtain a tripartite map corresponding to the image to be processed; the tripartite map is used to indicate different areas in the image that need to be processed; the areas include a known foreground area, a known background area, and an unknown area;

[0149] A confidence estimator module 220, configured to input the trisection map and the image to be processed into a preset foreground-background confidence estimator, predict the pixels in the unknown area, and obtain a foreground confidence map and a background confidence map;

[0150] The encoding and decoding module 230 is used to perform feature conversion on the foreground confidence map, the background confidence map, the image to be processed and the tri-image through an encoder-decoder structure to obtain a temporary image; the temporary image includes a temporary foreground image, a temporary background image and a temporary transparent mask;

[0151] The refinement network module 240 is used to use the foreground and background to guide the progressive refinement network to obtain the transparency mask, foreground image and background image of the image to be processed after the matting process according to the temporary image.

[0152] Optionally, in an embodiment of the present application, the cutout processing device 200 further includes: a training confidence estimator module, which is used to obtain the transparency value of pixels in the sample tri-image and the image to be processed; and set the category label of the pixel according to the transparency value; the category label includes a foreground class, a background class and a transparent class; determine the foreground attenuation coefficient and the background attenuation coefficient respectively according to the transparency value; obtain a weight function according to the number of pixels of the foreground class, the background class and / or the transparent class in the sample tri-image, and the weight function includes a foreground weight function and a background weight function; obtain an initial foreground prediction value and an initial background prediction value obtained after predicting the sample tri-image using an initial confidence estimator; perform loss calculation according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain a foreground loss; perform loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain a background loss; train the initial confidence estimator according to the foreground loss and the background loss, adjust the network parameters of the initial confidence estimator through an optimization algorithm, and obtain the foreground background confidence estimator.

[0153] Optionally, in an embodiment of the present application, the cutout processing device 200, the training confidence estimator module, is also used to obtain the foreground weight function according to the number of pixels of the foreground class and the transparent class in the sample tri-image; and obtain the foreground weight function according to the number of pixels of the background class and the transparent class in the sample tri-image.

[0154] Optionally, in the embodiment of the present application, the cutout processing device 200, the training confidence estimator module, is further used to use a foreground loss function to perform loss calculation according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss; wherein the foreground loss function includes:

[0155]

[0156] Represents pixel Prospect loss, represents the foreground weight function, represents the category label, represents the foreground attenuation coefficient, represents the initial outlook forecast value; Representative pixels;

[0157] The step of performing loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain background loss comprises: performing loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value using a background loss function to obtain the background loss; wherein the background loss function comprises:

[0158]

[0159] Represents pixel The background loss, represents the background weight function, represents the category label, represents the background attenuation coefficient, represents the initial background prediction value; Representative Pixels.

[0160] Optionally, in an embodiment of the present application, the cutout processing device 200, the foreground-background guided progressive refinement network includes a first-layer refinement module, a second-layer refinement module and a third-layer refinement module; the refinement network module 250 is further used to obtain a first-layer foreground guide mask, a first-layer background guide mask and a first-layer self-guided mask according to the tri-map; the foreground guide mask is used to identify a non-background area; the background guide mask is used to identify a non-foreground area; the self-guided mask is used to identify a transparent area; through the first-layer refinement module, a first-layer foreground image is generated according to the foreground guide mask of the first layer and the temporary foreground map; a first-layer background image is generated according to the background guide mask of the first layer and the temporary background map; and a first-layer transparency mask is generated according to the self-guided mask of the first layer and the temporary transparency mask; a second-layer foreground guide mask, a first-layer background mask and a first-layer background mask are generated according to the first-layer transparency mask. The second layer of background guide mask and the second layer of self-guided mask; according to the second layer of self-guided mask, the first layer of transparency mask is updated to obtain the second layer of transparency mask; according to the second layer of foreground guide mask, the first layer of foreground image is updated to obtain the second layer of foreground image; and according to the second layer of background guide mask, the first layer of background image is updated to obtain the second layer of background image; according to the second layer of transparency mask, the third layer of foreground guide mask, the third layer of background guide mask and the third layer of self-guided mask are generated; according to the third layer of self-guided mask, the second layer of transparency mask is updated to obtain the transparency mask; according to the third layer of foreground guide mask, the second layer of foreground image is updated to obtain the foreground image; and according to the third layer of background guide mask, the second layer of background image is updated to obtain the background image.

[0161] Optionally, in an embodiment of the present application, the cutout processing device 200 and the refinement network module 250 are further used to perform a downsampling operation on the tri-map to obtain a sampled tri-map; based on the non-background area in the sampled tri-map, a foreground guidance mask of the first layer is obtained; the non-background area includes the known foreground area and the unknown area; based on the non-foreground area in the sampled tri-map, a background guidance mask of the first layer is obtained; the non-foreground area includes the known background area and the unknown area; based on the unknown area in the sampled tri-map, a background guidance mask of the first layer is obtained.

[0162] Optionally, in the embodiment of the present application, the cutout processing device 200 further includes a thinning network training module, which is used for obtaining the transparency mask, the foreground image and the background image after the cutout processing of the image to be processed according to the temporary image by using the foreground background to guide the progressive thinning network. The method further includes: obtaining a sample trisection map and the true foreground value and the true background value and the true value of the transparency mask; obtaining an initial foreground prediction value and an initial background prediction value after predicting the sample trisection map using the initial thinning network; and for the first layer thinning module, the second layer thinning module and the third layer thinning module. The first and second similarities between the true foreground value and the initial foreground prediction value are calculated, and the second similarities between the true background value and the initial background prediction value are calculated to obtain a level loss value; a foreground background loss value is calculated according to the level loss value; a transparency mask level loss is calculated according to the preset weight of each level in the initial refinement network; a network loss value is obtained by adding the foreground background loss value and the transparency mask level loss, and the initial refinement network is trained using the network loss value to obtain the foreground background guided progressive refinement network.

[0163] It should be understood that the device corresponds to the above-mentioned cutout processing method embodiment and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be found in the description above. To avoid repetition, the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.

[0164] See also Figure 5 The electronic device 300 provided in the embodiment of the present application includes: a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and when the machine-readable instructions are executed by the processor 310, the above method is executed.

[0165] An embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above method is executed.

[0166] Among them, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0167] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0168] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.

[0169] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.

Claims

1. A cutout processing method, characterized in that: include: Obtaining a tripartite map corresponding to the image to be processed; the tripartite map is used to indicate different areas in the image that need to be processed; The area includes a known foreground area, a known background area and an unknown area; Inputting the trisection image and the image to be processed into a preset foreground-background confidence estimator, predicting the pixels in the unknown area, and obtaining a foreground confidence map and a background confidence map; Performing feature transformation on the foreground confidence map, the background confidence map, the image to be processed and the tri-image through an encoder-decoder structure to obtain a temporary image; the temporary image includes a temporary foreground image, a temporary background image and a temporary transparent mask; Using the foreground and background to guide the progressive refinement network, according to the temporary image, obtain the transparency mask, the foreground image and the background image after the image to be processed is matted; Before obtaining the foreground confidence map and the background confidence map, the method further includes: Obtaining transparency values ​​of pixels in the unknown region of the sample tri-image and the unknown region of the sample tri-image; and setting category labels of the pixels according to the transparency values; the category labels include foreground class, background class and transparent class; Determine a foreground attenuation coefficient and a background attenuation coefficient respectively according to the transparency value; According to the number of pixels of the foreground class, the background class and / or the transparent class in the unknown area of ​​the sample trigraph, a weight function is obtained, where the weight function includes a foreground weight function and a background weight function; Obtaining an initial foreground prediction value and an initial background prediction value obtained after predicting the unknown area of ​​the sample trigraph using an initial confidence estimator; Perform loss calculation according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain a foreground loss; Perform loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain background loss; The initial confidence estimator is trained according to the foreground loss and the background loss, and the network parameters of the initial confidence estimator are adjusted through an optimization algorithm to obtain the foreground-background confidence estimator.

2. The method according to claim 1, characterized in that The step of obtaining a weight function according to the number of pixels of the foreground class, the background class and / or the transparent class in the unknown area of ​​the sample trigraph, wherein the weight function includes a foreground weight function and a background weight function, comprises: Acquire the foreground weight function according to the number of pixels of the foreground class and the transparent class in the unknown area of ​​the sample tri-image; The background weight function is obtained according to the number of pixels of the background class and the transparent class in the unknown area of ​​the sample tri-image.

3. The method according to claim 1, characterized in that The loss is calculated according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss, including: Using a foreground loss function, a loss calculation is performed according to the foreground attenuation coefficient, the foreground weight function and the initial foreground prediction value to obtain the foreground loss; wherein the foreground loss function includes: Represents pixel Prospect loss, represents the foreground weight function, represents the category label, represents the foreground attenuation coefficient, represents the initial outlook forecast value; Representative pixels; The step of performing loss calculation according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain background loss includes: Using a background loss function, a loss calculation is performed according to the background attenuation coefficient, the background weight function and the initial background prediction value to obtain the background loss; wherein the background loss function includes: Represents pixel The background loss, represents the background weight function, represents the category label, represents the background attenuation coefficient, represents the initial background prediction value; Representative Pixels.

4. The method according to claim 1, characterized in that: The foreground-background guided progressive refinement network includes a first-layer refinement module, a second-layer refinement module, and a third-layer refinement module; the method of using the foreground-background guided progressive refinement network to obtain the transparency mask, the foreground image, and the background image after the matting process of the image to be processed according to the temporary image includes: Acquire a foreground guide mask of the first layer, a background guide mask of the first layer, and a self-guided mask of the first layer according to the trisection map; the foreground guide mask is used to identify a non-background area; the background guide mask is used to identify a non-foreground area; and the self-guided mask is used to identify a transparent area; Generate a first layer foreground image according to the foreground guide mask of the first layer and the temporary foreground image through the first layer refinement module; generate a first layer background image according to the background guide mask of the first layer and the temporary background image; and generate a first layer transparency mask according to the self-guided mask of the first layer and the temporary transparency mask; Generate a foreground guide mask of a second layer, a background guide mask of a second layer, and a self-guide mask of a second layer according to the transparency mask of the first layer; By the second layer refinement module, the first layer transparency mask is updated according to the second layer self-guided mask to obtain a second layer transparency mask; the first layer foreground image is updated according to the second layer foreground guided mask to obtain a second layer foreground image; and the first layer background image is updated according to the second layer background guided mask to obtain a second layer background image; Generate a foreground guide mask of a third layer, a background guide mask of a third layer, and a self-guide mask of a third layer according to the second layer transparency mask; Through the third layer refinement module, the second layer transparency mask is updated according to the third layer self-guiding mask to obtain the transparency mask; according to the third layer foreground guiding mask, the second layer foreground image is updated to obtain the foreground image; and according to the third layer background guiding mask, the second layer background image is updated to obtain the background image.

5. The method according to claim 4, characterized in that The step of obtaining a foreground guide mask of the first layer, a background guide mask of the first layer, and a self-guide mask of the first layer according to the trisection map includes: Performing a downsampling operation on the trigraph to obtain a sampled trigraph; Obtaining a foreground guide mask of the first layer according to the non-background area in the sampled trigraph; the non-background area includes the known foreground area and the unknown area; Obtaining a background guide mask of the first layer according to a non-foreground area in the sampled trigraph; the non-foreground area includes the known background area and the unknown area; According to the unknown area in the sampled trigraph, a background guide mask of the first layer is obtained.

6. The method according to claim 1, characterized in that Before using the foreground and background to guide the progressive refinement network to obtain the transparency mask, the foreground image and the background image after the matting process of the image to be processed according to the temporary image, the method further includes: Obtaining a sample trisection image, a true foreground value and a true background value of the sample trisection image, and a true value of the transparency mask; Obtaining an initial foreground prediction value and an initial background prediction value after predicting the sample trisection map using an initial refinement network; Downsampling the first layer refinement module, the second layer refinement module, and the third layer refinement module respectively, calculating a first similarity between the true foreground value and the initial foreground prediction value, and calculating a second similarity between the true background value and the initial background prediction value, to obtain a level loss value; According to the level loss value, a foreground background loss value is calculated; Calculating the transparency mask level loss according to the preset weights of each level in the initial refinement network; The foreground-background loss value and the transparency mask level loss are added to obtain a network loss value, and the initial refinement network is trained using the network loss value to obtain the foreground-background guided progressive refinement network.

7. A computer program product, characterized in that The method comprises computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is executed.

8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the method according to any one of claims 1 to 6 is executed.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is executed.

Citation Information

Patent Citations

  • Image processing network training method and device and image processing method and device

    CN113052242A

  • Method and device for acquiring opacity image in portrait matting process

    CN118229724A