An interactive tree image cutout method with real-time feedback

By combining the DeeplabV3+ model with the real-time feedback loop of the global feature encoding branch and the local semantic extraction branch, user-interactive tree image matting is realized, which solves the problems of high user interaction cost and difficulty in error correction, and improves the accuracy of matting. and convenience.

CN118470048BActive Publication Date: 2024-09-24ANHUI ANZHIXIN TECHNOLOGY GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410907884.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-09-24
Estimated Expiration
2044-07-08

AI Technical Summary

Technical Problem

The existing technology has high user interaction costs in tree image matting, and it is difficult to respond to user operations and provide feedback in real time, resulting in inaccurate foreground extraction and lack of error correction capabilities.

Method used

The three-part map prediction network based on the DeeplabV3+ model is used to combine the global feature encoding branch and the local semantic extraction branch. Through the real-time feedback loop and feature fusion output module, user-interactive tree image matting is realized, allowing users to correct wrong predictions in real time and guide different predictions. Determine the area.

Benefits of technology

It greatly improves the accuracy and user convenience of tree image matting, reduces learning costs, and can quickly generate high-quality transparency maps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470048B
    Figure CN118470048B
Patent Text Reader

Abstract

The present invention discloses an interactive tree image cutout method with real-time feedback, comprising the following steps: constructing a tree image cutout model, comprising a user interaction module and a cutout processing module; inputting a tree image into the user interaction module to predict a tree trisection map; converting the obtained tree trisection map and the original tree image into tensors and splicing them, inputting the obtained tree trisection map and the original tree image into tensors and extracting global features and local features, fusing the global features and the local features to output a final tree foreground transparency mask; constructing a data set to train the tree image cutout model before use by adopting a transfer learning strategy; the tree image cutout data set constructed by the present invention covers different tree varieties and forms in various seasons, ensuring the high accuracy and robustness of the model in practical applications; through the cutout processing module, not only the global features of the image can be captured, but also the local details can be accurately grasped.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image cutout, and in particular to an interactive tree image cutout method with real-time feedback. Background Art

[0002] Image matting technology, also known as image soft segmentation technology, is a key technology in the field of computer vision. This technology plays a vital role in processing target foregrounds in complex backgrounds. In terms of tree image matting, it extracts tree foregrounds by predicting the tree transparency mask in the input image. Compared with traditional image segmentation, this method pays more attention to the refinement of edges, making the extracted foreground not only more precise in boundaries, but also richer in information. This technology has a wide range of application value in 3D modeling, virtual scene construction, special effects production, landscape design, and advertising design.

[0003] The mathematical basis of the cutout technique can be described by the following formula: , where p=(x,y) represents the pixel coordinates of the input image M. , , They represent the foreground transparency value, foreground value, and background value of p pixel points respectively. This formula accurately describes the image synthesis process. Each pixel point is a linear mixture of foreground and background in a certain proportion. This proportion is determined by the foreground transparency value. This description highlights how each pixel in the image is constructed, reveals the linear relationship between foreground and background, and exposes the under-constrained problem of image matting.

[0004] To meet this challenge, traditional image cutout models often need to rely on preset auxiliary inputs for constraints, such as using a tripartite map to limit the solution space. Although this tripartite-based method can significantly improve the cutout performance, drawing an accurate tripartite map is very cumbersome and requires users to have certain professional knowledge, professional skills and time investment, resulting in low user friendliness.

[0005] With the rapid development of deep learning technology, some automatic cutout models that do not require the auxiliary input of the triplicate map have also emerged. These models still have limitations, mainly reflected in that they are usually only applicable to prominent objects in the image, such as portraits, and their performance is usually not as good as the triplicate map-based methods. In addition, when there are multiple foreground objects in the image, such models often cannot accurately extract the specific foreground required by the user, and also lack the ability to correct incorrect predictions.

[0006] Therefore, the cutout process necessarily requires user participation. The challenge is how to minimize the user interaction cost while providing an interactive mechanism that enables the model to respond to user operations in real time and provide corresponding feedback, and allows the user to directly correct the model's erroneous predictions. This ensures that the foreground part required by the user is accurately extracted. However, the existing technology does not have a particularly effective method to solve these problems. Summary of the invention

[0007] In view of the shortcomings of the prior art, the present invention provides an interactive tree image cutout method with real-time feedback, the purpose of which is that the user can instruct the model to make necessary adjustments through simple click operations, including direct correction of erroneous predictions and guidance for uncertain areas, and the model will also provide immediate feedback. This real-time feedback mechanism allows the user to quickly correct any misjudgment of the model during the cutout process, ensuring the generation of high-quality transparency maps.

[0008] To achieve the above object, the present invention provides the following technical solution: a real-time feedback interactive tree image cutout method, comprising the following steps:

[0009] Step S1: Collect natural images to construct a pre-training data set; the natural images include human images, animal images, transparent object images, plant images, furniture images, toy images, and fruit images;

[0010] Step S2: Collect tree images to construct a tree image cutout dataset;

[0011] Step S3: construct a tree image cutout model, the tree image cutout model consists of a user interaction module and a cutout processing module, the user interaction module and the cutout processing module are in a serial structure; the core of the user interaction module is composed of a three-part image prediction network based on the DeeplabV3+ model structure; the cutout processing module is composed of a global feature encoding branch, a local semantic extraction branch and a feature fusion output module; the local semantic extraction branch and the feature fusion output module are a lightweight U-Net architecture as a whole, the global feature encoding branch and the local semantic extraction branch are in a parallel structure, and the feature fusion output module is serially connected behind the global feature encoding branch and the local semantic extraction branch; the user interaction module is a real-time feedback loop, and the three-part image prediction network runs in the real-time feedback loop;

[0012] Step S4: input the tree image into the user interaction module, and predict the tree tri-map of the tree image through a tri-map prediction network based on the DeeplabV3+ model;

[0013] Step S5: Convert the obtained tree triplicate map and the original tree image into tensors and perform channel concatenation to obtain a merged image. ,Will The global feature encoding branch and local semantic extraction branch are sent to the cutout processing module respectively. The global feature encoding branch is composed of a visual transformer. Encode and get The global features of the local semantic extraction branch Downsample layer by layer and extract Local features of

