Image processing method, device, electronic device and storage medium

By adaptively determining the background color and threshold, the problem of poor foreground extraction accuracy when image cutout in the prior art is solved, and higher accuracy and speed are achieved.

CN114723772BActive Publication Date: 2025-09-02DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210306661.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-25
Publication Date
2025-09-02
Estimated Expiration
2042-03-25

AI Technical Summary

Technical Problem

In the prior art, when cutting images, the background color is complex and requires manual definition, resulting in poor accuracy of foreground extraction.

Method used

By acquiring the color data of the reference image and standard background color data, adaptively determine the background color data and divide the threshold, realize automatic acquisition of adaptive background color and threshold, and improve the accuracy of foreground extraction.

Benefits of technology

Improve the accuracy of foreground extraction, reduce image processing steps, and improve the processing speed of foreground extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114723772B_ABST
    Figure CN114723772B_ABST
Patent Text Reader

Abstract

The present disclosure discloses an image processing method, apparatus, electronic device, and storage medium. The method includes: acquiring a reference image; determining adaptive background color data for the reference image based on the reference image's color data and standard background color data; determining an adaptive segmentation threshold for the reference image based on the reference image's color data and the adaptive background color data; and performing foreground extraction on the reference image and / or a background image identical to the reference image based on the adaptive segmentation threshold. The technical solution of the present disclosure enables adaptive determination of background color and segmentation thresholds, improving the accuracy of foreground extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer data processing technology, and in particular to an image processing method, apparatus, electronic device, and storage medium. Background Art

[0002] With the rapid development of multimedia technology, cutout technology has been widely used in many scenarios, such as film production, online class live broadcast, etc., that is, extracting the foreground part of the image and removing or replacing the background part of the image.

[0003] In the prior art, when performing cutout processing on an image, the background color is relatively complex and manual definition of the background color and division threshold is required, which is prone to errors and results in poor accuracy in foreground extraction. Summary of the Invention

[0004] The embodiments of the present disclosure provide an image processing method, apparatus, electronic device, and storage medium to adaptively determine background color and divide thresholds, thereby improving the accuracy of foreground extraction.

[0005] In a first aspect, an embodiment of the present disclosure provides an image processing method, comprising:

[0006] Acquire a reference image, and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data;

[0007] determining an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data;

[0008] Foreground extraction is performed on the reference image and / or the background image identical to the reference image based on the adaptive segmentation threshold.

[0009] In a second aspect, the embodiments of the present disclosure further provide an image processing device, including:

[0010] A color data determination module, configured to obtain a reference image and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data;

[0011] an image threshold determination module, configured to determine an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data;

[0012] A foreground extraction module is configured to perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

[0013] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:

[0014] one or more processors;

[0015] a storage device for storing one or more programs,

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in any one of the embodiments of the present disclosure.

[0017] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to execute the image processing method as described in any one of the embodiments of the present disclosure.

[0018] The technical solution of the embodiment of the present disclosure obtains a reference image, determines the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data, and obtains accurate background color data; further, determines the adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data, realizes the adaptive acquisition of the division threshold, and makes the obtained adaptive division threshold more reliable; further, based on the more reliable adaptive division threshold, foreground extraction is performed on the reference image and / or the same background image of the reference image, which can improve the accuracy of foreground extraction, and can reduce the steps of image processing, thereby improving the processing speed of foreground extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.

[0020] Figure 1 A flowchart of an image processing method provided by an embodiment of the present disclosure;

[0021] Figure 2 is a flowchart of an image processing method provided by an embodiment of the present disclosure;

[0022] Figure 3 is a flowchart of an image processing method provided by an embodiment of the present disclosure;

[0023] Figure 4 is a flowchart of an image processing method provided by an embodiment of the present disclosure;

[0024] Figure 5 is a flowchart of an image processing method provided by an embodiment of the present disclosure;

[0025] Figure 6 is a structural diagram of an image processing device provided by an embodiment of the present disclosure;

[0026] Figure 7 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.

[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0029] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.

[0030] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0031] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".

[0032] Figure 1 This is a flow chart of an image processing method provided by an embodiment of the present disclosure. The present disclosure embodiment is suitable for adaptively determining background color and dividing thresholds and automatically extracting image foreground. The method can be executed by the image processing device provided by the embodiment of the present disclosure. The image processing device can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal or a PC. Figure 1 , the method of this embodiment includes:

[0033] S110 : Acquire a reference image, and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data.

[0034] S120: Determine an adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data.

[0035] S130: Perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

[0036] In this embodiment, the reference image refers to the image used as the processing standard. Specifically, the adaptive segmentation threshold obtained after processing the reference image can be used to perform foreground extraction on images associated with the reference image, thereby reducing image processing steps and improving the speed of foreground extraction. When the image to be processed is a single image, the reference image is the image to be processed itself. When there are multiple images to be processed, all of which are set against the same background, the reference image can be any of the images to be processed.

[0037] The reference image may include a foreground and background. The foreground may include at least one target subject, and the background may be any portion of the reference image excluding the target subject. In this embodiment, the reference image includes a single-color background, such as a green screen or a blue screen. The target subject may include, but is not limited to, people, animals, trees, tables, buildings, and other designated objects.

