High-precision image cutting method, device, terminal equipment and computer-readable storage medium

Through the combination of semantic segmentation network and prediction model, a high-precision cutout method is realized, which solves the problems of user input limitation, output quality reduction and time-consuming in the existing technology, and realizes high-quality ultra-high-definition picture cutout.

CN114972404BActive Publication Date: 2025-04-25MIGU CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210360588.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2025-04-25
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

The existing high-precision cutout method requires users to provide additional input, limiting application scenarios; lower resolution inference leads to a decrease in output quality; non-resolution inference takes a long time, limiting the application of ultra-high-definition high-precision cutout.

Method used

A high-precision cutout method is proposed, which generates a mask image by acquiring the image to be processed and using a preset semantic segmentation network to process it; preprocessing the mask image to generate a three-point map; predicting it through a prediction model based on the pending image and the three-point map to generate a target cutout result.

Benefits of technology

Under the premise of acceptable inference time consumption and storage resource consumption, high-quality ultra-high-definition picture cutouts are achieved, solving the problems of user input limitations, output quality decline and time-consuming.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114972404B_ABST
    Figure CN114972404B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and discloses a high-precision cutout method, device, terminal device, and computer-readable storage medium. The present invention obtains an image to be processed, and processes the image to be processed using a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; performs image preprocessing on the mask image to generate a trisection map corresponding to the mask image; inputs the image to be processed and the trisection map into a prediction model, and determines a predicted image of the image to be processed through the prediction model; generates a cutout result based on the image to be processed and the predicted image; thereby achieving high-quality ultra-high-definition image cutout under the premise of acceptable inference time consumption and storage resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a high-precision image cutting method, device, terminal equipment and computer-readable storage medium. Background Art

[0002] Cutting out an image is one of the most common operations in image processing. It is to separate a part of a picture or image from the original picture or image into a separate layer.

[0003] At present, there are two main methods for high-precision matting. Method 1: The method of pre-inputting the background or trimap requires the user to input the background image of the image to be matted or use tools to manually draw the trimap of the image to be matted. Trimap refers to dividing the image to be matted into three areas: a determined foreground area, a determined background area, and an uncertain area. The uncertain area in the trimap is the area that needs to be finely matted using the Matting model to achieve the effect goal of high-precision matting; Method 2: Single-model end-to-end Matting method. This type of method does not rely on the user to provide additional input, and directly uses the Matting matting method to obtain the final high-precision matting result.

[0004] However, the existing high-precision cutout methods still have the following defects: they require users to provide additional input, which limits the application scenarios of high-precision cutouts; they reduce the resolution of the inference, which seriously reduces the output quality of high-definition and high-precision cutouts; and they do not reduce the resolution of the inference, which is time-consuming and limits the application scenarios of ultra-high-definition and high-precision cutouts. Summary of the invention

[0005] The main purpose of the present invention is to propose a high-precision cutout method, apparatus, terminal device and computer-readable storage medium, aiming to achieve high-quality ultra-clear image cutout under the premise of acceptable inference time consumption and storage resource consumption.

[0006] To achieve the above object, the present invention provides a high-precision image cutting method, which comprises the following steps:

[0007] Acquire an image to be processed, and process the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed;

[0008] Preprocessing the mask image to generate a trisection image corresponding to the mask image;

[0009] Based on the image to be processed and the trisection image, prediction is performed by using a prediction model to determine a predicted image corresponding to the image to be processed;

[0010] Based on the image to be processed and the predicted image, a target matting result is generated.

[0011] Preferably, before the step of acquiring the image to be processed and processing the image to be processed by a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed, the high-precision matting method further includes:

[0012] Obtain sample images and sample cutout results corresponding to each sample image;

[0013] The sample image and the sample cutout result are input into an initialization model, and the initialization model is iteratively trained to obtain a prediction model.

[0014] Preferably, the step of acquiring the image to be processed, and processing the image to be processed by a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed comprises:

[0015] Acquire an image to be processed, and downsample the image to be processed to obtain a low-resolution image corresponding to the image to be processed;

[0016] The low-resolution image is subjected to semantic segmentation processing by means of the preset semantic segmentation network to obtain a mask image corresponding to the low-resolution image.

[0017] Preferably, the step of preprocessing the mask image to generate a trisection image corresponding to the mask image includes:

[0018] Upsampling the mask image to obtain a mask image with an original resolution restored;

[0019] Performing an erosion operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain an erosion operation result image corresponding to the mask image of the original resolution;

[0020] Performing a dilation operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain a dilation operation result image corresponding to the mask image of the original resolution;

[0021] Create a new initialized sample trigraph with the same size as the mask image;

[0022] The initialized sample trisection map is updated by using the erosion operation result map and the dilation operation result map to obtain a corresponding trisection map.

[0023] Preferably, the step of performing prediction based on the image to be processed and the tripartite map by using a prediction model to determine a predicted image corresponding to the image to be processed comprises:

[0024] Determining whether the resolution of the longest side of the image to be processed is greater than a preset value;

[0025] If the resolution of the longest side of the image to be processed is greater than a preset value, the resolution of the longest side of the image to be processed is adjusted to the preset value, and the shortest side of the image to be processed is adjusted in proportion to obtain an image to be processed in a standard format;

[0026] Scaling and adjusting the three-division image to be the same size as the image to be processed in the standard format to obtain an adjusted three-division image;

[0027] The image to be processed in the standard format and the adjusted trisection image are input into a prediction model for prediction, so as to obtain a predicted image corresponding to the image to be processed in the standard format.

[0028] Preferably, the step of performing prediction based on the image to be processed and the tripartite map by using a prediction model to determine a predicted image corresponding to the image to be processed comprises:

[0029] Determining whether the resolution of the longest side of the image to be processed is greater than a preset value;

[0030] If the resolution of the longest side of the image to be processed is less than or equal to the preset value, the image to be processed does not need to be adjusted;

[0031] Scaling the trisection image to be the same size as the image to be processed to obtain an adjusted trisection image;