[0014] Step S6: Send the global features and local features output by the global feature encoding branch and the local semantic extraction branch to the feature fusion output module to perform feature fusion and output the final tree foreground transparency mask.

[0015] Furthermore, the specific process of collecting tree images to construct a tree image cutout dataset is as follows:

[0016] Tree image collection: Collect tree images, including taking them with a camera, collecting tree images from various data sets, and searching for publicly available images on the Internet to obtain images of trees of different species and seasonal states;

[0017] Image preprocessing and annotation: The collected tree images were preprocessed by cropping and adjusting the resolution. The collected tree images were manually annotated using image processing tools. Each tree image was annotated with a foreground transparent image and a label trisection image;

[0018] Image synthesis: The foreground of each labeled tree image is randomly synthesized with a background image in the BG-20K dataset. The synthesis operation is performed according to formula (1):

[0019] (1);

[0020] In the formula, =(x,y) represents the pixel coordinates of the input image M, , , Represents pixel points Foreground transparency value, foreground value, background value;

[0021] Dataset division and quality control: After the synthesis is completed, the annotation accuracy of each tree image is corrected through manual inspection, and the tree image cutout dataset is divided into training set and test set in proportion.

[0022] Furthermore, the tripartite map prediction network is designed based on the DeeplabV3+ model, which is used as the backbone structure of the tripartite map prediction network. The DeeplabV3+ model consists of an encoder and a decoder, and introduces an attention mechanism. The encoder uses the ResNet-50 backbone network structure to extract the features of the input tree image. The decoder upsamples the features of the input tree image extracted by the encoder through deconvolution operations to obtain the upsampled features. At the same time, the jump connection operation is used to combine the upsampled features with the extracted features of the input tree image, and finally outputs the tree tripartite map in the tree image.

[0023] Furthermore, the trigraph prediction network uses mean absolute error loss for supervision, and the formula is as follows:

[0024] (2);

[0025] In the formula, represents the mean absolute error loss; N represents the total number of pixels of the image input to the triplicate map prediction network, is the true label value of the i-th pixel, is the model's predicted value for the i-th pixel.

[0026] Furthermore, the visual transformer consists of three core parts: image embedding layer, position encoding layer and Transformer encoding layer; first, the merged image The tree image is divided into small blocks, and the small blocks are converted into sequence data in the image embedding layer and the position encoding layer to extract the global features of the tree image. Specifically, first The image is divided into a group of patches of size 16×16 pixels; then, each patch is converted into a mapping vector of length 384 through linear mapping; at the same time, the position information of the patch is introduced, and the position information of each patch is encoded through a group of learnable position vectors to obtain the position vector of the corresponding patch; then, the mapping vector of each patch is added and merged with its corresponding position vector to obtain a comprehensive vector; all the comprehensive vectors are connected in series to form a serialized feature matrix; then this feature matrix is ​​sent to the visual transformer. Each Transformer encoding layer in the visual transformer consists of a multi-head self-attention MHSA and a multi-layer perceptron MLP, and layer normalization LayerNorm is applied to generate the final output feature map, i.e., the global feature , expressed as:

[0027] x 0 [i]=PatchEmbed patc h i ( F Merged ) +PositionEncoding i (3);

[0028] x 0 =[ x 0 1 , x 0 2 , x 0 3 ,…, x 0 [n]] (4);

[0029] (5);

[0030] (6);

[0031] (7);

[0032] (8);

[0033] (9);

[0034] In the formula, express The Patch blocks; Represents the patch block embedding operation; Indicates positional encoding addition operation; x 0 [i] ∈ R D express The embedding vector obtained after the patch block embedding operation and the position encoding addition operation; R represents a set of real numbers; D represents the dimension of each embedding vector; represents a sequence consisting of all embedded vectors; n represents the number of patches; Respectively represent input The query vector, key vector and value vector obtained through linear mapping; represents the self-attention function; The transpose operation of the key vector represented by ; represents the dot product of the query vector and the key vector; represents the square root of the key vector dimension; They are High-dimensional vector obtained by linear dimensionality increase; Represents a splicing operation; Representation layer normalization operation; Indicates The output of the multi-head self-attention layer; Indicates The output of the encoding layer; Represents the output of the final layer of the global feature encoding branch, i.e., the global feature.

[0035] Furthermore, the local semantic extraction branch consists of a 7-layer network. In this 7-layer network, the first 6 layers use a single-layer 3×3 convolution operation to Downsampling is performed, and the seventh layer adopts the dilated spatial convolution pooling pyramid ASPP. The dilated spatial convolution pooling pyramid ASPP contains five parallel processing units, namely four dilated convolution units with different expansion rates and one global average pooling unit. Each dilated convolution unit with different expansion rates includes a convolution layer, a batch normalization layer, and an activation layer; and the global average pooling unit includes a pooling layer, a convolution layer, a batch normalization layer, and an activation layer. These five parallel processing units each output a set of feature maps, generating a total of five sets of feature maps. Finally, the five sets of feature maps are spliced ​​on the channel and passed through a 1×1 convolution unit to generate the final output feature map, namely the local feature ; The 1×1 convolution unit includes a 1×1 convolution layer, a batch normalization layer, an activation layer, and a dropout layer, expressed as:

[0036] (10);

[0037] (11);

[0038] (12);

[0039] In the formula, represents the number of downsampling layers, represents the expansion rate, Indicates that the convolution kernel size is 3 and the expansion rate is Convolution operation; represents the local semantic extraction branch The output of the layer; represents the local semantic extraction branch +1 layer output; Represents the 6th layer output of the local semantic extraction branch; Represents a dilated convolution unit with a kernel size of 3 and a dilation rate of 6; is the global average pooling unit; express Output after five parallel processing units; represents a nonlinear activation function; Represents batch normalization operation; local features Represents the final output of the local semantic extraction branch.

