Green screen matting method and device
By constructing a green screen keying dataset and background dataset containing green overflow information, using deep learning model training, the problem of cumbersome parameter adjustment and green overflow removal in traditional green screen keying methods is solved, and automatic and real-time green screen keying is achieved to achieve visually realistic effect.
Patent Information
- Application Number
- CN202210785154.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-29
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2042-06-29
AI Technical Summary
The traditional green screen keying method requires professionals to adjust a large number of parameters. The processing speed is slow and the steps are cumbersome, and it is difficult to achieve automatic and real-time green overflow removal. The natural image keying method is unnatural when green screen keying.
A green screen keying dataset and background dataset containing green overflow information are built. Through deep learning model training, foreground images and alpha images without green overflow information are generated. A lightweight network structure is used to achieve automatic and real-time green screen keying.
Automatic green screen cushion processing is realized, removing green overflow, achieving visually realistic effects, avoiding manual adjustment of parameters, and improving processing speed and accuracy.
Smart Images

Figure CN115222762B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a green screen matting method and device. Background Art
[0002] Traditional green screen keying methods include chroma keying, color difference keying, luminance keying, and triangle keying. Many professional green screen keying software programs are based on and modified from these traditional methods. While professional green screen keying software offers good results, setting parameters requires professional expertise, which consumes significant labor and time. Furthermore, traditional green screen keying methods typically separate the keying and green spill removal steps, making them cumbersome. Natural image keying involves keying images captured in natural scenes, eliminating the need to consider green spill. Therefore, the results are unnatural when used for green screen keying, and few solutions can achieve this automatically and in real time. Summary of the Invention
[0003] In response to the shortcomings of the existing technology, the present invention proposes a green screen matting method and device, which can automatically and real-timely realize green screen matting processing without manual intervention, and effectively remove the green overflow phenomenon to achieve a more visually realistic effect.
[0004] In order to achieve the above-mentioned object, the present invention provides a green screen matting method, comprising:
[0005] Constructing a green screen keying dataset and a green screen background dataset, wherein the green screen keying dataset includes green overflow information;
[0006] Randomly selecting a first foreground image and a first Alpha image corresponding to the first foreground image from the green screen matting dataset, where the first foreground image contains green overflow information;
[0007] Randomly select a green screen background image from the green screen background dataset;
[0008] Synthesize the first foreground image, the first Alpha map, and the green screen background image to generate an initial green screen image;
[0009] Generating a target green screen background image using the initial green screen image;
[0010] The initial green screen image and the target green screen background image are input into a deep learning model for training, and a second foreground image and a second alpha image corresponding to the second foreground image are output, where the second foreground image does not contain green overflow information.
[0011] Optionally, different green pixel information is used to simulate different green screen shooting scenes to construct the green screen background dataset.
[0012] Optionally, the first foreground image, the first Alpha image, and the green screen background image are all processed using geometric enhancement and pixel enhancement methods.
[0013] Optionally, the generated initial green screen image is:
[0014] C=F×α+B×(1-α)
[0015] Wherein, F represents the first foreground image containing green overflow information, α represents the first Alpha image corresponding to the first foreground image, B represents the green screen background image, and C represents the initial green screen image.
[0016] Optionally, generating a target green screen background image using the initial green screen image includes:
[0017] Convert the initial green screen image from RGB color space to HSV color space;
[0018] Based on the HSV color space, the initial green screen image is subjected to binary image processing to generate a binary green screen image;
[0019] Synthesizing the initial green screen image with the binarized green screen image to obtain an initial green screen background image, wherein the initial green screen background image includes green pixel information and black pixel information;
[0020] Clustering is performed on the initial green screen background image to obtain the target green screen background image, where the target green screen background image contains green pixel information.
[0021] Optionally, the generated binary green screen image is:
[0022]
[0023] Among them, miGreen and maGreen represent the minimum threshold and maximum threshold set in the HSV color space respectively;
[0024] The initial green screen image is synthesized with the binarized green screen image to obtain the initial green screen background image:
[0025] B'=C×(1-mask)
[0026] Wherein, C represents the initial green screen image.
[0027] Optionally, the deep learning model adopts a lightweight deep learning model.
[0028] Optionally, calculate the loss function of the second Alpha image,
[0029]
[0030] in, represents the first loss function, Represents a second loss function, the first loss function and the second loss function are combined to train the second Alpha image, and the first loss function is used to measure the predicted second Alpha image α i The real data corresponding to the second Alpha image The difference between The second loss function is the gradient loss,
[0031] Calculate the loss function of the second foreground image,
[0032]
[0033] Among them, F i represents the predicted second foreground image, represents the real data corresponding to the second foreground image.
[0034] Optionally, a green screen keying dataset and a green screen background dataset are constructed according to different classifications of opaque, semi-transparent, transparent, and complex structure classes.
[0035] Another aspect of the present invention provides a green screen matting device, which uses the above-mentioned green screen matting method, and the device at least comprises:
[0036] A data set construction module is used to construct a green screen keying data set and a green screen background data set, wherein the green screen keying data set includes green overflow information;
[0037] An image synthesis module, configured to randomly select a first foreground image and a first alpha image corresponding to the first foreground image from the green screen matting dataset, wherein the first foreground image includes green overflow information;
[0038] Randomly select a green screen background image from the green screen background dataset;
[0039] Synthesize the first foreground image, the first Alpha map, and the green screen background image to generate an initial green screen image;
[0040] Generating a target green screen background image using the initial green screen image;
[0041] An image training module is used to use the initial green screen image and the target green screen background image to input into a deep learning model for training, and output a second foreground image and a second alpha image corresponding to the second foreground image, wherein the second foreground image does not contain green overflow information.
[0042] Another aspect of the present invention further provides a storage medium for storing a computer program for executing the above-mentioned green screen matting method.
[0043] On the other hand, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned green screen matting method when executing the computer program.
[0044] From the above scheme, it can be seen that the advantages of the present invention are:
[0045] The green screen matting method provided in this embodiment of the present invention, by constructing a diverse green screen matting dataset and a green screen background dataset containing green overflow information, enables green screen matting and green overflow removal problems to be addressed through network training. Furthermore, a first foreground image containing green overflow information and a corresponding first alpha image are randomly selected from the green screen matting dataset; the first foreground image and the first alpha image are synthesized with the green screen background image to generate an initial green screen image; the initial green screen image is then used to automatically generate a target green screen background image as auxiliary information. The initial green screen image is combined with the target green screen background image to achieve more refined matting quality. This automation eliminates the need for manual parameter adjustment and ensures matting accuracy without human intervention. The initial green screen image and the target green screen background image are then input into a constructed deep learning model for training, outputting a second foreground image without green overflow information and a corresponding second alpha image. This not only solves both green screen matting and green overflow removal problems within the same model, but also utilizes a lightweight network structure to ensure matting accuracy while simultaneously increasing processing speed, achieving real-time performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of the process of a green screen matting method provided by an embodiment of the present invention;
[0047] Figure 2 for Figure 1 The specific flow diagram of step S4 of the green screen matting method provided in;
[0048] Figure 3 The comparison results of the green screen matting method of the present invention with the natural image matting methods CF, KNN, FBA, MODNet, LFP, BGMV2, and AIM are shown;
[0049] Figure 4 The green screen matting method of the present invention is compared with the professional matting software Keylight and Aximmetry;
[0050] Figure 5 This is a framework diagram of the green screen matting device of the present invention;
[0051] Figure 6 A schematic diagram of the structure of an electronic device;
[0052] in:
[0053] 400-Green screen keying device;
[0054] 401-dataset construction module;
[0055] 402-Image synthesis module;
[0056] 403-Image training module;
[0057] 500-electronic equipment;
[0058] 501-processor;
[0059] 502-Memory. DETAILED DESCRIPTION
[0060] In order to make the above features and effects of the present invention more clearly understood, embodiments are given below and described in detail with reference to the accompanying drawings.
[0061] As previously mentioned, existing traditional green screen keying methods require professionals to adjust numerous parameters, resulting in slow processing speeds and cumbersome steps. This invention provides a real-time, automatic green screen keying method based on deep learning that can remove green spill. Using user-provided green screen images or video frames as input, this method simultaneously completes both the green screen keying and green spill removal tasks without manual parameter adjustment. This green screen keying method can be directly used in applications such as filming, virtual studios, livestreaming by influencers, and offline VR experience centers.
[0062] Specifically, refer to Figure 1 As shown in Figure 1 A schematic diagram showing the flow of the green screen matting method provided by this embodiment is shown;
[0063] A green screen matting method, comprising:
[0064] S1. Construct a green screen keying dataset and a green screen background dataset, wherein the green screen keying dataset includes green overflow information.
[0065] In this embodiment, a green screen matting dataset and a green screen background dataset containing green overflow are constructed by shooting various types of green screen materials in a real green screen scene and adding a foreground image with green overflow to Ground Truth.
[0066] In specific implementations, for green screen keying datasets, which contain green overflow information, we can construct a green screen keying dataset by classifying diverse foreground objects into opaque, semi-transparent, transparent, and complex structure categories. For example, opaque objects include clothing of different colors, people in different poses (hair), tables and chairs, etc.; semi-transparent and transparent objects include gauze, mineral water bottles, glasses, etc.; and complex structures include entangled wires and mesh structures.
[0067] For the green screen background dataset, different green pixel information may be used to simulate different green screen shooting scenes to construct the green screen background dataset.
[0068] S2. Randomly selecting a first foreground image and a first Alpha image corresponding to the first foreground image from the green screen matting dataset, wherein the first foreground image includes green overflow information; and
[0069] A green screen background image is randomly selected from the green screen background dataset.
[0070] In a specific implementation, Keylight processing is used to randomly select a first foreground image containing green overflow information from the green screen matting dataset, and generate a first Alpha image corresponding to the first foreground image. The first foreground image containing green overflow information is a newly added dataset in this embodiment, which facilitates the network deep learning model to learn the characteristics of green overflow.
[0071] S3. Synthesize the first foreground image, the first Alpha image, and the green screen background image to generate an initial green screen image.
[0072] In a specific implementation, the first foreground image, the first Alpha image, and the green screen background image are synthesized to generate an initial green screen image:
[0073] C=F×α+B×(1-α)
[0074] Wherein, F represents the first foreground image containing green overflow information, α represents the first Alpha image corresponding to the first foreground image, B represents the green screen background image, and C represents the initial green screen image.
[0075] To address the problem of removing green overflow, this embodiment adds an image with green overflow to the green screen matting dataset, namely, the first foreground image containing green overflow information. By synthesizing it with the green screen background dataset and simultaneously predicting the alpha map and foreground image, the characteristics of the green overflow can be learned and effectively removed, thereby achieving a visually realistic effect.
[0076] Furthermore, the first foreground image, the first alpha image, and the green screen background image can all be pre-processed using geometric enhancement and pixel enhancement methods to enhance the diversity of the dataset and facilitate subsequent synthesis to generate the initial green screen image. Geometric enhancement includes operations such as upside-down flipping, left-right flipping, rotation, translation, and scaling; and pixel enhancement includes operations such as contrast adjustment, saturation adjustment, hue adjustment, and brightness adjustment.
[0077] S4. Generate a target green screen background image using the initial green screen image.
[0078] In the specific implementation, Figure 2 As shown in Figure 2 The specific flow diagram of step S4 is shown, and generating the target green screen background image using the initial green screen image specifically includes:
[0079] S41, converting the initial green screen image from the RGB color space to the HSV color space;
[0080] S42: Based on the HSV color space, perform binary image processing on the initial green screen image to generate a binary green screen image. The generated binary green screen image is:
[0081]
[0082] Among them, miGreen and maGreen represent the minimum threshold and maximum threshold set in the HSV color space respectively.
[0083] S43: Synthesize the initial green screen image and the binarized green screen image to obtain an initial green screen background image, wherein the initial green screen background image includes green pixel information and black pixel information. The initial green screen background image is:
[0084] B'=C×(1-mask)
[0085] Wherein, C represents the initial green screen image.
[0086] S44. Cluster the initial green screen background image to obtain the target green screen background image, where the target green screen background image includes green pixel information. In this embodiment, a K-means clustering method may be used to cluster the images into two categories, and the background image containing green pixel information is selected as the target green screen background image B".
[0087] In this embodiment, the target green screen background image is automatically generated using the initial green screen image, which effectively improves the precision of the green screen matting and avoids manual adjustment in traditional methods.
[0088] S5. Use the initial green screen image and the target green screen background image to input into a deep learning model for training, and output a second foreground image and a second Alpha image corresponding to the second foreground image, where the second foreground image does not contain green overflow information.
[0089] In a specific implementation, the initial green screen image C and the target green screen background image B" are input together into the constructed deep learning model for training, wherein the deep learning model structure adopts a lightweight deep learning model, which is composed of an encoder, an ASPP module, a jump connection and a decoder. The encoder adopts a lightweight MobileNetV2 model to extract image features. The lightweight MobileNetV2 model is a lightweight processing of the standard MobileNetV2 model. In this embodiment, expansion is used on the last module of the standard MobileNetV2 model to keep the output stride at 16, and the classifier module originally used for classification is deleted. The ASPP module refers to a void spatial convolution pooling pyramid, which samples the given input in parallel with void convolutions at different sampling rates. It is equivalent to capturing the context of the image at multiple scales, that is, increasing the network receptive field without changing the resolution, thereby enhancing the network's ability to obtain multi-scale context. The skip connection enables the decoder to obtain high-order semantic features and low-order detail features at the same time. The implementation method is to return feature maps of all resolutions in the forward method of MobileNetV2 for use by the decoder. The decoder fuses high- and low-order features and simultaneously predicts Alpha and removes the foreground image with green overflow. In this embodiment, a simple structure is used for the decoder network to reduce the number of parameters and speed up training. The decoder network has four convolutional layers. Except for the last layer, each convolutional layer is followed by a BN layer and a ReLU activation function. Before each convolutional layer, bilinear upsampling is used and spliced with the skip connection features from the encoder.
[0090] In this embodiment, a lightweight deep learning model is adopted, which greatly improves the processing speed while maintaining the accuracy of the matting, thus meeting the real-time requirements.
[0091] In addition, in this embodiment, by calculating the loss function of the second Alpha image and the loss function of the second foreground image, and combining the loss function of the second Alpha image with the loss function of the second foreground image, model training is performed to evaluate the second Alpha image and the foreground image after removing the green overflow, that is, the second foreground image, thereby realizing real-time automatic green screen matting processing that can remove green overflow.
[0092] Among them, the loss function of the second Alpha image consists of two parts, namely represents the first loss function, Represents a second loss function, the first loss function and the second loss function are combined to train the second Alpha image, and the first loss function is used to measure the predicted second Alpha image α i The real data corresponding to the second Alpha image The difference between The second loss function is the gradient loss,
[0093] The loss function of the second foreground image is expressed as: Among them, F i represents the predicted second foreground image, represents the real data corresponding to the second foreground image.
[0094] In summary, the green screen matting method provided in this embodiment, based on a deep learning approach, constructs a diverse green screen matting dataset and a green screen background dataset containing green spill information, enabling the green screen matting and green spill removal problems to be addressed through network training. Furthermore, a first foreground image containing green spill information and a corresponding first alpha image are randomly selected from the green screen matting dataset; the first foreground image and the first alpha image are synthesized with the green screen background image to generate an initial green screen image; the initial green screen image is then used to automatically generate a target green screen background image as auxiliary information. The initial green screen image is then combined with the target green screen background image to achieve more refined matting quality. This automation eliminates the need for manual parameter adjustment and ensures matting accuracy without human intervention. The initial green screen image and the target green screen background image are then input into a constructed deep learning model for training, outputting a second foreground image without green spill information and a corresponding second alpha image. This not only solves both green screen matting and green spill removal problems within the same model, but also utilizes a lightweight network structure to ensure matting accuracy while simultaneously increasing processing speed, achieving real-time performance. Compared with existing green screen matting methods, the green screen matting method provided by the present invention performs better in challenging scenes such as uneven lighting. In addition, the method is automatic and real-time, does not require human intervention, and effectively removes green overflow to achieve a more visually realistic effect. In addition, the method does not require trimap or background as additional input, and is more efficient.
[0095] The green screen matting method provided in this embodiment is compared with the existing natural image matting methods CF, KNN, FBA, MODNet, LFP, BGMV2, and AIM, as well as with the existing professional matting software Keylight and Aximmetry to verify the effect.
[0096] Specifically, the comparison results with natural image matting methods CF, KNN, FBA, MODNet, LFP, BGMV2, and AIM are as follows Figure 3As shown in . Specifically, 5 real green screen images of humans and semi-transparent images are selected to demonstrate the effectiveness of the proposed method. CF predicts fine boundary details, but performs poorly in areas with small holes. KNN performs better than CF, but may fail in some semi-transparent scenes. MODNet cannot matte other types because it is only trained on portrait datasets. All three methods perform poorly in predicting the foreground because they do not consider a key problem in green screen matting: green overflow. Although AIM is an automatic matting method, it usually predicts rough edges. BGMv2 performs poorly due to its weak generalization ability for the input background and its inability to remove green overflow. FBA and LFP methods generally perform better in predicting alpha maps. However, their ability to remove green overflow is very limited. In contrast, the green screen matting method provided by the present invention can show more visually realistic matting performance.
[0097] The results are compared with the existing professional matte software Keylight and Aximmetry. Figure 4 As shown in . Since professional green screen matting software performs well in general green screen scenes, three challenging green screen data were selected for comparison, which show human body images with different types of hair. It can be seen from the figure that the green screen matting method provided by the present invention can obtain more hair details than professional green screen matting software. Professional green screen matting software does not work well in some cases because they try to adjust parameters to obtain a clean background, which results in rough edge details. The present invention implements green screen matting and green overflow removal based on a deep learning method. First, a green screen matting dataset containing green overflow and a green screen background dataset are created. Then, the initial green screen image and the automatically generated target green screen background image are input into the constructed network model. The model simultaneously outputs a second foreground image that does not contain green overflow information and a corresponding second alpha image, thereby solving both the green screen matting and green overflow removal problems.
[0098] The above embodiments of the present invention can be applied to a terminal device that performs the green screen keying method. The terminal device may include a personal terminal and a host terminal, and the present invention is not limited thereto. The terminal may support operating systems such as Windows, Android, iOS, and Windows Phone.
[0099] Reference Figure 5 , Figure 5 A green screen matting device 400 is shown, which can be applied to a personal terminal and a host terminal device. Figure 1 、 Figure 2 The method shown, the green screen matting device provided in the embodiment of the present application can implement each process implemented by the above-mentioned green screen matting method.
[0100] A green screen matting device 400, using the above-mentioned green screen matting method, comprises at least:
[0101] A data set construction module 401 is used to construct a green screen keying data set and a green screen background data set, wherein the green screen keying data set includes green overflow information;
[0102] An image synthesis module 402 is configured to randomly select a first foreground image and a first alpha image corresponding to the first foreground image from the green screen matting dataset, wherein the first foreground image includes green overflow information;
[0103] Randomly select a green screen background image from the green screen background dataset;
[0104] Synthesize the first foreground image, the first Alpha map, and the green screen background image to generate an initial green screen image;
[0105] Generating a target green screen background image using the initial green screen image;
[0106] The image training module 403 is used to use the initial green screen image and the target green screen background image to input into the deep learning model for training, and output a second foreground image and a second alpha image corresponding to the second foreground image, where the second foreground image does not contain green overflow information.
[0107] The green screen matting device provided in this embodiment can automatically and in real time realize green screen matting processing without manual intervention, and effectively remove the green overflow phenomenon, achieving a more visually realistic effect with higher efficiency.
[0108] It should be understood that the descriptions of the green screen matting method are also applicable to the green screen matting device 400 according to the embodiment of the present application. To avoid repetition, they will not be described in detail.
[0109] In addition, it should be understood that in the green screen cutout device 400 according to the embodiment of the present application, the division of the above-mentioned functional modules is only used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the green screen cutout device 400 can be divided into functional modules different from the modules illustrated above to complete all or part of the functions described above.
[0110] Figure 6 It is a structural diagram of an electronic device provided in an embodiment of the present application.
[0111] like Figure 6As shown in , an embodiment of the present application also provides an electronic device 500, including a processor 501, a memory 502, and a program or instruction stored in the memory 502 and executable on the processor 501. When the program or instruction is executed by the processor 501, the steps of the above-mentioned green screen matting method are implemented, and the same technical effect can be achieved.
[0112] It should be noted that the electronic devices in the embodiments of the present application may include mobile electronic devices and non-mobile electronic devices.
[0113] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the above-mentioned green screen matting method are implemented and the same technical effect can be achieved.
[0114] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising 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 device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be applied, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0115] 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 the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0116] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
Claims
1. A green screen matting method, characterized in that: include: Constructing a green screen keying dataset and a green screen background dataset, wherein the green screen keying dataset includes green overflow information; Randomly selecting a first foreground image and a first Alpha image corresponding to the first foreground image from the green screen matting dataset, where the first foreground image contains green overflow information; Randomly select a green screen background image from the green screen background dataset; Synthesize the first foreground image, the first Alpha map, and the green screen background image to generate an initial green screen image; Generating a target green screen background image using the initial green screen image includes: Convert the initial green screen image from RGB color space to HSV color space; Based on the HSV color space, the initial green screen image is subjected to binary image processing to generate a binary green screen image; Synthesizing the initial green screen image with the binarized green screen image to obtain an initial green screen background image, wherein the initial green screen background image includes green pixel information and black pixel information; Performing clustering processing on the initial green screen background image to obtain the target green screen background image, where the target green screen background image contains green pixel information; The initial green screen image and the target green screen background image are input into a deep learning model for training, and a second foreground image and a second alpha image corresponding to the second foreground image are output, where the second foreground image does not contain green overflow information.
2. The method according to claim 1, characterized in that Different green pixel information is used to simulate different green screen shooting scenes to construct the green screen background dataset.
3. The method according to claim 1, characterized in that Also includes: The first foreground image, the first Alpha image and the green screen background image are all processed using geometric enhancement and pixel enhancement methods.
4. The method according to claim 1, wherein The initial green screen image generated is: C=F×α+B×(1-α) Wherein, F represents the first foreground image containing green overflow information, α represents the first Alpha image corresponding to the first foreground image, B represents the green screen background image, and C represents the initial green screen image.
5. The method according to claim 1, wherein The generated binary green screen image is: Among them, miGreen and maGreen represent the minimum threshold and maximum threshold set in the HSV color space respectively; The initial green screen image is synthesized with the binarized green screen image to obtain the initial green screen background image: B'=C×(1-mask) Wherein, C represents the initial green screen image.
6. The method according to claim 1, characterized in that The deep learning model adopts a lightweight deep learning model.
7. The method according to claim 1, characterized in that Also includes: Calculate the loss function of the second Alpha image, in, represents the first loss function, Represents a second loss function, the first loss function and the second loss function are combined to train the second Alpha image, and the first loss function is used to measure the predicted second Alpha image α i The real data corresponding to the second Alpha image The difference between The second loss function is the gradient loss, Calculate the loss function of the second foreground image, Among them, F i represents the predicted second foreground image, represents the real data corresponding to the second foreground image.
8. The method according to claim 1, characterized in that According to the different classifications of opaque, semi-transparent, transparent, and complex structure classes, a green screen keying dataset and a green screen background dataset are constructed.
9. A green screen matting device, characterized in that: The green screen matting method according to any one of claims 1 to 8 is adopted, wherein the device at least comprises: A data set construction module is used to construct a green screen keying data set and a green screen background data set, wherein the green screen keying data set includes green overflow information; An image synthesis module, configured to randomly select a first foreground image and a first alpha image corresponding to the first foreground image from the green screen matting dataset, wherein the first foreground image includes green overflow information; Randomly select a green screen background image from the green screen background dataset; Synthesize the first foreground image, the first Alpha map, and the green screen background image to generate an initial green screen image; Generating a target green screen background image using the initial green screen image includes: Convert the initial green screen image from RGB color space to HSV color space; Based on the HSV color space, the initial green screen image is subjected to binary image processing to generate a binary green screen image; Synthesizing the initial green screen image with the binarized green screen image to obtain an initial green screen background image, wherein the initial green screen background image includes green pixel information and black pixel information; Performing clustering processing on the initial green screen background image to obtain the target green screen background image, where the target green screen background image contains green pixel information; An image training module is used to use the initial green screen image and the target green screen background image to input into a deep learning model for training, and output a second foreground image and a second alpha image corresponding to the second foreground image, wherein the second foreground image does not contain green overflow information.
Citation Information
Patent Citations
Background replacing method and apparatus for images
CN105678724A
Foreground image acquisition method and device
CN108961258A