[0032] The image to be processed and the adjusted tri-image are input into a prediction model for prediction to obtain a predicted image corresponding to the image to be processed.

[0033] Preferably, the predicted image includes a foreground area, a background area and an uncertain area, and the step of generating a target matting result based on the image to be processed and the predicted image includes:

[0034] Adjusting the predicted image to obtain a predicted image restored to its original size;

[0035] Assigning a region in the image to be processed that is larger than a preset transparency to the foreground region in the predicted image of the original size to obtain the assigned foreground region;

[0036] Generate a composite image through the assigned foreground area, the background area and the uncertain area;

[0037] Correcting the assigned foreground area and the background area by using the image to be processed, the synthesized image and the uncertain area to obtain a corrected foreground area and a corrected background area;

[0038] A target cutout result is generated through the corrected foreground area, the corrected background area and the image to be processed.

[0039] In addition, to achieve the above-mentioned purpose, the present invention also provides a high-precision image cutting device, the high-precision image cutting device comprising:

[0040] A segmentation module is used to obtain an image to be processed, and process the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed;

[0041] A preprocessing module, used for preprocessing the mask image to generate a trisection image corresponding to the mask image;

[0042] A prediction module, used to perform prediction based on the image to be processed and the tri-image by using a prediction model to determine a predicted image corresponding to the image to be processed;

[0043] A generation module is used to generate a target matting result based on the image to be processed and the predicted image.

[0044] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal device, which includes: a memory, a processor, and a high-precision cutout program stored on the memory and run on the processor, and when the high-precision cutout program is executed by the processor, the steps of the high-precision cutout method as described above are implemented.

[0045] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a high-precision cutout program is stored, and when the high-precision cutout program is executed by a processor, the steps of the high-precision cutout method as described above are implemented.

[0046] The high-precision matting method, device, terminal device and computer-readable storage medium proposed in the present invention; the high-precision matting method includes: obtaining an image to be processed, and processing the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; preprocessing the mask image to generate a tripartite graph corresponding to the mask image; based on the image to be processed and the tripartite graph, predicting through a prediction model to determine the predicted image corresponding to the image to be processed; generating a target matting result based on the image to be processed and the predicted image. The present invention obtains an image to be processed, and processes the image to be processed using a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; image preprocessing the mask image to generate a tripartite graph corresponding to the mask image; inputting the image to be processed and the tripartite graph into the prediction model, and determining the predicted image of the image to be processed through the prediction model; generating a matting result based on the image to be processed and the predicted image; thereby achieving high-quality ultra-high-definition image matting under the premise of acceptable inference time consumption and storage resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention;

[0048] Figure 2 It is a schematic diagram of the process of the first embodiment of the high-precision cutout method of the present invention;

[0049] Figure 3 A schematic diagram of a first sub-process of a first embodiment of a high-precision image cutting method of the present invention;

[0050] Figure 4 A schematic diagram of a preset semantic segmentation network structure of the first embodiment of the high-precision image cutting method of the present invention;

[0051] Figure 5 A schematic diagram of a sub-flow chart of step S10 of the first embodiment of the high-precision image cutting method of the present invention;

[0052] Figure 6 A schematic diagram of the prediction model structure of the first embodiment of the high-precision image cutting method of the present invention;

[0053] Figure 7 It is a flow chart of the second embodiment of the high-precision cutout method of the present invention;

[0054] Figure 8 It is a schematic diagram of the process of the third embodiment of the high-precision cutout method of the present invention;

[0055] Fig. 9 It is a schematic diagram of the flow chart of the fourth embodiment of the high-precision cutout method of the present invention;

[0056] Fig.10 It is a flowchart of a fifth embodiment of the high-precision image cutting method of the present invention;

[0057] Fig.11 It is a flow chart of a sixth embodiment of the high-precision cutout method of the present invention;

[0058] Fig.12 Schematic diagram of functional modules of the first embodiment of the high-precision image cutting method of the present invention.

[0059] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

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

[0061] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.

[0062] The device in the embodiment of the present invention may be a mobile terminal or a server device.

[0063] like Figure 1 As shown, the device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0064] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation of the device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0065] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a high-precision cutout program.

[0066] Among them, the operating system is a program for managing and controlling terminal devices and software resources, supporting the operation of network communication modules, user interface modules, high-precision cutout programs and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.

[0067] exist Figure 1 In the terminal device shown, the terminal device calls the high-precision image cutting program stored in the memory 1005 through the processor 1001, and executes the operations in each embodiment of the following high-precision image cutting method.

[0068] Based on the above hardware structure, an embodiment of the high-precision cutout method of the present invention is proposed.

[0069] Reference Figure 2 , Figure 2 This is a flow chart of the first embodiment of the high-precision cutout method of the present invention, referring to Figure 3 , the high-precision cutout method comprises:

[0070] Step S10, obtaining an image to be processed, and processing the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed;

[0071] Step S20, preprocessing the mask image to generate a trisection image corresponding to the mask image;

[0072] Step S30, based on the image to be processed and the three-part image, prediction is performed by using a prediction model to determine a predicted image corresponding to the image to be processed;

[0073] Step S40: generating a target matting result based on the image to be processed and the predicted image.

[0074] This embodiment obtains an image to be processed, and processes the image to be processed using a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; performs image preprocessing on the mask image to generate a tripartite map corresponding to the mask image; inputs the image to be processed and the tripartite map into a prediction model, and determines a predicted image of the image to be processed through the prediction model; generates a matting result based on the image to be processed and the predicted image; thereby achieving high-quality ultra-high-definition image matting under the premise of acceptable inference time consumption and storage resource consumption.

[0075] The following is a detailed description of each step:

[0076] Step S10: acquiring an image to be processed, and processing the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed.

[0077] In this embodiment, the high-precision cutout method of the present invention is applied to a mobile terminal or a server device. The image to be processed is obtained from different channels, which can be obtained through mobile terminals of different users, or by receiving the image to be processed forwarded by other users' mobile terminals; this embodiment does not limit the channel for obtaining the image to be processed. Among them, the image to be processed can be any picture, which can be an image containing a person or an image without a person.