[0040] Furthermore, the feature fusion output module includes a multiple feature fusion block MFFB and 6 convolution operations, 6 skip connection operations and 6 bilinear interpolation upsampling operations. The feature fusion output module fuses the outputs of the global feature encoding branch and the local semantic extraction branch. Specifically, first, the global feature and local features The feature map is obtained by multiple feature fusion blocks MFFB , Then perform 6 skip connection operations, 6 bilinear interpolation upsampling operations and 6 convolution operations to restore the feature map The size of the upsampled features is combined with the local features using 6 skip connection operations. Interact with each other to obtain the final tree foreground transparency mask;

[0041] Among them, the global features and local features The feature map is obtained by multiple feature fusion blocks MFFB The specific process is as follows: First, the multiple feature fusion block MFFB includes 8 convolution operations for dimensionality reduction and dimensionality increase of feature maps, 3 non-linear activation functions Relu for enhancing the non-linear expression of features, and 1 splicing operation for merging global features. and local features , 1 convolution operation to generate the weight array required for dynamic convolution and 1 set of dynamic convolution operations for dynamically integrating global features With local features After the merged features, a batch normalization operation is used to standardize the distribution of features, a maximum pooling operation and two bilinear interpolation operations are used for spatial feature adjustment; the global features are Perform bilinear interpolation upsampling to make the global features Dimensions and local features Keep it consistent; then, the upsampled global features and local features Splicing is performed along the channel dimension, and the spliced ​​features are subjected to a 1×1 convolution operation to obtain a feature map At the same time, the global features after upsampling Perform the maximum pooling operation to obtain the feature map ; Then the feature map and feature map Splicing is performed along the channel dimension, and the spliced ​​feature map is passed through 5 consecutive dimensionality reduction convolution layers and two nonlinear activation functions. , a convolutional layer that generates the weight array required for dynamic convolution and a set of dynamic convolutions to obtain feature maps ; Finally, the feature map After processing through two convolutional layers, a batch normalization layer and a ReLU activation layer, the fused feature map is output , expressed as:

[0042] (13);

[0043] (14);

[0044] (15);

[0045] (16);

[0046] (17);

[0047] (18);

[0048] (19);

[0049] In the formula, Represents a bilinear interpolation upsampling operation; Indicates a convolution operation with a kernel size of 1 and a dilation rate of 1; is the maximum pooling operation; w is the generated dynamic convolution weight array; Represents a 3×3 convolution operation with a kernel size of 3 and a dilation rate of 1; Represents an operation that rearranges the dimensions of a tensor. Reshape the dynamic convolution weight array W into a specific format; Represents a dynamic convolution operation; Represents the convolution step size; Indicates the padding size; Represents a batch normalization operation; Indicates that the global feature After upsampling and combining with local features After concatenation, the feature map is obtained through convolution operation; Indicates that the global feature Feature map obtained after upsampling and global pooling; Indicates that and After splicing, it undergoes three layers of convolution operations and nonlinear activation functions. The feature map obtained after processing; express After two convolution operations and one nonlinear activation function The feature map obtained after processing; Represents the output feature map of the dynamic convolution operation; Represents the final output feature map of the multiple feature fusion block MFFB.

[0050] Furthermore, when training the cutout processing module, the combined loss function L= + + To supervise; obtain the tree tri-map of the tree image in the tree image matting dataset as the label tri-map, and use the weighted absolute error loss function To supervise the prediction results of known foreground and background areas and unknown uncertain areas in the label trigraph; gradient penalty loss is used To compare the gradient of the predicted image and the real image in the unknown uncertain area of ​​the label trigraph, supervise the edge of the predicted image; use Laplace loss The details of the predicted image at multiple scales are supervised by constructing the Laplacian pyramid of the predicted image and the real image, which is expressed as:

[0051] (20);

[0052] (twenty one);

[0053] (twenty two);

[0054] (twenty three);

[0055] In the formula, and They are The predicted value and true value of foreground transparency of pixels, represents the scaling factor, is the total number of pixels, Indicates the number of pixels in the unknown uncertain area in the label trigraph. Indicates the number of pixels in the known foreground and background areas in the label tri-map; is a binary map of the same size as the label triplicate map, containing only two values: 0 and 1; express The The value of a pixel point, 0 means that the pixel point belongs to the known foreground and background area in the corresponding label trigraph, and 1 means that the pixel point belongs to the unknown uncertain area in the corresponding label trigraph; , are the gradients along the x and y directions respectively; and They are The predicted value and true value of the foreground transparency of the pixel are represented in the hth layer of the Laplacian pyramid. is the total number of layers in the Laplacian pyramid.

[0056] Furthermore, before the tree image cutout model is used, it is first trained. The training is implemented in two stages, and the user interaction module and the cutout processing module are trained using transfer learning and supervised learning respectively;

[0057] For the three-part image prediction network in the user interaction module, the three-part image prediction network is pre-trained on the pre-training dataset. The pre-training uses a random gradient descent optimizer, the batch size is set to 16, and the learning rate is set to 0.0003; then fine-tuning training is continued on the tree image cutout dataset. The fine-tuning training uses a random gradient descent optimizer, the batch size is set to 16, and the learning rate is set to 0.0001. After the training is completed, the three-part image prediction network with the optimal parameters is retained;

[0058] For the global feature encoding branch in the cutout processing module, the self-supervised DINO method is used to pre-train the global feature encoding branch on the public image classification dataset ImageNet to obtain the pre-training weights of the global feature encoding branch, and then the pre-training weights of the global feature encoding branch are initialized. Then, the cutout processing module is trained on the tree image cutout dataset until convergence. The training applies the stochastic gradient descent optimizer, the batch size is set to 16, the learning rate is initialized to 0.0005, the learning rate is adjusted dynamically, the number of training rounds is set to 100, and the optimal cutout processing module parameters are saved after the training.

[0059] Furthermore, the specific process of collecting natural images to construct a pre-training dataset is: collecting the main public datasets in the current image matting field, including PhotoMatte85 dataset, AIM500 dataset, AM2000 dataset, withoutbg100 dataset, Distinctions646 dataset, P3M10K RealwordPortrait636 dataset and SIMD dataset.

[0060] Compared with the existing technology, the present invention has the following beneficial effects:

[0061] (1) The present invention uses a global feature encoding branch, a local semantic extraction branch and a feature fusion output module as a cutout network, which can not only capture the global features of the image but also accurately grasp the local details.

[0062] (2) The tree image cutout dataset constructed by the present invention covers different tree species and forms in different seasons. These high-quality, accurately labeled datasets provide effective support for model training, ensuring the high accuracy and robustness of the model in practical applications.

[0063] (3) The present invention realizes interactive correction of the cutout task by using the tripartite prediction network to design an interactive module. The user can control the prediction and correction process of the tripartite map in real time, which greatly improves the convenience of operation and the accuracy of the tripartite map. The model is pre-trained using a wide range of cutout datasets and transfer learning is used to improve the model efficiency, so that the model can quickly adapt and optimize performance when processing tree images.

[0064] (4) The image cutout model of the present invention does not require complicated and tedious processes, has extremely low learning costs, and can achieve high-quality tree cutout with only a small number of clicks. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a model framework diagram of the present invention.

[0066] Figure 2 It is a structural diagram of the cutout processing module of the present invention. DETAILED DESCRIPTION

[0067] The present invention provides a technical solution: a real-time feedback interactive tree image cutout method, comprising the following steps:

[0068] Step S1: construct a pre-training dataset;

[0069] The main public datasets in the current image matting field are collected, such as the PhotoMatte85 dataset, AIM500 dataset, AM2000 dataset, withoutbg100 dataset, Distinctions646 dataset, P3M10KRealwordPortrait636 dataset and SIMD dataset, totaling 14,268 images, covering natural images such as human images, animal images, transparent object images, plant images, furniture images, toy images, fruit images, etc.; the pre-training dataset is used as training data in transfer learning.

[0070] Step S2: construct a tree image cutout dataset;

[0071] The specific process is:

[0072] 1. Tree image collection: Tree images are collected through various channels, including taking pictures with cameras, collecting tree images from various data sets, searching for publicly available images on the Internet, etc., to obtain images of trees of different species and seasonal conditions.

[0073] 2. Image preprocessing and labeling: The collected tree images were preprocessed by image cropping, adjusting resolution, etc., and manually labeled using image processing tools such as Photoshop. Each tree image was accurately labeled with a foreground transparent map and a label tri-map. The foreground transparent map is a grayscale image that indicates the transparency of the foreground object. The label tri-map defines a definite foreground area, a definite background area, and an unknown uncertain area, which are marked as 1, 0, and 0.5, respectively.

[0074] 3. Image synthesis: In order to further enhance the constructed tree image cutout dataset and increase the background complexity of the collected tree images, the foreground of each labeled tree image is randomly synthesized with a background image in the BG-20K dataset. The synthesis operation is performed according to formula (1) to ensure the natural fusion between the foreground and the background.

[0075] (1);

[0076] In the formula, =(x,y) represents the pixel coordinates of the input image M, , , Represents pixel points Foreground transparency value, foreground value, background value.

[0077] 4. Dataset division and quality control: After the synthesis is completed, the annotation accuracy of each tree image is corrected through manual inspection to ensure the validity of the tree image cutout dataset, and the tree image cutout dataset is divided into training set and test set in a ratio of 8:2.

[0078] There are 2587 samples in the tree image cutout dataset, including the foreground of the tree image, the foreground transparent image of the tree image, the labeled three-dimensional image, and the synthesized background image.

[0079] Step S3: construct a tree image cutout model, which consists of a user interaction module and a cutout processing module, and the user interaction module and the cutout processing module are in a serial structure; the core of the user interaction module is composed of a three-part image generation network based on the DeeplabV3+ model structure, and runs in a real-time feedback loop; the cutout processing module is composed of a global feature encoding branch, a local semantic extraction branch and a feature fusion output module; the local semantic extraction branch and the feature fusion output module are a lightweight U-Net architecture as a whole, the global feature encoding branch and the local semantic extraction branch are in a parallel structure for feature extraction, and the feature fusion output module is serially connected behind the global feature encoding branch and the local semantic extraction branch.

[0080] Step S4: Figure 1As shown, a tree image is input into the user interaction module, and a tripartite map prediction network based on the DeeplabV3+ model is used to predict the tree tripartite map of the tree image in a real-time feedback loop; the tripartite map prediction network is inside the user interaction module and can provide continuous real-time feedback before the cutout process to ensure that the user can finally obtain a satisfactory result.

[0081] Step S5: Convert the obtained tree triplicate map and the original tree image into tensors and perform channel concatenation to obtain a merged image. ,Will The global feature encoding branch and local semantic extraction branch are sent to the cutout processing module respectively; the global feature encoding branch adopts the Vision Transformer architecture to Encode global features and capture The local semantic extraction branch downsamples layer by layer through a lightweight encoder and focuses on extracting The local features are used to supplement the local semantic information omitted when the global feature encoding branch captures image features.

[0082] Step S6: Send the global features and local features extracted by the global feature encoding branch and the local semantic extraction branch to the feature fusion output module to perform feature fusion and output the final tree foreground transparency mask.

[0083] Among them, before the tree image cutout model is used, it is first trained. The training is implemented in two stages. Transfer learning and supervised learning are used to train the user interaction module and the cutout processing module respectively.

[0084] For the tripartite map prediction network in the user interaction module, the tripartite map prediction network was pre-trained on the pre-training dataset. The pre-training applied the random gradient descent optimizer, the batch size was set to 16, and the learning rate was set to 0.0003; then fine-tuning training was continued on the tree image cutout dataset. The fine-tuning training applied the random gradient descent optimizer, the batch size was set to 16, and the learning rate was set to 0.0001. After the training was completed, the tripartite map prediction network with the optimal parameters was retained.

[0085] For the global feature encoding branch in the cutout processing module, the self-supervised DINO method is used to pre-train the global feature encoding branch on the public image classification dataset ImageNet to obtain the pre-trained weights of the global feature encoding branch, and then the pre-trained weights of the global feature encoding branch are initialized. Then the cutout processing module is trained on the tree image cutout dataset until convergence. The training applies the stochastic gradient descent optimizer, the batch size is set to 16, the learning rate is initialized to 0.0005, the learning rate is adjusted dynamically, the number of training rounds is set to 100, and the optimal cutout processing module parameters are saved after the training. Finally, prediction and evaluation are performed on the test set.