[0038] Methods for obtaining a reference image may include but are not limited to: real-time image capture through an image capture device, and determining a reference image from one or more captured images; the reference image may also be retrieved through a preset storage location or other device; or video frames may be extracted from a video, and the extracted video frames may be determined as the reference image, wherein the video is a video captured under the same single color background.

[0039] Due to the diversity of color variations, even a single color background can exhibit numerous variations. For example, a green screen background can vary in color data due to variations in screen material, color depth, and brightness. Accurately determining background color data is crucial for accurate foreground extraction. In this embodiment, adaptive background color data corresponding to a reference image is determined, replacing the standard background color data. Foreground extraction is adaptively performed based on the differences in backgrounds across different images, improving the accuracy of background color data and further enhancing foreground extraction precision.

[0040] The adaptive background color data of the reference image can be determined based on the color data of the reference image and the standard background color data. The color data of the reference image refers to the color information of each pixel in the reference image, and may include but is not limited to RGB data, grayscale values, or color components. The standard background color data refers to the color information of the pixels in the standard background. The standard background can be a background composed of standard colors. For example, the standard RGB data for a green screen can be (R: 0, G: 255, B: 0), the standard RGB data for a blue screen can be (R: 0, G: 0, B: 255), etc. If other background colors exist, the corresponding standard RGB data can be set accordingly. The adaptive background color data can be background color data adaptively determined based on the color data of the reference image and the standard background color data. That is, the adaptive background color data can change with changes in the color data of the reference image and is a variable. It is understood that the color of the background in the reference image can be a standard background color or a different standard background color, and the adaptive background color data of different reference images can be different. Directly using standard background color data to extract the foreground of an image will result in errors in the extracted foreground. This embodiment determines adaptive background color data to obtain accurate color data corresponding to the background in the reference image, thereby improving the reliability of the background color data.

[0041] In some optional embodiments, the color similarity of the color data of each pixel in the reference image and the standard background color data can be calculated, and the color data corresponding to the pixel in the reference image whose similarity meets the preset similarity range can be determined as the adaptive background color data; it should be noted that the color similarity can be obtained by subtracting the color data corresponding to the pixel, and the smaller the data difference, the higher the similarity. The data difference can be the grayscale difference or color component difference between the pixel in the reference image and the pixel in the standard background, etc., which is not limited here. In some optional embodiments, when the area of ​​the background area is larger than the area of ​​the foreground area, the color data of each pixel in the reference image can be subtracted from the standard background color data to obtain the data difference, and the number of occurrences of each data difference can be counted, and the color data corresponding to the data difference with the largest number of occurrences can be determined as the adaptive background color data. This embodiment does not limit the method for determining the adaptive background color data.

[0042] Furthermore, after obtaining the adaptive background color data, the adaptive division threshold of the reference image can be determined based on the color data of the reference image and the adaptive background color data. The adaptive division threshold of the reference image refers to a foreground / background division threshold that can adapt to the background used by the reference image, and can be used to divide the foreground and background in the image to adaptively extract the foreground in the reference image and / or the same background image of the reference image, thereby improving the accuracy of foreground extraction. Among them, the same background image of the reference image refers to an image with the same background as the reference image. It can be understood that the color data corresponding to images with the same background is also the same, so the same division threshold can be used for foreground extraction, thereby improving the efficiency of foreground extraction for a large number of images with the same background.

[0043] In some optional embodiments, the color data of each pixel in the reference image and the adaptive background color data can be subtracted, the frequency of occurrence of each data difference can be counted, and the intermediate value of the color data corresponding to the data difference frequency peak and the color data of another difference frequency peak is determined as the adaptive division threshold. Among them, the data difference can be a grayscale difference or a color difference, etc., which is not limited here. It can be understood that the higher the frequency of occurrence of a certain data difference, the more likely the pixel corresponding to the data difference is located in the foreground or background. In an optional embodiment, the color data of each pixel in the reference image and the adaptive background color data can be clustered and calculated, and the adaptive threshold is obtained according to the clustering result. This embodiment does not limit the method for determining the adaptive threshold of the reference image.

[0044] It should be noted that the adaptive division threshold of the reference image may include one or more. If the adaptive division threshold of the reference image is one, then the reference image and / or the same background image of the reference image is divided according to the single adaptive division threshold of the reference image to obtain the foreground and background of the reference image; if the adaptive division threshold of the reference image is multiple, then the reference image is divided into multiple parts, such as the foreground part, the background part and the transition part, according to the multiple adaptive division thresholds of the reference image. Among them, the transition part refers to the junction of the foreground part and the background part. This part is easy to be divided incorrectly during the division and is more difficult to handle. It can be understood that by setting multiple adaptive division thresholds, the difficult-to-handle transition part can be processed separately and finely divided, which can effectively improve the accuracy of foreground extraction.