[0078] The preset semantic segmentation network includes but is not limited to one or more of the full convolutional neural network series network, DeepLab series network, SegNet, PSPNet, RefineNet, and U-Net; in this embodiment, the U2NET network is preferably used as the preset semantic segmentation network, referring to Figure 4 , Figure 4 This is a schematic diagram of the U2NET network structure.

[0079] The U2NET network structure consists of a 6-stage encoder, a 5-stage decoder, and a feature map fusion output module, and each stage is filled by the configured RSU.

[0080] The left side of the network is the downsampling process. The first four stages are filled with RSUs with layer parameters L of 7, 6, 5, and 4 respectively. The size of the feature map is halved and restored layer by layer. The last two stages are filled with RSUs with dilated convolutions. The size of the feature map remains unchanged. In the encoding stage, RSUs are connected by 2×2 maximum pooling, and the feature map size becomes the original The right side of the network is the upsampling process. In each stage, the RSU configuration is the same as the symmetrical position on the left side, and the input is the cascaded combination of the output of the previous stage and the output of the symmetrical stage on the left. In the decoding stage, the RSUs are connected through bilinear interpolation operations to gradually restore the feature map. Finally, the feature maps output by each RSU are concatenated and decoded to obtain the final feature map.

[0081] By using the U2NET network to perform semantic segmentation on the image to be processed, a mask image corresponding to the image to be processed is generated. The mask image is a low-precision matting result of the image to be processed.

[0082] Further, in one embodiment, referring to Figure 5 , step S10 comprises:

[0083] Step S11, obtaining an image to be processed, and downsampling the image to be processed to obtain a low-resolution image corresponding to the image to be processed.

[0084] In this embodiment, the image to be processed is obtained from different channels, and the image to be processed is downsampled. Specifically, the size of the image to be processed is adjusted to 320*320 pixels to obtain a low-resolution image corresponding to the image to be processed.

[0085] Step S12: performing semantic segmentation processing on the low-resolution image through the preset semantic segmentation network to obtain a mask image corresponding to the low-resolution image.

[0086] In this embodiment, the preset semantic segmentation network is preferably a U2NET network, and the U2NET network is used to perform semantic segmentation processing on the low-resolution image to generate a mask image corresponding to the low-resolution image, wherein the mask image is a low-precision matting result of the image to be processed.

[0087] Step S20: preprocess the mask image to generate a trisection image corresponding to the mask image.

[0088] In this embodiment, in image analysis, the input image is processed before feature extraction, segmentation and matching. The main purpose of image preprocessing is to eliminate irrelevant information in the image, restore useful real information, enhance the detectability of relevant information and simplify data to the maximum extent, thereby improving the reliability of feature extraction, image segmentation, matching and recognition. The preprocessing process generally includes steps such as digitization, geometric transformation, normalization, smoothing, restoration and enhancement.

[0089] The mask image generated above is subjected to multiple rounds of erosion and / or dilation preprocessing operations using a preset convolution kernel to generate a trisection map corresponding to the mask image. Among them, a large number of experiments in various application scenarios have shown that the value of the convolution kernel for preprocessing in the interval (3,8) is the best; the number of preprocessing iterations in the interval (3,12) is the best.

[0090] Step S30: Based on the image to be processed and the tripartite map, prediction is performed using a prediction model to determine a predicted image corresponding to the image to be processed.

[0091] In one embodiment, the prediction model is preferably a Matting prediction network model, referring to Figure 6 , Figure 6 The structure of the Matting network is shown in Figure 1. The image to be processed and the three-part image are used as the input of the Matting prediction network model. After the Encoder (encoding) and the Decoder (decoding), the predicted image corresponding to the image to be processed is output. The predicted image includes the foreground area F, the background area B, and the uncertain area Alpha. The foreground area in the predicted image is the predicted matting result of the image to be processed.

[0092] Step S40: generating a target matting result based on the image to be processed and the predicted image.

[0093] In this embodiment, the predicted image includes a foreground area F, a background area B, and an uncertain area Alpha; wherein the foreground area in the predicted image is the predicted cutout result of the image to be processed. There is a certain deviation between the predicted cutout result in the predicted image and the target cutout of the image to be processed, and the predicted image needs to be fused and corrected using the image to be processed.

[0094] The foreground area F, background area B and uncertain area Alpha in the predicted image are updated and corrected through the image to be processed to generate the target matting result corresponding to the image to be processed.

[0095] This embodiment obtains an image to be processed, and processes the image to be processed using a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; performs image preprocessing on the mask image to generate a tripartite map corresponding to the mask image; inputs the image to be processed and the tripartite map into a prediction model, and determines a predicted image of the image to be processed through the prediction model; generates a matting result based on the image to be processed and the predicted image; thereby achieving high-quality ultra-high-definition image matting under the premise of acceptable inference time consumption and storage resource consumption.

[0096] Furthermore, based on the first embodiment of the high-precision image cutting method of the present invention, a second embodiment of the high-precision image cutting method of the present invention is proposed.

[0097] The difference between the second embodiment of the high-precision image cutout method and the first embodiment of the high-precision image cutout method is that in this embodiment, before the step S10 of obtaining the image to be processed and processing the image to be processed by a preset semantic segmentation network to obtain the mask image corresponding to the image to be processed, refer to Figure 7 , high-precision cutout methods also include:

[0098] Step A10, obtaining sample images and sample cutout results corresponding to each sample image;

[0099] Step A20: input the sample image and the sample cutout result into an initialization model, and iteratively train the initialization model to obtain a prediction model.

[0100] This embodiment obtains a large number of sample images and the sample cutout results corresponding to each sample image; inputs the sample images and the sample cutout results into an initialization model, and iteratively trains the initialization model to generate a prediction model; thereby improving the prediction effect of the trained prediction model.

[0101] The following is a detailed description of each step:

[0102] Step A10, obtaining sample images and sample cutout results corresponding to each sample image.