[0086] Operations within the user interaction module:

[0087] The user interaction module is mainly a real-time feedback loop, in which the tripartite map prediction network runs; the tripartite map prediction network is designed based on the DeeplabV3+ model, which is a deep learning model that performs exceptionally well in semantic segmentation tasks. The DeeplabV3+ model is used as the backbone structure of the tripartite map prediction network; the DeeplabV3+ model consists of an encoder and a decoder, and introduces an attention mechanism to extract and refine features; among them, the encoder adopts the ResNet-50 backbone network structure to extract the features of the input tree image; the decoder upsamples the features of the input tree image extracted by the encoder through deconvolution operations to obtain the upsampled features, and at the same time, uses jump connection operations to combine these upsampled features with the extracted features of the input tree image, and finally outputs the tree tripartite map in the tree image.

[0088] By designing the tripartite map prediction network to operate in a real-time feedback loop, the tripartite map prediction network utilizes the mask of the previous step in the loop and can handle two situations: one is the initial interaction of the existing mask (initially empty), and the other is the correction interaction where the existing mask contains errors; allowing users to explicitly control the tripartite map prediction using interactive input in several iterations. This instant control enables users to select the click objects of interest and correct prediction errors.

[0089] The trigraph prediction network uses mean absolute error loss for supervision, and its formula is as follows:

[0090] (2);

[0091] In the formula, represents the mean absolute error loss; N represents the total number of pixels of the image input to the triplicate map prediction network, is the true label value of the i-th pixel, is the model's predicted value for the i-th pixel.

[0092] like Figure 2 As shown, the operations in the cutout processing module are:

[0093] The image cutting processing module consists of a global feature encoding branch, a local semantic extraction branch, and a feature fusion output module. The inputs of the global feature encoding branch and the local semantic extraction branch are ;

[0094] Among them, the Vision Transformer is mainly composed of three core parts: image embedding layer, position encoding layer and Transformer encoding layer; first, the merged image The image is divided into small blocks, and the small blocks are converted into sequence data in the image embedding layer and the position encoding layer to extract the global features of the tree image; due to the irregularity of the tree foreground, a tree covers the trunk, crown and other parts. The excellent long-range dependency information processing ability of the Vision Transformer can better understand the overall morphology of the tree, thereby effectively capturing the overall semantic relationship between the trunk and crown in the tree image and between the tree and the surrounding environment.

[0095] The processing flow of the global feature encoding branch is as follows: First, The image is divided into a group of patches of size 16×16 pixels; then, each patch is converted into a mapping vector of length 384 through linear mapping; at the same time, the position information of the patch is introduced, and the position information of each patch is encoded through a group of learnable position vectors to obtain the position vector of the corresponding patch, which contains both the absolute position information of the patch and the relative position information; then, the mapping vector of each patch is added and merged with its corresponding position vector to obtain a comprehensive vector; all the comprehensive vectors are then concatenated together to form a serialized feature matrix; this feature matrix is ​​then sent to the Vision Transformer, in which each Transformer encoding layer consists of multi-head self-attention (MHSA) and multi-layer perceptron (MLP) blocks, and layer normalization LayerNorm is applied to generate the final output feature map, i.e., the global feature , which can be expressed as:

[0096] x 0 [i]=PatchEmbed patc h i ( F Merged ) +PositionEncoding i (3);

[0097] x 0 =[ x 0 1 , x 0 2 , x 0 3 ,…, x 0 [n]] (4);

[0098] (5);

[0099] (6);

[0100] (7);

[0101] (5);

[0102] (9);

[0103] In the formula, express The Patch blocks; Represents the patch block embedding operation; Indicates positional encoding addition operation; x 0 [i] ∈ R D express The embedding vector obtained after the patch block embedding operation and the position encoding addition operation; R represents a set of real numbers; D represents the dimension of each embedding vector; represents a sequence consisting of all embedded vectors; n represents the number of patches; Respectively represent input The query, key and value vectors obtained through linear mapping; represents the self-attention function; The transpose operation of the key vector represented by ; represents the dot product (matrix multiplication) of the query vector and the key vector; represents the square root of the key vector dimension; They are High-dimensional vector obtained by linear dimensionality increase; Represents a splicing operation; Representation layer normalization operation; Indicates The output of the multi-head self-attention layer; Indicates The output of the encoding layer; Represents the output of the final layer of the global feature encoding branch, i.e., the global feature.

[0104] Among them, the local semantic extraction branch adopts a lightweight coding structure, which reduces the consumption of computing resources while maintaining performance by simplifying the network structure and the number of parameters; the atrous spatial convolution pooling pyramid ASPP is introduced to enhance the receptive field, thereby more effectively capturing the semantic information in the image; the local semantic extraction branch is mainly responsible for supplementing the detailed semantic information lost when the global feature encoding branch extracts image features, especially other important detail features such as the outlines of trees and the edges of leaves in the image.

[0105] The processing flow of the local semantic extraction branch is as follows: First, the local semantic extraction branch consists of a 7-layer network to process the merged image In this 7-layer network, the first 6 layers use a single layer of 3×3 convolution operation to Downsampling is performed; the seventh layer adopts the atrous spatial convolution pooling pyramid ASPP, which contains five parallel processing units: four atrous convolution units with different expansion rates and one global average pooling unit. Each atrous convolution unit with different expansion rates includes a convolution layer, a batch normalization layer, and an activation layer; and the global average pooling unit includes a pooling layer, a convolution layer, a batch normalization layer, and an activation layer. These five parallel processing units each output a set of feature maps, generating a total of five sets of feature maps. Finally, the five sets of feature maps are spliced ​​on the channel and passed through a 1×1 convolution unit to generate the final output feature map, i.e., the local feature ; The 1×1 convolution unit includes a 1×1 convolution layer, a batch normalization layer, an activation layer, and a dropout layer; the computational flow of the entire local semantic extraction branch can be expressed as:

[0106] (10);

[0107] (11);

[0108] (12);