[0045] The image processing method provided by the embodiment of the present disclosure obtains accurate background color data by acquiring a reference image and determining the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data; further, the adaptive division threshold of the reference image is determined based on the color data of the reference image and the adaptive background color data, thereby realizing the adaptive acquisition of the division threshold and making the obtained adaptive division threshold more reliable; further, foreground extraction is performed on the reference image and / or the same background image of the reference image based on the more reliable adaptive division threshold, which can improve the accuracy of foreground extraction, reduce the steps of image processing, and improve the processing speed of foreground extraction.

[0046] refer to Figure 2 , Figure 2 The present invention provides a flowchart of an image processing method according to an embodiment of the present invention. The method according to this embodiment can be combined with the various optional schemes in the image processing method provided in the above embodiments. The image processing method provided in this embodiment is further refined. Optionally, the adaptive background color data of the reference image is determined based on the color data of the reference image and the standard background color data, including: determining the initial background area in the reference image based on the color data of the reference image and the standard background color data; and determining the adaptive background color data of the reference image based on the color data of the initial background area.

[0047] like Figure 2 , the method of this embodiment includes:

[0048] S210 : Acquire a reference image, and determine an initial background area in the reference image based on color data of the reference image and standard background color data.

[0049] S220 : Determine adaptive background color data of the reference image based on color data of the initial background area.

[0050] S230 : Determine an adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data.

[0051] S240: Perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

[0052] In this embodiment, the initial background area in the reference image can be determined based on the color data of the reference image and the standard background color data. The initial background area refers to the background area in the reference image obtained by rough calculation. Specifically, the difference between the color data of the reference image and the standard background color data can be calculated, and the area consisting of pixels whose data difference is less than a preset threshold can be determined as the initial background area in the reference image. The data difference can be a grayscale difference or a color component difference, etc., which is not limited here. It can be understood that the smaller the data difference, the closer the color of the pixel in the reference image is to the color of the standard background. Therefore, the area consisting of pixels whose data difference is less than the preset threshold can be determined as the initial background area in the reference image. The color data of the initial background area can be used to determine the adaptive background color data of the reference image. Exemplarily, the maximum value, minimum value or mean value of the color data of the initial background area can be determined as the adaptive background color data of the reference image, which is not limited here.

[0053] In some embodiments, determining the initial background area in the baseline image based on the color data of the baseline image and the standard background color data includes: determining the first distance information of the color data of each pixel point in the baseline image from the standard background color data; and determining the initial background area in the baseline image based on the first distance information and the distance threshold.

[0054] The first distance information may be spatial metric information between the color data of each pixel in the reference image and the standard background color data, for example, Euclidean distance, Mahalanobis distance, etc. The distance threshold may be a pre-set threshold based on experiments or experience, which can be used to judge the first distance information and determine the region consisting of pixels corresponding to the first distance information that meets the requirements as the initial background region in the reference image. It should be noted that the distance information can effectively express the difference between the color data of each pixel in the reference image and the standard background color data, thereby screening out the initial background region that meets the requirements. This method is computationally simple and can improve the speed of image processing.

[0055] Exemplarily, the Euclidean distance between the color data of the reference image and the standard background color data is calculated pixel by pixel, and pixels that meet a distance threshold are screened based on the Euclidean distance. The region consisting of pixels that meet the distance threshold is determined as the initial background region in the reference image. Exemplarily, pixels whose first distance information is less than the distance threshold can be determined as pixels in the initial background region to form the initial background region.

[0056] Based on the above embodiments, determining the adaptive background color data of the reference image based on the color data of the initial background area includes: determining the mean value of the color data in the initial background area as the adaptive background color data of the reference image.

[0057] For example, determining the color data mean of each pixel value in the initial background area as the adaptive background color data of the reference image can avoid inaccuracies in the adaptive background color data caused by a small number of abnormal pixels, thereby improving the reliability of the adaptive background color data. The color data mean can be a grayscale mean or a color component mean, etc., which is not limited here.

[0058] On the basis of the above embodiments, before determining the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data, it also includes: converting the color encoding mode of the reference image and the standard background data into a color-brightness separation mode, and extracting the color data of the reference image and the standard background color data in the color-brightness separation mode.

[0059] Among them, the color encoding mode may refer to a mode that uses multiple basic colors (such as red, green and blue) to construct an image, such as RGB color encoding, etc.; the color-brightness separation mode may refer to a mode that stores image brightness and color data separately, such as YUV color encoding, etc. It can be understood that in the color-brightness separation mode, the color data and brightness of the image are stored separately, which is conducive to quickly extracting the color data of the reference image and the standard background color data. Furthermore, the adaptive background color data of the reference image is determined based on the color data extracted in the color-brightness separation mode, avoiding interference from the brightness component and improving the accuracy of the adaptive background color data.

[0060] Exemplarily, the RGB color coding modes of the reference image and the standard background data are respectively converted into the YUV color coding mode, and the color data of the reference image and the standard background color data are respectively extracted in the YUV color coding mode.

[0061] The image processing method provided by the embodiment of the present disclosure obtains a reference image, determines the initial background area in the reference image based on the color data of the reference image and the standard background color data, and determines the adaptive background color data of the reference image based on the color data of the obtained initial background area, thereby obtaining background color data that is adaptive to the reference image and is more accurate.