[0103] In this embodiment, a large number of sample images and sample cutout results corresponding to each sample image are obtained from different channels, which can be obtained through mobile terminals of different users, or by receiving sample images forwarded by other users' mobile terminals, and sample cutout results corresponding to each sample image; this embodiment does not limit the channels for obtaining sample images and sample cutout results corresponding to each sample image. Among them, the sample images and the sample cutout results corresponding to each sample image can be any pictures, which can be images containing people or images without people.

[0104] Step A20: input the sample image and the sample cutout result into an initialization model, and iteratively train the initialization prediction model to obtain a prediction model.

[0105] In this embodiment, a large number of sample images and the sample cutout results corresponding to each sample image are input into the initialization model, and the initialization model is iteratively trained to generate a prediction model, thereby improving the prediction effect of the trained prediction model.

[0106] This embodiment obtains a large number of sample images and the sample cutout results corresponding to each sample image; inputs the sample images and the sample cutout results into an initialization model, and iteratively trains the initialization model to generate a prediction model; thereby improving the prediction effect of the trained prediction model.

[0107] Furthermore, based on the first and second embodiments of the high-precision image cutting method of the present invention, a third embodiment of the high-precision image cutting method of the present invention is proposed.

[0108] The third embodiment of the high-precision cutout method is different from the first and second embodiments of the high-precision cutout method in that the present embodiment is to pre-process the mask image in step S20 to generate a refinement of the three-part image corresponding to the mask image, referring to Figure 8 , the step specifically includes:

[0109] Step S21, upsampling the mask image to obtain a mask image with an original resolution restored;

[0110] Step S22, performing an erosion operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain an erosion operation result image corresponding to the mask image of the original resolution;

[0111] Step S23, performing a dilation operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain a dilation operation result image corresponding to the mask image of the original resolution;

[0112] Step S24, creating a new initialized sample tri-image with the same size as the mask image;

[0113] Step S25, updating the initialized sample trisection graph by using the erosion operation result graph and the dilation operation result graph to obtain a trisection graph corresponding to the operation result graph.

[0114] In this embodiment, by upsampling the mask image with a resolution of 320*320, a mask image with the same original resolution as the resolution of the image to be processed is obtained; then, the mask image with the original resolution is eroded and expanded using a preset convolution kernel and number of iterations to obtain an erosion operation result map corresponding to the mask image and an expansion operation result map corresponding to the mask image; a new initialization sample tri-map with the same size as the image to be processed is created, and the initialization sample tri-map is updated using the erosion operation result map and the expansion operation result map to obtain the tri-map corresponding to the image to be processed; thereby achieving a refined cutout effect.

[0115] The following is a detailed description of each step:

[0116] Step S21 , upsampling the mask image to obtain a mask image with the original resolution restored.

[0117] In this embodiment, the mask image with a resolution of 320*320 is up-sampled so that the mask image is restored to the same resolution as the image to be processed, thereby obtaining a mask image with the original resolution.

[0118] Step S22, performing an erosion operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain an erosion operation result image corresponding to the mask image of the original resolution.

[0119] In this embodiment, an erosion algorithm is applied to the mask image of the original resolution, and the convolution kernel of the erosion operation is randomly selected in the interval (3, 8) and the number of erosion iterations is randomly selected in the interval (3, 12) to obtain an erosion operation result diagram corresponding to the mask image of the original resolution; wherein the intervals of the preset convolution kernel and the preset number of iterations need to be optimized according to the specific scenario; through experiments in a large number of application scenarios, it is proved that the effect of selecting a convolution kernel between 3 and 8 is optimal; wherein, the actual preset convolution kernel needs to be set according to the actual situation.

[0120] Step S23, performing a dilation operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain a dilation operation result image corresponding to the mask image of the original resolution.

[0121] In this embodiment, a dilation algorithm is applied to a mask image of the original resolution, a convolution kernel for the dilation operation is randomly selected in the interval (3, 8) and the number of dilation iterations is randomly selected in the interval (3, 12), and a dilation operation result graph corresponding to the mask image of the original resolution is obtained; wherein the intervals of the preset convolution kernel and the preset number of iterations need to be optimized according to specific scenarios; experiments in a large number of application scenarios have proved that selecting a convolution kernel between 3 and 8 has the best effect; wherein, the actual preset convolution kernel needs to be set according to actual conditions.

[0122] Step S24, creating a new initialized sample tri-image with the same size as the mask image.

[0123] In this embodiment, a new initialization sample tri-map having the same size as the image to be processed is created, and the initialization sample tri-map is initialized to 128.

[0124] Step S25, updating the initialized sample trisection graph by using the erosion operation result graph and the dilation operation result graph to obtain a trisection graph corresponding to the operation result graph.

[0125] In this embodiment, the initialization sample trigraph is updated using the corrosion result map and the expansion result map; specifically, the initialization sample trigraph is updated using the corrosion operation result map, and the corresponding position greater than or equal to 254 in the updated initialization sample trigraph is updated to 255; the corresponding position equal to 0 in the updated initialization sample trigraph is updated using the expansion operation result map, and is updated to 0; finally, the trigraph corresponding to the corrosion and expansion operation result is obtained. Among them, 255 in the trigraph represents the determined human foreground area, 0 represents the determined background area, and 128 represents the uncertain area, which is the area that requires the prediction model (that is, the Matting network model) to make accurate predictions.

[0126] In this embodiment, a mask image with an original resolution the same as that of the image to be processed is obtained by upsampling the mask image with a resolution of 320*320; then, an erosion and dilation operation is performed on the mask image with the original resolution using a preset convolution kernel and a number of iterations to obtain an erosion operation result map corresponding to the mask image and an expansion operation result map corresponding to the mask image; a new initialization sample trigraph with the same size as the image to be processed is created, and the initialization sample trigraph is updated using the erosion operation result map and the expansion operation result map to obtain the trigraph corresponding to the image to be processed; thereby achieving a refined cutout effect.

[0127] Furthermore, based on the first, second and third embodiments of the high-precision image cutting method of the present invention, a fourth embodiment of the high-precision image cutting method of the present invention is proposed.