[0109] In the formula, represents the number of downsampling layers, represents the expansion rate, Indicates that the convolution kernel size is 3 and the expansion rate is Convolution operation; represents the local semantic extraction branch The output of the layer; represents the local semantic extraction branch +1 layer output; Represents the sixth layer output of the local semantic extraction branch; Represents a dilated convolution unit with a kernel size of 3 and a dilation rate of 6; is the global average pooling unit; express Output after five parallel processing units; represents a nonlinear activation function; Represents batch normalization operation; local features Represents the final output of the local semantic extraction branch.

[0110] The feature fusion output module includes a multiple feature fusion block MFFB and 6 skip connection operations, 6 bilinear interpolation upsampling operations and 6 convolution operations. The feature fusion output module can effectively fuse the outputs of the global feature encoding branch and the local semantic extraction branch. First, the global feature and local features The feature map will be obtained through the multiple feature fusion block MFFB , Then, the six skip connection operations, six bilinear interpolation upsampling operations and six convolution operations are performed to gradually restore the size of the feature map. The six skip connection operations are used to interact the upsampled features with the multi-scale features of the local semantic extraction branch, connect the shallow features with the deep features, reduce the spatial information loss caused by downsampling, and obtain the final tree foreground transparency mask after interaction.

[0111] The processing flow of the multi-feature fusion block MFFB is as follows: First, the multi-feature fusion block MFFB includes 8 convolution operations for reducing and increasing the dimension of the feature map, 3 non-linear activation functions Relu for enhancing the non-linear expression of features, and 1 splicing operation for merging global features. and local features , 1 convolution operation to generate the weight array required for dynamic convolution and 1 set of dynamic convolution operations for dynamically integrating global features With local features After the merged features, a batch normalization operation is used to standardize the distribution of features, a maximum pooling operation and two bilinear interpolation operations are used for spatial feature adjustment; the global features are Perform bilinear interpolation upsampling to make the global features Dimensions and local features Keep it consistent; then, the upsampled global features and local features Splicing is performed along the channel dimension, and the spliced ​​features are subjected to a 1×1 convolution operation to obtain a feature map At the same time, the global features after upsampling Perform the maximum pooling operation to obtain the feature map ; Then the feature map and feature map Splicing is performed along the channel dimension, and the spliced ​​features are passed through five consecutive dimensionality reduction convolution layers and two nonlinear activation functions. , a convolutional layer that generates the weight array required for dynamic convolution and a set of dynamic convolutions to obtain feature maps ; Finally, the feature map After processing through two convolutional layers, a batch normalization layer and a ReLU activation layer, the fused feature map is output , which can be expressed as:

[0112] (13);

[0113] (14);

[0114] (15);

[0115] (16);

[0116] (17);

[0117] (18);

[0118] (19);

[0119] In the formula, Represents a bilinear interpolation upsampling operation; Indicates a convolution operation with a kernel size of 1 and a dilation rate of 1; is the maximum pooling operation; w is the generated dynamic convolution weight array; Represents a 3×3 convolution operation with a kernel size of 3 and a dilation rate of 1; Represents an operation that rearranges the dimensions of a tensor. Reshape the dynamic convolution weight array W into a specific format. Specifically, The output is a five-dimensional tensor, the five dimensions are Bat, Group, Ker, High, Widh; Bat represents the batch size, Group represents the number of groups, Ker represents the convolution kernel size, High represents the height of the feature map, and Widh represents the width of the feature map; Represents a dynamic convolution operation, which performs convolution using a pre-computed dynamic convolution weight array W, where the weights are based on the input features. Dynamic adjustment, represents the convolution step size, Indicates the padding size; Represents a batch normalization operation; Indicates that the global feature After upsampling and combining with local features After concatenation, the feature map is obtained through convolution operation; Indicates that the global feature Feature map obtained after upsampling and global pooling; Indicates that the feature map and After splicing, it undergoes three layers of convolution operations and nonlinear activation functions. The feature map obtained after processing; express After two convolution operations and one nonlinear activation function The feature map obtained after processing; Represents the output feature map of the dynamic convolution operation; Represents the final output feature map of the multiple feature fusion block MFFB.

[0120] Among them, when training the cutout processing module, the combined loss function L= + + To supervise; obtain the tree tri-map of the tree image in the tree image matting dataset as the label tri-map, and use the weighted absolute error loss function To supervise the prediction results of known foreground and background areas and unknown uncertain areas in the label trigraph; gradient penalty loss is used To compare the gradient of the predicted image and the real image in the unknown uncertain area of ​​the label trigraph, supervise the edge of the predicted image; use Laplace loss The details of the predicted image at multiple scales are supervised by constructing the Laplacian pyramid of the predicted image and the real image, which is expressed as:

[0121] (20);

[0122] (twenty one);

[0123] (twenty two);

[0124] (twenty three);

[0125] In the formula, and They are The predicted value and true value of foreground transparency of pixels, represents the scaling factor, is the total number of pixels, Indicates the number of pixels in the unknown uncertain area in the label trigraph. Indicates the number of pixels in the known foreground and background areas in the label tri-map; is a binary map of the same size as the label triplicate map, containing only two values: 0 and 1; express The The value of a pixel point, 0 means that the pixel point belongs to the known foreground and background area in the corresponding label trigraph, and 1 means that the pixel point belongs to the unknown uncertain area in the corresponding label trigraph; , are the gradients along the x and y directions respectively; and They are The predicted value and true value of the foreground transparency of the pixel are represented in the hth layer of the Laplacian pyramid. is the total number of layers in the Laplacian pyramid.