[0062] refer to Figure 3 , Figure 3The following is a flow chart of the image processing method provided in the embodiment of the present disclosure. The method of this embodiment can be combined with the various optional schemes in the image processing method provided in the above embodiments. The image processing method provided in this embodiment is further refined. Optionally, the adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data includes: performing clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data; and determining the adaptive division threshold of the reference image based on the cluster center data.

[0063] like Figure 3 , the method of this embodiment includes:

[0064] S310 : Acquire a reference image, and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data.

[0065] S320 , performing clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data.

[0066] S330: Determine an adaptive division threshold of the reference image based on the cluster center data.

[0067] S340: Perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

[0068] In this embodiment, clustering processing can be performed based on the adaptive background color data and the color data of the reference image to determine cluster center data. The cluster center data refers to the class center value of each group of cluster data obtained by clustering processing, such as the center value (or mean) of a set of color data with similar or identical characteristics, and each cluster type can correspond to a cluster center data. Optionally, a two-clustering processing is performed based on the adaptive background color data and the color data of the reference image, and accordingly, two cluster center data are obtained. It can be understood that one of them is the cluster center data of the foreground, and the other is the cluster center data of the background, thereby realizing the division of the foreground and the background. The cluster center data can be obtained by clustering processing, and the clustering processing method can include but is not limited to K-Means clustering, Gaussian mixture model clustering, density-based clustering, etc., which are not limited here.

[0069] In some embodiments, clustering processing is performed based on the adaptive background color data and the color data of the reference image to determine cluster center data, including: determining the second distance information of the color data of each pixel point in the reference image from the adaptive background color data; and performing clustering processing with a cluster number of two based on the second distance information to obtain two cluster center data.

[0070] The second distance information may be spatial metric information of the color data of each pixel in the reference image and the adaptive background color data, for example, may be Euclidean distance, Mahalanobis distance, etc.

[0071] In this embodiment, the model used for clustering processing may be a Gaussian mixture model, and the second distance information may be a Euclidean distance. The second distance information satisfies a Gaussian distribution. Accordingly, clustering processing using the Gaussian mixture model facilitates improved clustering processing accuracy. For example, the color data of each pixel in the reference image is respectively determined to have a Euclidean distance with the adaptive background color data. The Gaussian mixture model is then used to perform clustering processing on the multiple Euclidean distances, with a cluster number of two, to obtain two cluster center data.

[0072] Furthermore, an adaptive division threshold for the reference image can be determined based on the cluster center data. Specifically, the mean of the two cluster center data can be determined as the adaptive division threshold for determining the reference image, or multiple intermediate values ​​of the two cluster center data can be determined as the adaptive division threshold for determining the reference image. This embodiment does not limit the method for determining the adaptive division threshold.

[0073] On the basis of the above embodiments, the determining of the adaptive division threshold of the reference image based on the cluster center data includes: determining an adaptive division threshold between two cluster center data based on a preset ratio value.

[0074] The preset ratio value may be a ratio value preset based on experience, such as 1:1, 1:2, etc., which is not limited thereto.

[0075] For example, when the preset ratio is 1:1, an adaptive partitioning threshold can be determined between the two cluster center data, i.e., the mean of the two cluster center data is determined as the adaptive partitioning threshold. When the preset ratio includes two ratios, such as 1:2 and 2:1, two adaptive partitioning thresholds can be determined between the two cluster center data, i.e., the two intermediate values ​​of the two cluster center data are determined as the adaptive partitioning threshold. Foreground extraction is performed on the reference image or an image associated with the reference image using the adaptive partitioning threshold.

[0076] The image processing method provided by the embodiment of the present disclosure performs clustering processing based on the adaptive background color data and the color data of the reference image to determine the cluster center data, thereby realizing cluster division of the foreground and background color data, that is, the cluster center data is representative and reliable. Furthermore, the adaptive division threshold of the reference image is determined based on the representative and reliable cluster center data, so that the obtained adaptive division threshold is more reliable.

[0077] refer to Figure 4 , Figure 4 The present invention provides a flowchart of an image processing method according to an embodiment of the present invention. The method according to this embodiment can be combined with the various optional schemes in the image processing method provided in the above embodiments. The image processing method provided in this embodiment is further refined. Optionally, the foreground extraction of the reference image and / or the background image identical to the reference image based on the adaptive division threshold comprises: for the image to be processed for foreground extraction, determining an image mask based on the color data of the image to be processed and the adaptive division threshold; and performing foreground extraction on the image to be processed based on the image mask.

[0078] like Figure 4 , the method of this embodiment includes:

[0079] S410 : Acquire a reference image, and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data.

[0080] S420: Determine an adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data.

[0081] S430 : For the image to be processed for foreground extraction, determine an image mask based on color data of the image to be processed and an adaptive division threshold.

[0082] S440: Perform foreground extraction on the image to be processed based on the image mask.

[0083] In this embodiment, the image to be processed refers to the image for which foreground extraction is to be performed, and may include, but is not limited to, a reference image and / or a background image identical to the reference image. An image mask may be an image that retains or blocks a region of interest in the image to be processed. The image mask can be used to perform foreground extraction on the image to be processed, i.e., by blocking the background and retaining the foreground, thereby achieving foreground extraction. The adaptive segmentation threshold may be obtained through real-time processing of the current reference image or retrieved from a preset storage location, without limitation herein.