[0128] The fourth embodiment of the high-precision image cutout method is different from the first, second and third embodiments of the high-precision image cutout method in that the fourth embodiment is to perform a prediction based on the image to be processed and the three-part image by using a prediction model to determine the refinement of the predicted image corresponding to the image to be processed, referring to Fig. 9 , the step specifically includes:

[0129] Step B10, determining whether the resolution of the longest side of the image to be processed is greater than a preset value;

[0130] Step B20, if the resolution of the longest side of the image to be processed is greater than the preset value, the resolution of the longest side of the image to be processed is adjusted to the preset value, and the shortest side of the image to be processed is adjusted in proportion to obtain the image to be processed in a standard format;

[0131] Step B30, scaling and adjusting the three-division image to be the same size as the image to be processed in the standard format, to obtain an adjusted three-division image;

[0132] Step B40: input the image to be processed in the standard format and the adjusted trisection image into a prediction model for prediction, so as to obtain a predicted image corresponding to the image to be processed in the standard format.

[0133] This embodiment determines whether the longest side of the original image resolution is greater than the preset value 2200; when the longest side of the image resolution to be processed is greater than the preset value 2200, the longest side of the image to be processed is scaled to the preset value 2200, and the shortest side of the image to be processed is proportionally scaled to obtain a standard format image to be processed. Then, the three-part image is scaled to the same size as the image to be processed in the standard format to obtain an adjusted three-part image. The image to be processed in the standard format and the adjusted three-part image are input into the Matting network model, and the Matting network model is used for reasoning to output the predicted image corresponding to the image to be processed in the standard format; thereby improving the efficiency of target matting.

[0134] The following is a detailed description of each step:

[0135] Step B10, determining whether the resolution of the longest side of the image to be processed is greater than a preset value.

[0136] In this embodiment, it is determined whether the longest side resolution of the image to be processed is greater than a preset value. When the longest side resolution of the image to be processed is greater than the preset value, the resolution of the image to be processed needs to be adjusted. In this embodiment, the preset value is preferably 2200.

[0137] Step B20, if the resolution of the longest side of the image to be processed is greater than the preset value, the resolution of the longest side of the image to be processed is adjusted to the preset value, and the shortest side of the image to be processed is proportionally adjusted to obtain a standard format image to be processed.

[0138] In this embodiment, when the longest side of the resolution of the image to be processed is greater than the preset value 2200, the longest side of the image to be processed is scaled to the preset value 2200; at the same time, the shortest side of the image to be processed is scaled proportionally to obtain a standard format image to be processed.

[0139] Step B30: scaling and adjusting the three-division image to be the same size as the image to be processed in the standard format, to obtain an adjusted three-division image.

[0140] In this embodiment, when the longest side of the resolution of the image to be processed is greater than the preset value 2200, the longest side of the image to be processed is scaled to the preset value 2200; then, the tripartite image is scaled and adjusted to the same size as the image to be processed in the standard format to obtain the adjusted tripartite image.

[0141] Step B40: input the image to be processed in the standard format and the adjusted trisection image into a prediction model for prediction, so as to obtain a predicted image corresponding to the image to be processed in the standard format.

[0142] In this embodiment, the image to be processed in a standard format and the adjusted tripartite map are input into the prediction model, wherein, in this embodiment, the prediction model is preferably a Matting network model, and prediction reasoning is performed through the Matting network model to obtain a predicted image corresponding to the image to be processed in a standard format; wherein the predicted image includes a foreground area F, a background area B and an uncertain area Alpha.

[0143] In this embodiment, it is determined whether the longest side of the original image resolution is greater than the preset value 2200; when the longest side of the image resolution to be processed is greater than the preset value 2200, the longest side of the image to be processed is scaled to the preset value 2200, and the shortest side of the image to be processed is scaled proportionally to obtain a standard format image to be processed. Then, the three-part image is scaled to the same size as the image to be processed in the standard format to obtain an adjusted three-part image. The image to be processed in the standard format and the adjusted three-part image are input into the Matting network model, and the Matting network model is used for reasoning to output a predicted image corresponding to the image to be processed in the standard format; thereby improving the efficiency of target matting.

[0144] Furthermore, based on the first, second, third and fourth embodiments of the high-precision image cutting method of the present invention, a fifth embodiment of the high-precision image cutting method of the present invention is proposed.

[0145] The fifth embodiment of the high-precision cutout method is different from the first, second, third and fourth embodiments of the high-precision cutout method in that the present embodiment is to perform a prediction based on the image to be processed and the three-part image by using a prediction model to determine the refinement of the predicted image corresponding to the image to be processed, referring to Fig.10 , the step specifically includes:

[0146] Step C10, determining whether the resolution of the longest side of the image to be processed is greater than a preset value;

[0147] Step C20: if the resolution of the longest side of the image to be processed is less than or equal to the preset value, the image to be processed does not need to be adjusted;

[0148] Step C30, scaling the trisection image to be the same size as the image to be processed, to obtain an adjusted trisection image;

[0149] Step C40: input the image to be processed and the adjusted tripartite image into a prediction model for prediction, so as to obtain a predicted image corresponding to the image to be processed.

[0150] This embodiment determines whether the longest side of the original image resolution is greater than a preset value of 2200; when the longest side of the resolution of the image to be processed is less than or equal to the preset value 2200, there is no need to adjust the image to be processed. Then, the three-part image is scaled to the same size as the image to be processed to obtain an adjusted three-part image. The image to be processed and the adjusted three-part image are input into the Matting network model, and the Matting network model is used for reasoning to output the predicted image corresponding to the image to be processed; thereby improving the efficiency of target matting.

[0151] The following is a detailed description of each step:

[0152] Step C10, determining whether the resolution of the longest side of the image to be processed is greater than a preset value.

[0153] In this embodiment, it is determined whether the longest side resolution of the image to be processed is greater than a preset value. When the longest side resolution of the image to be processed is greater than the preset value, the resolution of the image to be processed needs to be adjusted. In this embodiment, the preset value is preferably 2200. When the longest side resolution of the image to be processed is less than or equal to the preset value 2200, the resolution of the image to be processed does not need to be adjusted.