[0126] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. An interactive tree image cutout method with real-time feedback, It is characterized in that The steps include: Step S1: Collect natural images to construct a pre-training data set; the natural images include human images, animal images, plant images, furniture images, toy images, and fruit images; Step S2: Collect tree images to construct a tree image cutout dataset; Step S3: construct a tree image cutout model, the tree image cutout model consists of a user interaction module and a cutout processing module, the user interaction module and the cutout processing module are in a serial structure; the core of the user interaction module is composed of a three-part image prediction network based on the DeeplabV3+ model structure; the cutout processing module is composed of a global feature encoding branch, a local semantic extraction branch and a feature fusion output module; the local semantic extraction branch and the feature fusion output module are a lightweight U-Net architecture as a whole, the global feature encoding branch and the local semantic extraction branch are in a parallel structure, and the feature fusion output module is serially connected behind the global feature encoding branch and the local semantic extraction branch; the user interaction module is a real-time feedback loop, and the three-part image prediction network runs in the real-time feedback loop; Step S4: input the tree image into the user interaction module, and predict the tree tri-map of the tree image through a tri-map prediction network based on the DeeplabV3+ model; Step S5: Convert the obtained tree triplicate map and the original tree image into tensors and perform channel concatenation to obtain a merged image. ,Will The global feature encoding branch and local semantic extraction branch are sent to the cutout processing module respectively. The global feature encoding branch is composed of a visual transformer. Encode and get The global features of the local semantic extraction branch Downsample layer by layer and extract Local features of Step S6: sending the global features and local features output by the global feature encoding branch and the local semantic extraction branch to the feature fusion output module to perform feature fusion and output the final tree foreground transparency mask; The specific process of collecting tree images to build a tree image cutout dataset is as follows: Tree image collection: Collect tree images, including taking them with a camera, collecting tree images from various data sets, and searching for public images on the Internet to obtain images of trees of different species and seasonal conditions; Image preprocessing and annotation: The collected tree images were preprocessed by cropping and adjusting the resolution. The collected tree images were manually annotated using image processing tools. Each tree image was annotated with a foreground transparent image and a label trisection image; Image synthesis: The foreground of each labeled tree image is randomly synthesized with a background image in the BG-20K dataset. The synthesis operation is performed according to formula (1): (1); In the formula, =(x,y) represents the pixel coordinates of the input image M, , , Represents pixel points Foreground transparency value, foreground value, background value; Dataset division and quality control: After the synthesis is completed, the annotation accuracy of each tree image is corrected through manual inspection, and the tree image cutout dataset is divided into training set and test set in proportion; The tripartite map prediction network is designed based on the DeeplabV3+ model. The DeeplabV3+ model is used as the backbone structure of the tripartite map prediction network. The DeeplabV3+ model consists of an encoder and a decoder, and introduces an attention mechanism. The encoder uses the ResNet-50 backbone network structure to extract the features of the input tree image. The decoder upsamples the features of the input tree image extracted by the encoder through deconvolution operations to obtain the upsampled features. At the same time, the jump connection operation is used to combine the upsampled features with the extracted features of the input tree image, and finally outputs the tree tripartite map in the tree image. The trigraph prediction network uses mean absolute error loss for supervision, and the formula is as follows: (2); In the formula, represents the mean absolute error loss; N represents the total number of pixels of the image input to the triplicate map prediction network, is the true label value of the i-th pixel, is the model's predicted value for the i-th pixel; The visual transformer consists of three core parts: image embedding layer, position encoding layer and Transformer encoding layer. First, the merged image The tree image is divided into small blocks, and the small blocks are converted into sequence data in the image embedding layer and the position encoding layer to extract the global features of the tree image. Specifically, first The image is divided into a group of patches of size 16×16 pixels; then, each patch is converted into a mapping vector of length 384 through linear mapping; at the same time, the position information of the patch is introduced, and the position information of each patch is encoded through a group of learnable position vectors to obtain the position vector of the corresponding patch; then, the mapping vector of each patch is added and merged with its corresponding position vector to obtain a comprehensive vector; then all the comprehensive vectors are connected in series to form a serialized feature matrix; then this feature matrix is ​​sent to the visual transformer. Each Transformer encoding layer in the visual transformer consists of a multi-head self-attention MHSA and a multi-layer perceptron MLP, and layer normalization is applied to generate the final output feature map, that is, the global feature , expressed as: (3); (4); (5); (6); (7); (8); (9); In the formula, express The Patch blocks; Represents the patch block embedding operation; Indicates positional encoding addition operation; express The embedding vector obtained after the patch block embedding operation and the position encoding addition operation; R represents a set of real numbers; D represents the dimension of each embedding vector; represents a sequence consisting of all embedded vectors; n represents the number of patches; Respectively represent input The query vector, key vector and value vector obtained through linear mapping; represents the self-attention function; The transpose operation of the key vector represented by ; represents the dot product of the query vector and the key vector; represents the square root of the key vector dimension; They are High-dimensional vector obtained by linear dimensionality increase; Represents a splicing operation; Representation layer normalization operation; Indicates The output of the multi-head self-attention layer; Indicates The output of the encoding layer; Represents the output of the final layer of the global feature encoding branch, i.e., the global feature; The local semantic extraction branch consists of a 7-layer network. In this 7-layer network, the first 6 layers use a single-layer 3×3 convolution operation to Downsampling is performed; the seventh layer adopts the atrous spatial convolution pooling pyramid ASPP, which contains five parallel processing units, namely four atrous convolution units with different expansion rates and one global average pooling unit. Each atrous convolution unit with different expansion rates includes a convolution layer, a batch normalization layer, and an activation layer; and the global average pooling unit includes a pooling layer, a convolution layer, a batch normalization layer, and an activation layer; the five parallel processing units each output a set of feature maps, generating a total of five sets of feature maps; finally, the five sets of feature maps are spliced ​​on the channel and passed through a 1×1 convolution unit to generate the final output feature map, i.e., the local feature ; The 1×1 convolution unit includes a 1×1 convolution layer, a batch normalization layer, an activation layer, and a dropout layer, expressed as: (10); (11); (12); In the formula, represents the number of downsampling layers, represents the expansion rate, Indicates that the convolution kernel size is 3 and the expansion rate is Convolution operation; represents the local semantic extraction branch The output of the layer; represents the local semantic extraction branch +1 layer output; Represents the sixth layer output of the local semantic extraction branch; Represents a dilated convolution unit with a kernel size of 3 and a dilation rate of 6; is the global average pooling unit; express Output after five parallel processing units; represents a nonlinear activation function; Represents batch normalization operation; local features Represents the final output of the local semantic extraction branch.