[0084] In some embodiments, the image mask is the same size as the image to be processed, and the mask value corresponding to the foreground area in the image to be processed is 1, and the mask value corresponding to the background area is 0. The image after foreground extraction is obtained by multiplying the mask value in the image mask with the pixel points in the image to be processed. Exemplarily, the adaptive division threshold is a numerical value. If the color data of the pixel point in the image to be processed is greater than the adaptive division threshold, the mask data of the pixel point is determined to be 1; if the color data of the pixel point in the image to be processed is less than the adaptive division threshold, the mask data of the pixel point is determined to be 0. Furthermore, the image mask 1 value area is retained in the corresponding area of ​​the image to be processed, and the image mask 0 value area is shielded in the corresponding area of ​​the image to be processed to achieve foreground extraction.

[0085] On the basis of the above embodiments, the adaptive division threshold includes a foreground threshold and a background threshold, and the foreground threshold is greater than the background threshold; the image mask is determined based on the color data of the image to be processed and the adaptive division threshold, including: if the color data of the pixel point in the image to be processed is greater than the foreground threshold, the mask data of the pixel point is determined as the first data; if the color data of the pixel point in the image to be processed is less than the background threshold, the mask data of the pixel point is determined as the second data; if the color data of the pixel point in the image to be processed is greater than or equal to the background threshold and less than or equal to the foreground threshold, the mask data of the pixel point is determined as the pending data.

[0086] The adaptive segmentation threshold can be a color data threshold, i.e., both the foreground threshold and the background threshold are color data thresholds. The foreground threshold can be an adaptive threshold for determining the foreground, and the background threshold can be an adaptive threshold for determining the background. The foreground threshold can be greater than the background threshold. The first data and the second data are only used to distinguish the type of mask data and do not limit the data. For example, the first data can be 1 and the second data can be 0. The pending data refers to data to be determined, for example, it can be represented by a numerical value other than 0 and 1 or a character.

[0087] In some embodiments, the adaptive segmentation threshold may also be a distance data threshold, that is, the foreground threshold and the background threshold are respectively distance data thresholds. Accordingly, based on the Euclidean distance between each pixel and the adaptive background color data, the foreground threshold and the background threshold are respectively compared. If the Euclidean distance between the pixel in the image to be processed and the adaptive background color data is greater than the foreground threshold, the mask data of the pixel is determined to be 1; if the Euclidean distance between the pixel in the image to be processed and the adaptive background color data is less than the background threshold, the mask data of the pixel is determined to be 0; if the Euclidean distance between the pixel in the image to be processed and the adaptive background color data is greater than or equal to the background threshold and less than or equal to the foreground threshold, the mask data of the pixel is determined to be pending data.

[0088] Based on the above embodiments, after determining the image mask, the method further includes: performing one or more of the following processing on the undetermined area formed by the undetermined data in the image mask: erosion processing and blurring processing. Specifically, one or more of the processing of erosion processing and blurring processing is performed on the undetermined area formed by the position in the image mask where the mask value is the undetermined data.

[0089] Among them, the corrosion processing can be to corrode the area to be processed in the image mask, and the area to be processed can be the undetermined area in the above-mentioned image mask. There are many methods for corrosion processing, for example, the image mask is convolved with a preset corrosion template to obtain the minimum value of the pixel points in the area covered by the preset corrosion template, and the minimum value is replaced by the pixel value of the corresponding pixel point in the image mask, so that the image mask produces a corrosion effect. The blurring processing can be to blur the area to be processed in the image mask, and there are many methods for corrosion processing, for example, the average value of the pixels around each pixel point in the image mask is determined as the pixel value of the middle point, so that the image mask produces a blurred effect. The transition area between the foreground area and the background area is identified by corrosion processing and / or blurring processing to accurately obtain the boundary between the foreground area and the background area, thereby improving the accuracy of foreground extraction.

[0090] The image processing method provided by the embodiment of the present disclosure obtains accurate background color data by acquiring a reference image and determining the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data; further, the adaptive division threshold of the reference image is determined based on the color data of the reference image and the adaptive background color data, thereby realizing the adaptive acquisition of the division threshold and making the obtained adaptive division threshold more reliable; further, for the image to be processed for foreground extraction, an image mask is determined based on the color data of the image to be processed and the adaptive division threshold, wherein the image mask can accurately shield the background in the image to be processed, retain the foreground, and realize foreground extraction.

[0091] refer to Figure 5 , Figure 5 This is a flow chart of the image processing method provided in an embodiment of the present disclosure. This embodiment, based on the above embodiment, provides a preferred example to specifically illustrate the image processing method of the above embodiment. Optionally, the reference image is the first frame in a video, and the background image identical to the reference image is each frame in the video containing the reference image. Each frame in the video can be captured based on the same green screen background.

[0092] like Figure 5 , the method of this embodiment includes:

[0093] S510: Process the first frame of the video. Convert the first frame of the video from RGB format to YUV format, define the standard green RGB color as (R:0, G:255, B:0) (i.e., the color data of the standard background), convert it to YUV format, and calculate the L2 (Euclidean) distance between the YUV color value of each pixel in the first frame and the YUV color value of the standard green.

[0094] S520: A distance threshold of Euclidean distance is set. The Euclidean distance of each pixel is determined based on the distance threshold to obtain an initial background area. The average color value within the initial background area can be used as the accurate green screen background color (i.e., adaptive background color data). The L2 (Euclidean) distance between the YUV color value of each pixel in the current frame and the YUV color value of the accurate green screen background is calculated.

[0095] S530: Clustering is performed on the Euclidean distance obtained in S520 using a Gaussian Mixed Model (GMM), the number of clusters is specified to be 2, two cluster centers (foreground and background) are obtained, and the results of the cluster centers are stored.

[0096] The formula of the Gaussian mixture model is as follows:

[0097]

[0098] Where μ1 and μ2 are the center values ​​of the two Gaussian distributions, representing the distribution of the two sets of green screen (background) pixels and foreground pixels, respectively. ∑1 and ∑2 are the variances of the two Gaussian distributions, representing the degree of dispersion of the two Gaussian distributions, respectively. The foreground and background thresholds can be taken as the midpoint between the preset ratios of the two cluster centers μ1 and μ2 (the foreground threshold must be greater than the background threshold).

[0099] S540: Pixels with a Euclidean distance greater than or equal to the foreground threshold are considered foreground (value 1), pixels with a Euclidean distance less than or equal to the background threshold are considered background (value 0), and pixels with a Euclidean distance between the foreground and background thresholds are considered pending data (values ​​between 0 and 1). Finally, a matrix with the same size as the first frame is obtained as the image mask (pixels with a value of 1 are foreground, pixels with a value of 0 are background, and pixels with a value between 0 and 1 are considered pending data).

[0100] S550: performing post-processing such as corrosion and blurring on the preliminary result obtained in S540.

[0101] S560: Subsequent frames (except the first frame image) use the foreground threshold and background threshold obtained in S530, repeat S540 and S550 to obtain the image mask of the entire video sequence frame by frame, and perform foreground extraction on the image to be processed based on the image mask to obtain the foreground extraction result.

[0102] Compared with traditional algorithms, the image processing method proposed in this embodiment can effectively protect the foreground image from being mistakenly removed when processing video sequences with green components in the foreground; and can more thoroughly remove the green screen background when processing video sequences with uneven green screen color and uneven lighting.

[0103] Figure 6 FIG. 1 is a structural diagram of an image processing device provided by an embodiment of the present disclosure. Figure 6 As shown, the device includes:

[0104] The color data determination module 610 is used to obtain a reference image and determine the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data; the image threshold determination module 620 is used to determine the adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data; the foreground extraction module 630 is used to perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

[0105] In some optional implementations of the embodiments of the present disclosure, the color data determination module 610 includes:

[0106] a background region determining unit, configured to determine an initial background region in the reference image based on the color data of the reference image and standard background color data;

[0107] The background color determining unit is configured to determine the adaptive background color data of the reference image based on the color data of the initial background area.

[0108] In some optional implementations of the embodiments of the present disclosure, the background area determination unit may further be configured to:

[0109] Determine first distance information between the color data of each pixel in the reference image and the standard background color data;

[0110] An initial background area in the reference image is determined based on the first distance information and a distance threshold.

[0111] In some optional implementations of the embodiments of the present disclosure, the background color determination unit may also be configured to:

[0112] The average value of the color data in the initial background area is determined as the adaptive background color data of the reference image.

[0113] In some optional implementations of the embodiments of the present disclosure, the apparatus may also be used to:

[0114] The color coding modes of the reference image and the standard background data are respectively converted into color-brightness separation modes, and the color data of the reference image and the standard background color data are respectively extracted in the color-brightness separation mode.

[0115] In some optional implementations of the embodiments of the present disclosure, the image threshold determination module 620 includes:

[0116] a center data determining unit, configured to perform clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data;

[0117] A segmentation threshold determination unit is used to determine an adaptive segmentation threshold of the reference image based on the cluster center data.

[0118] In some optional implementations of the embodiments of the present disclosure, the central data determination unit may also be configured to:

[0119] Determine second distance information between the color data of each pixel in the reference image and the adaptive background color data;

[0120] A clustering process with a cluster number of two is performed based on the second distance information to obtain two cluster center data.

[0121] In some optional implementations of the embodiments of the present disclosure, the segmentation threshold determination unit may also be configured to:

[0122] Based on a preset ratio value, an adaptive partition threshold is determined between two cluster center data.

[0123] In some optional implementations of the embodiments of the present disclosure, the foreground extraction module 630 includes:

[0124] An image mask determination unit, configured to determine an image mask for an image to be processed for foreground extraction based on color data of the image to be processed and an adaptive segmentation threshold;

[0125] The foreground extraction unit is used to extract the foreground of the image to be processed based on the image mask.

[0126] In some optional implementations of the embodiments of the present disclosure, the adaptive segmentation threshold includes a foreground threshold and a background threshold, and the foreground threshold is greater than the background threshold; and the image mask determination unit is further configured to:

[0127] If the color data of the pixel in the image to be processed is greater than the foreground threshold, determining the mask data of the pixel as the first data;

[0128] If the color data of the pixel in the image to be processed is less than the background threshold, determining the mask data of the pixel as the second data;

[0129] If the color data of a pixel in the to-be-processed image is greater than or equal to the background threshold and less than or equal to the foreground threshold, the mask data of the pixel is determined as pending data.

[0130] In some optional implementations of the embodiments of the present disclosure, the apparatus is further configured to:

[0131] The undetermined area formed by the undetermined data in the image mask is subjected to one or more of the following processings: corrosion processing and blurring processing.

[0132] In some optional implementations of the embodiments of the present disclosure, the reference image is the first frame image in the video, and the same background image as the reference image is each video frame in the video where the reference image is located.

[0133] The image processing device provided by the embodiments of the present disclosure can execute the image processing method provided by any embodiment of the present disclosure, and has corresponding functional modules and beneficial effects for executing the image processing method.

[0134] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.

[0135] Reference below Figure 7 , which shows an electronic device (eg Figure 7 The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.

[0136] like Figure 7As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. Various programs and data required for the operation of the electronic device 400 are also stored in the RAM 403. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0137] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.

[0138] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0139] The electronic device provided by the embodiment of the present disclosure and the image processing method provided by the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0140] An embodiment of the present disclosure provides a computer storage medium having a computer program stored thereon. When the program is executed by a processor, the image processing method provided by the above embodiment is implemented.

[0141] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0142] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0143] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0144] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0145] Acquire a reference image, and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data;

[0146] determining an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data;

[0147] Foreground extraction is performed on the reference image and / or the background image identical to the reference image based on the adaptive segmentation threshold.

[0148] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0149] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0150] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit / module does not, in some cases, limit the unit itself.

[0151] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0152] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0153] According to one or more embodiments of the present disclosure, [Example 1] provides an image processing method, the method comprising:

[0154] Acquire a reference image, and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data;

[0155] determining an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data;

[0156] Foreground extraction is performed on the reference image and / or the background image identical to the reference image based on the adaptive segmentation threshold.

[0157] According to one or more embodiments of the present disclosure, [Example 2] provides an image processing method, further comprising:

[0158] The step of determining the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data includes:

[0159] determining an initial background area in the reference image based on the color data of the reference image and the standard background color data;

[0160] Adaptive background color data of the reference image is determined based on color data of the initial background area.

[0161] According to one or more embodiments of the present disclosure, [Example 3] provides an image processing method, further comprising:

[0162] The determining of the initial background area in the reference image based on the color data of the reference image and the standard background color data includes:

[0163] Determine first distance information between the color data of each pixel in the reference image and the standard background color data;

[0164] An initial background area in the reference image is determined based on the first distance information and a distance threshold.

[0165] According to one or more embodiments of the present disclosure, [Example 4] provides an image processing method, further comprising:

[0166] The determining of the adaptive background color data of the reference image based on the color data of the initial background area includes:

[0167] The average value of the color data in the initial background area is determined as the adaptive background color data of the reference image.

[0168] According to one or more embodiments of the present disclosure, [Example 5] provides an image processing method, further comprising:

[0169] Before determining the adaptive background color data of the reference image based on the color data of the reference image and the standard background color data, the method further includes:

[0170] The color coding modes of the reference image and the standard background data are respectively converted into color-brightness separation modes, and the color data of the reference image and the standard background color data are respectively extracted in the color-brightness separation mode.

[0171] According to one or more embodiments of the present disclosure, [Example 6] provides an image processing method, further comprising:

[0172] The step of determining the adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data includes:

[0173] Performing clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data;

[0174] An adaptive segmentation threshold of the reference image is determined based on the cluster center data.

[0175] According to one or more embodiments of the present disclosure, [Example 7] provides an image processing method, further comprising:

[0176] The performing clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data includes:

[0177] Determine second distance information between the color data of each pixel in the reference image and the adaptive background color data;

[0178] A clustering process with a cluster number of two is performed based on the second distance information to obtain two cluster center data.

[0179] According to one or more embodiments of the present disclosure, [Example 8] provides an image processing method, further comprising:

[0180] The step of determining the adaptive division threshold of the reference image based on the cluster center data includes:

[0181] Based on a preset ratio value, an adaptive partition threshold is determined between two cluster center data.

[0182] According to one or more embodiments of the present disclosure, [Example 9] provides an image processing method, further comprising:

[0183] The performing foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold comprises:

[0184] For an image to be processed for foreground extraction, determining an image mask based on color data of the image to be processed and an adaptive segmentation threshold;

[0185] Perform foreground extraction on the image to be processed based on the image mask.

[0186] According to one or more embodiments of the present disclosure, [Example 10] provides an image processing method, further comprising:

[0187] The adaptive segmentation threshold includes a foreground threshold and a background threshold, and the foreground threshold is greater than the background threshold;

[0188] The determining of the image mask based on the color data of the image to be processed and the adaptive division threshold comprises:

[0189] If the color data of the pixel in the image to be processed is greater than the foreground threshold, determining the mask data of the pixel as the first data;

[0190] If the color data of the pixel in the image to be processed is less than the background threshold, determining the mask data of the pixel as the second data;

[0191] If the color data of a pixel in the to-be-processed image is greater than or equal to the background threshold and less than or equal to the foreground threshold, the mask data of the pixel is determined as pending data.

[0192] According to one or more embodiments of the present disclosure, [Example 11] provides an image processing method, further comprising:

[0193] After determining the image mask, the method further includes:

[0194] The undetermined area formed by the undetermined data in the image mask is subjected to one or more of the following processings: corrosion processing and blurring processing.

[0195] According to one or more embodiments of the present disclosure, [Example 12] provides an image processing method, further comprising:

[0196] The reference image is the first frame image in the video, and the same background image as the reference image is each video frame in the video where the reference image is located.

[0197] According to one or more embodiments of the present disclosure, [Example 13] provides an image processing device, the device including:

[0198] A color data determination module, configured to obtain a reference image and determine adaptive background color data of the reference image based on color data of the reference image and standard background color data;

[0199] an image threshold determination module, configured to determine an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data;

[0200] A foreground extraction module is configured to perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

[0201] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0202] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0203] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.

Claims

1. An image processing method, characterized in that: include: Acquire a reference image, and determine an initial background area in the reference image based on color data of the reference image and standard background color data; determining adaptive background color data of the reference image based on color data of the initial background area; determining an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data; Foreground extraction is performed on the reference image and / or the background image identical to the reference image based on the adaptive segmentation threshold.

2. The method according to claim 1, characterized in that The determining of the initial background area in the reference image based on the color data of the reference image and the standard background color data includes: Determine first distance information between the color data of each pixel in the reference image and the standard background color data; An initial background area in the reference image is determined based on the first distance information and a distance threshold.

3. The method according to claim 1, characterized in that The determining of the adaptive background color data of the reference image based on the color data of the initial background area includes: The average value of the color data in the initial background area is determined as the adaptive background color data of the reference image.

4. The method according to claim 1, wherein Before determining the initial background area in the reference image based on the color data of the reference image and the standard background color data, the method further includes: The color coding modes of the reference image and the standard background data are respectively converted into color-brightness separation modes, and the color data of the reference image and the standard background color data are respectively extracted in the color-brightness separation mode.

5. The method according to claim 1, wherein The step of determining the adaptive division threshold of the reference image based on the color data of the reference image and the adaptive background color data includes: Performing clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data; An adaptive segmentation threshold of the reference image is determined based on the cluster center data.

6. The method according to claim 5, characterized in that The performing clustering processing based on the adaptive background color data and the color data of the reference image to determine cluster center data includes: Determine second distance information between the color data of each pixel in the reference image and the adaptive background color data; A clustering process with a cluster number of two is performed based on the second distance information to obtain two cluster center data.

7. The method according to claim 5, characterized in that The step of determining the adaptive division threshold of the reference image based on the cluster center data includes: Based on a preset ratio value, an adaptive partition threshold is determined between two cluster center data.

8. The method according to claim 1, characterized in that The performing foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold comprises: For an image to be processed for foreground extraction, determining an image mask based on color data of the image to be processed and an adaptive segmentation threshold; Performing foreground extraction on the image to be processed based on the image mask.

9. The method according to claim 8, characterized in that The adaptive segmentation threshold includes a foreground threshold and a background threshold, and the foreground threshold is greater than the background threshold; The determining of the image mask based on the color data of the image to be processed and the adaptive division threshold comprises: If the color data of the pixel in the image to be processed is greater than the foreground threshold, determining the mask data of the pixel as the first data; If the color data of the pixel in the image to be processed is less than the background threshold, determining the mask data of the pixel as the second data; If the color data of a pixel in the to-be-processed image is greater than or equal to the background threshold and less than or equal to the foreground threshold, the mask data of the pixel is determined as pending data.

10. The method according to claim 9, characterized in that After determining the image mask, the method further includes: The undetermined area formed by the undetermined data in the image mask is subjected to one or more of the following processings: corrosion processing and blurring processing.

11. The method according to claim 1, wherein The reference image is the first frame image in the video, and the same background image as the reference image is each video frame in the video where the reference image is located.

12. An image processing device, characterized in that: include: A color data determination module, configured to obtain a reference image and determine an initial background area in the reference image based on the color data of the reference image and standard background color data; determining adaptive background color data of the reference image based on color data of the initial background area; an image threshold determination module, configured to determine an adaptive segmentation threshold of the reference image based on the color data of the reference image and the adaptive background color data; A foreground extraction module is configured to perform foreground extraction on the reference image and / or the background image identical to the reference image based on the adaptive division threshold.

13. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method according to any one of claims 1 to 11.

14. A storage medium comprising computer-executable instructions, wherein the computer-executable instructions are used to perform the image processing method according to any one of claims 1 to 11 when executed by a computer processor.

Citation Information

Patent Citations

  • Blue screen image-matting method

    CN104200470A

  • Image processing method and device

    CN113034509A