[0154] Step C20: If the resolution of the longest side of the image to be processed is less than or equal to the preset value, the image to be processed does not need to be adjusted.

[0155] In this embodiment, the preset value is preferably 2200. When the longest side resolution of the image to be processed is less than or equal to the preset value 2200, there is no need to adjust the resolution of the image to be processed.

[0156] Step C30: scaling the trisection image to be the same size as the image to be processed, to obtain an adjusted trisection image.

[0157] In this embodiment, when the longest side of the resolution of the image to be processed is less than or equal to the preset value 2200, there is no need to adjust the resolution of the image to be processed; then, the tri-image is scaled and adjusted to the same size as the image to be processed to obtain the adjusted tri-image.

[0158] Step C40: input the image to be processed and the adjusted tripartite image into a prediction model for prediction, so as to obtain a predicted image corresponding to the image to be processed.

[0159] In this embodiment, the image to be processed and the adjusted tripartite map are input into the prediction model, wherein, in this embodiment, the prediction model is preferably a Matting network model, and prediction reasoning is performed through the Matting network model to obtain a predicted image corresponding to the image to be processed; wherein the predicted image includes a foreground area F, a background area B and an uncertain area Alpha.

[0160] In this embodiment, it is determined whether the longest side of the original image resolution is greater than a preset value of 2200; when the longest side of the resolution of the image to be processed is less than or equal to the preset value of 2200, there is no need to adjust the image to be processed. Then, the three-part image is scaled to the same size as the image to be processed to obtain an adjusted three-part image. The image to be processed and the adjusted three-part image are input into the Matting network model, and the Matting network model is used for reasoning to output a predicted image corresponding to the image to be processed; thereby improving the efficiency of target matting.

[0161] Furthermore, based on the first, second, third, fourth and fifth embodiments of the high-precision image cutting method of the present invention, a sixth embodiment of the high-precision image cutting method of the present invention is proposed.

[0162] The sixth embodiment of the high-precision image cutout method is different from the first, second, third, fourth and fifth embodiments of the high-precision image cutout method in that the sixth embodiment is a refinement of the target image cutout result generated based on the image to be processed and the predicted image in step S40, wherein the predicted image includes a foreground area, a background area and an uncertain area. Fig.11 , the step specifically includes:

[0163] Step S41, adjusting the predicted image to obtain a predicted image restored to its original size;

[0164] Step S42, assigning a region in the image to be processed that is larger than a preset transparency to the foreground region in the predicted image of the original size to obtain the assigned foreground region;

[0165] Step S43, generating a composite image through the assigned foreground area, the background area and the uncertain area;

[0166] Step S44, correcting the assigned foreground area and the background area by using the image to be processed, the synthesized image and the uncertain area to obtain a corrected foreground area and a corrected background area;

[0167] Step S45, generating a target cutout result through the corrected foreground area, the corrected background area and the image to be processed.

[0168] This embodiment obtains a predicted image of the original size by adjusting the image size of the predicted image to the same size as the image to be processed; uses the determined area in the image to be processed as the foreground of the predicted image of the original size to obtain the assigned foreground area; then performs fusion correction processing on the assigned foreground area, background area, and uncertain area in the predicted image of the original size to obtain a composite image. The assigned foreground area and background area are respectively corrected using the image to be processed, the composite image, and the uncertain area in the composite image to obtain a corrected foreground area and a corrected background area; then the corrected foreground area F′, the corrected background area B′, and the image to be processed x are used for fusion correction processing to obtain the target cutout result of the image to be processed; thereby achieving high-quality and ultra-high-definition cutouts.

[0169] The following is a detailed description of each step:

[0170] Step S41, adjusting the predicted image to obtain a predicted image restored to its original size.

[0171] In this embodiment, the image size of the predicted image is adjusted to be the same as the size of the image to be processed, so as to obtain the predicted image of the original size.

[0172] Step S42, assigning a region in the image to be processed that is larger than a preset transparency to the foreground region in the predicted image of the original size to obtain the assigned foreground region.

[0173] In this embodiment, a determined area in the image to be processed is used as the foreground of the predicted image of the original size to obtain the assigned foreground area; specifically, the following calculation formula is used:

[0174] F[Alpha≥=0.95]=x[Alpha≥0.95]

[0175] Among them, the predicted image includes a foreground area F, a background area B and an uncertain area Alpha; x in the formula is the image to be processed, and F is the foreground area F of the predicted image; the part of the uncertain area alpha in the image to be processed x that is greater than or equal to 0.95 is assigned to the foreground area F in the predicted image.

[0176] Step S43, generating a composite image through the assigned foreground area, the background area and the uncertain area.

[0177] In this embodiment, the composite image is obtained by synthesizing the foreground region F, the background region B, and the uncertain region Alpha after the value assignment in the prediction image of the original size. The specific synthesis formula is as follows:

[0178] x′=F*Alpha+(1-Alpha)*B

[0179] Wherein, x′ is the synthesized image; F is the assigned foreground area F in the predicted image; B is the background area B in the predicted image; Alpha is the uncertain area Alpha in the predicted image.

[0180] Step S44, correcting the assigned foreground area and the background area through the image to be processed, the synthesized image and the uncertain area, and obtaining a corrected foreground area and a corrected background area.

[0181] In this embodiment, since the foreground area F, the background area B, and the uncertain area Alpha are network prediction outputs, there is a certain deviation between the synthesized image x′ and the image to be processed x, that is, the purpose of the F, B, Alpha fusion correction processing is: under the premise that it is known that F, B, alpha are not the optimal solutions, F, B, alpha are corrected so that the synthesized image x′ = the image to be processed x, assuming that alpha has no deviation from the true value.

[0182] The foreground area F and the background area B are corrected using the image to be processed, the synthesized image, and the uncertain area Alpha in the predicted image to obtain the corrected foreground area F′ and the background area B′; the specific correction formula is as follows:

[0183] F′=F+Alpha*(1-x′)