2. The interactive tree image cutout method with real-time feedback according to claim 1, Features: The feature fusion output module includes a multiple feature fusion block MFFB and 6 convolution operations, 6 skip connection operations and 6 bilinear interpolation upsampling operations. The feature fusion output module fuses the outputs of the global feature encoding branch and the local semantic extraction branch. Specifically, first, the global feature and local features The feature map is obtained by multiple feature fusion blocks MFFB , Then perform 6 skip connection operations, 6 bilinear interpolation upsampling operations and 6 convolution operations to restore the feature map The size of the upsampled features is combined with the local features using 6 skip connection operations. Interact with each other to obtain the final tree foreground transparency mask; Among them, the global features and local features The feature map is obtained by multiple feature fusion blocks MFFB The specific process is as follows: First, the multiple feature fusion block MFFB includes 8 convolution operations for dimensionality reduction and dimensionality increase of feature maps, 3 non-linear activation functions Relu for enhancing the non-linear expression of features, and 1 splicing operation for merging global features. and local features , 1 convolution operation to generate the weight array required for dynamic convolution and 1 set of dynamic convolution operations for dynamically integrating global features With local features After the merged features, a batch normalization operation is used to standardize the distribution of features, a maximum pooling operation and two bilinear interpolation operations are used for spatial feature adjustment; the global features are Perform bilinear interpolation upsampling to make the global features Dimensions and local features Keep it consistent; then, the upsampled global features and local features Splicing is performed along the channel dimension, and the spliced ​​features are subjected to a 1×1 convolution operation to obtain a feature map At the same time, the upsampled global features Perform the maximum pooling operation to obtain the feature map ; Then the feature map and feature map Splicing is performed along the channel dimension, and the spliced ​​feature map is passed through 5 consecutive dimensionality reduction convolution layers and two nonlinear activation functions. , a convolutional layer that generates the weight array required for dynamic convolution and a set of dynamic convolutions to obtain feature maps ; Finally, the feature map After processing through two convolutional layers, a batch normalization layer and a ReLU activation layer, the fused feature map is output , expressed as: (13); (14); (15); (16); (17); (18); (19); In the formula, Represents a bilinear interpolation upsampling operation; Indicates a convolution operation with a kernel size of 1 and a dilation rate of 1; is the maximum pooling operation; w is the generated dynamic convolution weight array; Represents a 3×3 convolution operation with a kernel size of 3 and a dilation rate of 1; Represents an operation that rearranges the dimensions of a tensor. Reshape the dynamic convolution weight array W into a specific format; Represents a dynamic convolution operation; Represents the convolution step size; Indicates the padding size; Represents a batch normalization operation; Indicates that the global feature After upsampling and combining with local features After concatenation, the feature map is obtained through convolution operation; Indicates that the global feature Feature map obtained after upsampling and global pooling; Indicates that and After splicing, it undergoes three layers of convolution operations and nonlinear activation functions. The feature map obtained after processing; express After two convolution operations and one nonlinear activation function The feature map obtained after processing; Represents the output feature map of the dynamic convolution operation; Represents the final output feature map of the multiple feature fusion block MFFB.

3. The interactive tree image cutout method with real-time feedback according to claim 2, Features: When training the cutout processing module, the combined loss function L= + + To supervise; obtain the tree tri-map of the tree image in the tree image matting dataset as the label tri-map, and use the weighted absolute error loss function To supervise the prediction results of known foreground and background areas and unknown uncertain areas in the label trigraph; gradient penalty loss is used To compare the gradient of the predicted image and the real image in the unknown uncertain area of ​​the label trigraph, supervise the edge of the predicted image; use Laplace loss The details of the predicted image at multiple scales are supervised by constructing the Laplacian pyramid of the predicted image and the real image, which is expressed as: (20); (21); (22); (23); In the formula, and They are The predicted value and true value of foreground transparency of pixels, represents the scaling factor, is the total number of pixels, Indicates the number of pixels in the unknown uncertain area in the label trigraph. Indicates the number of pixels in the known foreground and background areas in the label tri-map; is a binary map of the same size as the label triplicate map, containing only two values: 0 and 1; express The The value of a pixel point, 0 means that the pixel point belongs to the known foreground and background area in the corresponding label trigraph, and 1 means that the pixel point belongs to the unknown uncertain area in the corresponding label trigraph; , are the gradients along the x and y directions respectively; and They are The predicted value and true value of the foreground transparency of the pixel are represented in the hth layer of the Laplacian pyramid. is the total number of layers in the Laplacian pyramid.

4. The interactive tree image cutout method with real-time feedback according to claim 3, Features: Before using the tree image cutout model, it is first trained. The training is implemented in two stages. Transfer learning and supervised learning are used to train the user interaction module and the cutout processing module respectively. For the three-part image prediction network in the user interaction module, the three-part image prediction network is pre-trained on the pre-training dataset. The pre-training uses a random gradient descent optimizer, the batch size is set to 16, and the learning rate is set to 0.0003; then fine-tuning training is continued on the tree image cutout dataset. The fine-tuning training uses a random gradient descent optimizer, the batch size is set to 16, and the learning rate is set to 0.0001. After the training is completed, the three-part image prediction network with the optimal parameters is retained; For the global feature encoding branch in the cutout processing module, the self-supervised DINO method is used to pre-train the global feature encoding branch on the public image classification dataset ImageNet to obtain the pre-training weights of the global feature encoding branch, and then the pre-training weights of the global feature encoding branch are initialized. Then, the cutout processing module is trained on the tree image cutout dataset until convergence. The training applies the stochastic gradient descent optimizer, the batch size is set to 16, the learning rate is initialized to 0.0005, the learning rate is adjusted dynamically, the number of training rounds is set to 100, and the optimal cutout processing module parameters are saved after the training.

5. The interactive tree image cutout method with real-time feedback according to claim 4, Features: The specific process of collecting natural images to build a pre-training dataset is as follows: collect the main public datasets in the current image matting field, including PhotoMatte85 dataset, AIM500 dataset, AM2000 dataset, withoutbg100 dataset, Distinctions646 dataset, P3M10K RealwordPortrait636 dataset and SIMD dataset.