[0184] =F+Alpha*(x-(Alpha*F+(1-Alpha)*B))

[0185] =Alpha*x+(1-Alpha 2 )*F-Alpha*(1-Alpha)*B

[0186] Wherein, x is the image to be processed; x′ is the synthesized image; F is the assigned foreground area F in the predicted image; B is the background area B in the predicted image; Alpha is the uncertain area Alpha in the predicted image.

[0187] B′=B+(1-Alpha)*(xx′)

[0188] =B+(1-Alpha)*(x-(Alpha*F′)+(1-Alpha)*B))

[0189] =(1-Alpha)*x+(1-(1-Alpha) 2 )*B-(1-Alpha)*Alpha*F′

[0190] Wherein, x is the image to be processed; x′ is the synthesized image; B is the background area B in the predicted image; Alpha is the uncertain area Alpha in the predicted image; and F′ is the corrected foreground area F′.

[0191] Step S45, generating a target cutout result through the corrected foreground area, the corrected background area and the image to be processed.

[0192] In this embodiment, the corrected foreground area F′, the corrected background area B′ and the image to be processed x are used to perform fusion correction processing to obtain a target matting result of the image to be processed.

[0193] The specific correction formula is as follows:

[0194]

[0195] In the formula, x is the image to be processed; B is the background area B in the predicted image; F′ is the corrected foreground area F′; B′ is the corrected background area B′; Alpha′ is the corrected uncertain area Alpha′.

[0196] The corrected foreground area F′ and the uncertain area Alpha′ are generated as the final high-precision matting result output; thereby achieving high-quality and ultra-high-definition matting.

[0197] In this embodiment, the image size of the predicted image is adjusted to the same size as the image to be processed to obtain the predicted image of the original size; the determined area in the image to be processed is used as the foreground of the predicted image of the original size to obtain the assigned foreground area; then the assigned foreground area, background area, and uncertain area in the predicted image of the original size are fused and corrected to obtain a composite image. The assigned foreground area and background area are corrected using the image to be processed, the composite image, and the uncertain area in the composite image to obtain the corrected foreground area and the corrected background area; the corrected foreground area F′, the corrected background area B′, and the image to be processed x are then fused and corrected to obtain the target cutout result of the image to be processed; thus, high-quality and ultra-high-definition cutouts are achieved.

[0198] Furthermore, based on the first, second, third, fourth, fifth and sixth embodiments of the high-precision image cutting method of the present invention, a seventh embodiment of the high-precision image cutting method of the present invention is proposed.

[0199] In this embodiment, the image to be processed x is obtained from different channels, and then the size of the image to be processed x is adjusted to 320*320 pixels to obtain a low-resolution image corresponding to the image to be processed x. The low-resolution image is semantically segmented by using a semantic segmentation network (U2NET network) to generate a mask image alpha1 corresponding to the low-resolution image. The mask image alpha1 is a low-precision matting result of the image to be processed.

[0200] The mask image alpha1 with a resolution of 320*320 is resized to the resolution of the image to be processed x, and the mask image alpha2 with the original resolution is output; the erosion and dilation algorithm is applied to the mask image alpha2 with the original resolution, and the convolution kernel of the erosion and dilation is randomly selected in the interval (3, 8) and the number of iterations of the erosion and dilation is randomly selected in the interval (3, 12); wherein the interval needs to be optimized according to the specific scene; specifically, the erosion operation and the dilation operation are applied to the mask image alpha2 with the original resolution respectively, and the convolution kernel of the erosion and dilation is randomly selected in the interval (3, 8) and the number of iterations of the erosion and dilation is randomly selected in the interval (3, 12) as the operation parameters, and the erosion operation result image dilated and the dilation operation result image eroded are obtained.

[0201] Create a new initialization sample trimap with the same size as the original resolution mask image alpha2, and set the initialization to 128. Use the erosion operation result map dilated to update the initialization sample trimap, and update the corresponding positions greater than or equal to 254 in the updated initialization sample trimap trimap to 255; use the dilation operation result map eroded to update the corresponding positions equal to 0 in the updated initialization sample trimap to 0; finally, the trimap corresponding to the erosion and dilation operation result is obtained. Among them, 255 in the trimap represents the determined human foreground area, 0 represents the determined background area, and 128 represents the uncertain area. The uncertain area is the area that requires the prediction model (that is, the Matting network model) to make accurate predictions.

[0202] When the longest side of the resolution of the image to be processed x is greater than 2200, the longest side of the image to be processed x is scaled to 2200, and the shortest side of the image to be processed x is scaled proportionally to obtain the image to be processed in a standard format.

[0203] At the same time, the trimap is scaled and adjusted to be the same size as the image to be processed in the standard format, thereby obtaining an adjusted trimap.

[0204] The image to be processed in a standard format and the adjusted trimap are input into the Matting network model, and the Matting network model is used for reasoning to output a predicted image corresponding to the image to be processed in a standard format; wherein the predicted image includes a foreground area F, a background area B and an uncertain area Alpha.

[0205] The image size of the predicted image is adjusted to the same size as the image to be processed x to obtain the predicted image of the original size; the determined area in the image to be processed x is used as the foreground of the predicted image of the original size to obtain the assigned foreground area F; then the assigned foreground area F, the background area B, and the uncertain area Alpha in the predicted image of the original size are fused and corrected to obtain the synthesized image x′.

[0206] The assigned foreground region F and background region B are respectively corrected using the image to be processed x, the synthesized image x′ and the uncertain region Alpha to obtain the corrected foreground region F′ and the corrected background region B′.

[0207] The corrected foreground area F′, the corrected background area B′ and the image to be processed x are used for correction processing to obtain the corrected uncertain area Alpha′; wherein the corrected foreground area F′ is the target cutout result of the image to be processed x; thereby, high-quality ultra-high-definition image cutout is achieved under the premise of acceptable inference time consumption and storage resource consumption.

[0208] The present invention also provides a high-precision image cutting device. Fig.12 The high-precision image cutting device of the present invention comprises:

[0209] The segmentation module 10 is used to obtain an image to be processed, and process the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed;

[0210] A preprocessing module 20, used for preprocessing the mask image to generate a trisection image corresponding to the mask image;

[0211] A prediction module 30, configured to perform prediction based on the image to be processed and the trisection image by using a prediction model to determine a predicted image corresponding to the image to be processed;

[0212] The generating module 40 is used to generate a target matting result based on the image to be processed and the predicted image.

[0213] In addition, the present invention also provides a computer-readable storage medium, on which a high-precision cutout program is stored. When the high-precision cutout program is executed by a processor, the steps of the high-precision cutout method described above are implemented.

[0214] Among them, the method implemented when the high-precision cutout program running on the processor is executed can refer to the various embodiments of the high-precision cutout method of the present invention, and will not be repeated here.

[0215] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0216] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0217] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0218] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A high-precision cutout method, characterized in that: The high-precision cutout method comprises the following steps: Acquire an image to be processed, and perform semantic segmentation processing on the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; Preprocessing the mask image to generate a trisection image corresponding to the mask image; Based on the image to be processed and the trisection image, prediction is performed by using a prediction model to determine a predicted image corresponding to the image to be processed; Based on the image to be processed and the predicted image, generating a target matting result; The predicted image includes a foreground area, a background area and an uncertain area, and the step of generating a target matting result based on the image to be processed and the predicted image includes: Adjusting the predicted image to obtain a predicted image restored to its original size; Assigning a region in the image to be processed that is larger than a preset transparency to the foreground region in the predicted image of the original size to obtain the assigned foreground region; Generate a composite image through the assigned foreground area, the background area and the uncertain area; Correcting the assigned foreground area and the background area by using the image to be processed, the synthesized image and the uncertain area to obtain a corrected foreground area and a corrected background area; A target cutout result is generated through the corrected foreground area, the corrected background area and the image to be processed.

2. The high-precision cutout method according to claim 1, characterized in that: Before the step of acquiring the image to be processed and processing the image to be processed by a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed, the high-precision matting method further includes: Obtain sample images and sample cutout results corresponding to each sample image; The sample image and the sample cutout result are input into an initialization model, and the initialization model is iteratively trained to obtain a prediction model.

3. The high-precision cutout method according to claim 1, characterized in that: The step of acquiring an image to be processed, and performing semantic segmentation processing on the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed includes: Acquire an image to be processed, and downsample the image to be processed to obtain a low-resolution image corresponding to the image to be processed; The low-resolution image is subjected to semantic segmentation processing by means of the preset semantic segmentation network to obtain a mask image corresponding to the low-resolution image.

4. The high-precision cutout method as claimed in claim 1, characterized in that: The step of preprocessing the mask image to generate a trisection image corresponding to the mask image includes: Upsampling the mask image to obtain a mask image with an original resolution restored; Performing an erosion operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain an erosion operation result image corresponding to the mask image of the original resolution; Performing a dilation operation on the mask image of the original resolution by using a preset convolution kernel and a preset number of iterations to obtain a dilation operation result image corresponding to the mask image of the original resolution; Create a new initialized sample trigraph with the same size as the mask image; The initialized sample trisection map is updated by using the erosion operation result map and the dilation operation result map to obtain a corresponding trisection map.

5. The high-precision cutout method according to claim 1, characterized in that: The step of predicting the image to be processed and the tripartite map by using a prediction model to determine the predicted image corresponding to the image to be processed comprises: Determining whether the resolution of the longest side of the image to be processed is greater than a preset value; If the resolution of the longest side of the image to be processed is greater than a preset value, the resolution of the longest side of the image to be processed is adjusted to the preset value, and the shortest side of the image to be processed is adjusted in proportion to obtain an image to be processed in a standard format; Scaling and adjusting the three-division image to be the same size as the image to be processed in the standard format to obtain an adjusted three-division image; The image to be processed in the standard format and the adjusted trisection image are input into a prediction model for prediction, so as to obtain a predicted image corresponding to the image to be processed in the standard format.

6. The high-precision cutout method according to claim 1, characterized in that: The step of predicting the image to be processed and the tripartite map by using a prediction model to determine the predicted image corresponding to the image to be processed comprises: Determining whether the resolution of the longest side of the image to be processed is greater than a preset value; If the resolution of the longest side of the image to be processed is less than or equal to the preset value, the image to be processed does not need to be adjusted; Scaling the trisection image to be the same size as the image to be processed to obtain an adjusted trisection image; The image to be processed and the adjusted tri-image are input into a prediction model for prediction to obtain a predicted image corresponding to the image to be processed.

7. A high-precision cutout device, characterized in that: The high-precision cutout device comprises: A segmentation module is used to obtain an image to be processed, and process the image to be processed through a preset semantic segmentation network to obtain a mask image corresponding to the image to be processed; A preprocessing module, used for preprocessing the mask image to generate a trisection image corresponding to the mask image; A prediction module, used to perform prediction based on the image to be processed and the tri-image by using a prediction model to determine a predicted image corresponding to the image to be processed; A generating module, used for generating a target matting result based on the image to be processed and the predicted image; The predicted image includes a foreground area, a background area and an uncertain area, and the generating module is further used for: Adjusting the predicted image to obtain a predicted image restored to its original size; Assigning a region in the image to be processed that is larger than a preset transparency to the foreground region in the predicted image of the original size to obtain the assigned foreground region; Generate a composite image through the assigned foreground area, the background area and the uncertain area; Correcting the assigned foreground area and the background area by using the image to be processed, the synthesized image and the uncertain area to obtain a corrected foreground area and a corrected background area; A target cutout result is generated through the corrected foreground area, the corrected background area and the image to be processed.

8. A terminal device, comprising: A memory, a processor, and a high-precision cutout program stored in the memory and executable on the processor, wherein the high-precision cutout program, when executed by the processor, implements the steps of the high-precision cutout method as described in any one of claims 1 to 6.

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

Citation Information

Patent Citations

  • Picture matting method and device, terminal equipment and computer readable storage medium

    CN111383232A