A background removing method based on color channel operation
By utilizing the R, G, and B channel values of a color image and employing long component and relative long component features for masking operations, the process is simplified into relational operations. This solves the problem of high computational complexity in existing technologies, achieving an efficient background removal method and improving the user experience.
Patent Information
- Application Number
- CN202211211327.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-09-30
AI Technical Summary
Existing real-time image recognition methods for background removal are computationally complex and fail to effectively utilize the features of color images, resulting in a poor user experience.
By acquiring the R, G, and B channel values of a color image, mask operations are performed using long component and relative long component features, simplifying the operation to a relational operation and avoiding complex square and square root operations, thus directly obtaining the foreground.
It significantly reduces the computational complexity of background removal and improves the user experience, especially in real-time image recognition scenarios, thereby increasing work efficiency and user experience.
Smart Images

Figure CN115512112B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer vision and image processing, and in particular to a background removal method based on color channel operation. BACKGROUND
[0002] The calculation complexity of the background removal method in real-time image recognition is directly related to the user experience. In recent years, the academic community has proposed many background removal methods, such as the threshold based image segmentation method, the edge based image segmentation method, the fuzzy theory method, etc. These methods all try to define a pixel classification method to separate the foreground pixels from the background pixels. Abstractly, the input of the existing background removal scheme is generally a grayscale image, and a color image is first converted into a grayscale image, which discards the features of the image represented by color, which is not conducive to improving the accuracy and accuracy of the background removal. And the existing methods all use the gray value quantity relationship between pixels to construct a separation method, for example, calculating the gradient to obtain the edge, calculating the membership degree, etc. These calculation methods involve multiple rounds of square and square root operations, which is not conducive to improving the operation speed and user experience. In addition, the existing methods do not use the characteristics of the image in a specific application scenario, and the calculation time is long and the calculation complexity is high. SUMMARY
[0003] The present application provides a background removal method based on color channel operation to overcome the above technical problems.
[0004] In order to achieve the above purpose, the technical scheme of the present application is:
[0005] A background removal method based on color channel operation, comprising the following steps:
[0006] S1: obtaining a sample set of a picture to be processed; and selecting one picture from the sample set as an original picture P;
[0007] S2: obtaining R channel value r, G channel value g and B channel value b from the original picture P;
[0008] S3: judging whether there is a mask picture of the original picture P according to the R channel value r, the G channel value g and the B channel value b; if there is, obtaining the mask picture of the original picture P, and executing S4, otherwise executing S6;
[0009] S4: obtaining an ideal mask picture of the original picture P according to the mask picture of the original picture P;
[0010] S5: Perform a mask operation between the ideal mask image of the original image P and the original image P to obtain the foreground of the original image P; execute S6;
[0011] S6: Remove the background from the original image P to finish.
[0012] Furthermore, in step S3, the method for determining whether a mask image of the original image P exists is as follows:
[0013] S31: Obtain the long component image of the original image P, including the R long component image, the G long component image and the B long component image;
[0014] S32: Determine whether the long component image of the original image P is a long component separable image. If the long component image of the original image P is a long component separable image, then there exists a mask image of the original image P, and the long component separable image is the mask image of the original image P; otherwise, execute S33.
[0015] S33: Obtain the relative long component image of the original image P;
[0016] S34: Determine whether the relative long component image of the original image P is a relatively long component separable image; if the relative long component image of the original image P is a relatively long component separable image, then there exists a mask image of the original image P, and the relatively long component separable image is the mask image of the original image P; if not, then there is no mask image of the original image P.
[0017] Furthermore, in step S31, the long component image of the original image P is obtained as follows:
[0018] Let the original graph P = [C x,y |C x,y = (r, g, b)], where C x,y If it is a pixel of the original image P; then
[0019]
[0020]
[0021]
[0022] In the formula, DCP R Represents the R-length component map; DCP G Represents the G-length component of the original image P; DCP B Represents the B-length component of the original image P; C x,y is the pixel value of the original image P; x is the x-coordinate of the pixel; y is the y-coordinate of the pixel; r is the R channel value; g is the G channel value; b is the B channel value.
[0023] Furthermore, in S32, the method for determining whether the long component image of the original image P is a long component separable image is as follows:
[0024] like
[0025]
[0026] If true, then the long component of the original image P is a long component separable image of R.
[0027] like
[0028]
[0029] If true, then the long component of the original graph P is a long component separable graph of G.
[0030] like
[0031]
[0032] If true, then the long component of the original image P is a long component separable image of B.
[0033] In the formula, ∧ is the conjunction operator; ∈ is the membership operator for a set. O is the implication operator; O is the foreground of the original image P; B is the foreground and background of the original image P.
[0034] Furthermore, in step S33, the relative length component image of the original image P is obtained as follows:
[0035] The relative length component of the original image P includes the R-G relative length component, the R-B relative length component, the G-R relative length component, the G-B relative length component, the B-R relative length component, and the B-G relative length component.
[0036] The relative length component image of G to B is obtained as follows:
[0037]
[0038] The relative length component image of G to R is obtained as follows:
[0039]
[0040] The relative length component diagram of R to B is obtained as follows:
[0041]
[0042] The relative length component diagram of R to G is obtained as follows:
[0043]
[0044] The B-R relative length component image is obtained as follows:
[0045]
[0046] The relative length component image of B to G is obtained as follows:
[0047]
[0048] Furthermore, in S34, the method for determining whether the relatively long component of the original image P is a relatively long component separable image is as follows:
[0049] like
[0050]
[0051] If true, then the original image P is a relatively long component image, specifically an R-to-G relatively long component image; in this case, the R-to-G relatively long component image RDCP R∝G This is a mask image of the original image P;
[0052] like
[0053]
[0054] If true, then the original image P is a relatively long component image, specifically an R-to-B relatively long component image; in this case, the R-to-B relatively long component image RDCP... R∝B This is a mask image of the original image P;
[0055] like
[0056]
[0057] If true, then the original image P is a relatively long component image, which is the G-R relatively long component image; at this time, the G-R relatively long component image RDCP G∝R This is a mask image of the original image P;
[0058] like
[0059]
[0060] If true, then the original image P is a relatively long component image, specifically a G-to-B relatively long component image; in this case, the G-to-B relatively long component image RDCP... G∝B This is a mask image of the original image P;
[0061] like
[0062]
[0063] If true, then the original image P is a relatively long component image, specifically a B-to-G relatively long component image; in this case, the B-to-G relatively long component image RDCP... B∝G This is a mask image of the original image P;
[0064] like
[0065]
[0066] If true, then the original image P is a relatively long component image, specifically a B-to-R relatively long component image; in this case, the B-to-R relatively long component image RDCP B∝R This is the mask image of the original image P.
[0067] Beneficial effects: The background removal method based on color channel operations of the present invention utilizes the R channel value r, G channel value g, and B channel value b obtained from the original color image P, and makes full use of the image features, long component or relatively long component features, to obtain the foreground of the original image P, which greatly reduces the computational complexity of background removal and can effectively improve the user experience. Attached Figure Description
[0068] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0069] Figure 1 This is a flowchart of the background removal method of the present invention;
[0070] Figure 2 This is a schematic diagram of the R-length component color space in an embodiment of the present invention;
[0071] Figure 3 This is a schematic diagram of the B-component color space in an embodiment of the present invention;
[0072] Figure 4 This is a schematic diagram of the G-length component color space in an embodiment of the present invention;
[0073] Figure 5 This is a comparison chart of the computational efficiency of the basic arithmetic units in the embodiments of the present invention;
[0074] Figure 6 These are comparison images of background removal examples in embodiments of the present invention;
[0075] Figure 7 This is a percentage graph showing the channel computation time versus distance domain computation time in an embodiment of the present invention.
[0076] Figure 8 This is a flowchart illustrating background removal in an embodiment of the present invention. Detailed Implementation
[0077] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0078] Color channel-based algorithms utilize the relationships or arithmetic operations between channels to remove backgrounds. This is a highly flexible processing method in terms of precision control and does not require specifying a target color or sample color.
[0079] This embodiment provides a background removal method based on color channel operations, such as... Figure 1 and Figure 8 As shown, it includes the following steps:
[0080] S1: Obtain a sample set of images to be processed; and select one image from it as the original image P;
[0081] Specifically, in this embodiment, a sample set of images to be processed is formed by random sampling or continuous sampling.
[0082] S2: Obtain the R channel value r, G channel value g, and B channel value b (including foreground and background) from the original image P;
[0083] S3: Based on the R channel value r, G channel value g, and B channel value b, determine whether there is a mask image of the original image P; if there is, obtain the mask image of the original image P and execute S4; otherwise, the background removal method based on color channel operation of the present invention cannot be used and execute S6.
[0084] Specifically, the method for channel operations is determined based on the foreground and background colors of the original image P;
[0085] S4: Obtain the ideal mask image of the original image P based on the mask image of the original image P;
[0086] Specifically, since the mask image of the original image P is a foreground mask with point noise, the noise of the foreground mask is removed by erosion and dilation operations to obtain an ideal mask. Erosion and dilation operations are common methods in image processing and will not be elaborated upon here.
[0087] S5: Perform a mask operation between the ideal mask image of the original image P and the original image P to obtain the foreground of the original image P; execute S6.
[0088] Specifically, in this embodiment, the foreground of the original image P is obtained by performing a logical AND operation between the ideal mask image of the original image P and the original image P.
[0089] S6: Remove the background from the original image P to finish.
[0090] Preferably, in step S3, the method for obtaining the mask image of the original image P is as follows:
[0091] S31: Obtain the long component images of the original image P, including the R long component image, the G long component image, and the B long component image; such as Figures 2-4 As shown;
[0092] Let the original graph P = [C x,y |C x,y = (r, g, b)], where C x,y It refers to a pixel; according to equation (1)
[0093]
[0094]
[0095]
[0096] In the formula, DCP represents the Dominant Component Picture (DCP); DCP R Represents the R-length component map; DCP G Represents the G-length component of the original image P; DCP B Represents the B-component image; C x,y y is the color of the pixel; x is the x-coordinate of the pixel; y is the y-coordinate of the pixel; r is the R channel value; g is the G channel value; b is the B channel value;
[0097] S32: Determine whether the long component image of the original image P is a long component separable image. If the long component image of the original image P is a long component separable image, then there exists a mask image of the original image P, and the long component separable image is the mask image of the original image P; otherwise, execute S33.
[0098] In step S32, the method for determining whether the long component of the original image P is a long component separable image is as follows:
[0099] like
[0100]
[0101] If true, then the long component of the original graph P is a long component separable graph of R; at this time, the long component graph of R is DCP. R This is the mask image of the original image P; DCP is used here. R Remove background;
[0102] The meaning expressed by formula (4) is as follows: For all pixel points C of the original image P x,y the following judgment is made. If the pixel C x,y is on the foreground, then the relationship r > g and r > b holds. If the pixel is not on the foreground, that is, on the background, then the relationship r < g or r < b holds. Thus, it can be judged whether it is an R long-component separable graph.
[0103] If
[0104]
[0105] is true, then the long-component graph of the original image P is a G long-component separable graph; at this time, the G long-component graph DCP G is the mask graph of the original image P; at this time, use DCP G to remove the background;
[0106] If
[0107]
[0108] is true, then the long-component graph of the original image P is a B long-component separable graph; at this time, the B long-component graph DCP B is the mask graph of the original image P; at this time, use DCP B to remove the background;
[0109] In the formula, is any element in the existing set; ∧ is the conjunction operator; ∈ is the belonging operator of the set; is the implication operator; O is the foreground of the original image P; B is the front background of the original image P;
[0110] In an embodiment of the present invention, as shown in the appendix Figure 6 the picture with the foreground being a hand is an R long-component separable graph. The reason is that the pixels on the hand satisfy r > g and r > b, while the pixels in other positions satisfy r < g or r < b. In order to Figure 6 remove the background to obtain a picture with only the foreground (hand), that is, retain the pixels of the foreground (hand) and set other pixels to black (RGB decimal value is 000). As long as all pixels are judged for r > g and r > b, the true points are retained and the false points are set to black. It can be seen that in this background removal process, a simple relational operation is used, avoiding the distance domain method using square sum and square root operations. Therefore, the speed is fast and the user experience is good in real-time application scenarios.
[0111] S33: Obtain the relative dominant component picture (RDCP) of the original image P respectively; the relative dominant component picture of the original image P includes the R-to-G relative dominant component picture; the R-to-B relative dominant component picture; the G-to-R relative dominant component picture; the G-to-B relative dominant component picture; the B-to-R relative dominant component picture; and the B-to-G relative dominant component picture.
[0112] The relative length component image of G to B is obtained as follows:
[0113]
[0114] The relative length component image of G to R is obtained as follows:
[0115]
[0116] The relative length component diagram of R to B is obtained as follows:
[0117]
[0118] The relative length component diagram of R to G is obtained as follows:
[0119]
[0120] The B-R relative length component image is obtained as follows:
[0121]
[0122] The relative length component image of B to G is obtained as follows:
[0123]
[0124] S34: Determine whether the relative long component image of the original image P is a relatively long component separable image; if the relative long component image of the original image P is a relatively long component separable image, then there exists a mask image of the original image P, and the relatively long component separable image is the mask image of the original image P; if not, then there is no mask image of the original image P.
[0125] In step S34, the method for determining whether the relatively long component of the original image P is a relatively long component separable image is as follows:
[0126] like
[0127]
[0128] If true, then the relative length component of the original image P is the R-to-G relative length component; at this time, the R-to-G relative length component RDCP R∝G This is a mask image of the original image P; RDCP is used in this case. R∝G Remove background;
[0129] Specifically, the meaning expressed by Equation (12) is as follows: For all pixel points C of the original image P x,y make the following judgment. If pixel point C x,y is on the foreground, then the relationship r > g holds. That is to say, if the pixel point r > g, then pixel point C x,y is on the foreground; if the pixel is not on the foreground, that is, on the background, then the relationship r < g holds. Thus, it can be determined whether it is an R-to-G relatively long component separable graph.
[0130] In this type of application example, in order to remove the background and obtain an image with only the foreground, that is, retain the pixels of the foreground and set other pixels to black (its RGB decimal value is 000), just make a judgment of r > g for all pixels, retain the points that are true, and set the points that are false to black. Similarly, it can be seen that in this background removal process, a relational operation with simple calculation is used, completely avoiding the use of square sum and square root operations. Therefore, the computational complexity is low and the speed is fast, which is beneficial to ensuring the user experience in real-time application scenarios.
[0131] If
[0132]
[0133] is true, then the relatively long component graph of the original image P is the R-to-B relatively long component graph; at this time, the R-to-B relatively long component graph RDCP R∝B is the mask graph of the original image P; at this time, use RDCP R∝B to remove the background;
[0134] If
[0135]
[0136] is true, then the relatively long component graph of the original image P is the G-to-R relatively long component graph; at this time, the G-to-R relatively long component graph RDCP G∝R is the mask graph of the original image P; at this time, use RDCP G∝R to remove the background;
[0137] If
[0138]
[0139] is true, then the relatively long component graph of the original image P is the G-to-B relatively long component graph; at this time, the G-to-B relatively long component graph RDCP G∝B is the mask graph of the original image P; at this time, use RDCP G∝B to remove the background;
[0140] If
[0141]
[0142] If true, then the relative long component of the original image P is the B-to-G relative long component; at this time, the B-to-G relative long component RDCP B∝G This is a mask image of the original image P; RDCP is used in this case. B∝G Remove background;
[0143] like
[0144]
[0145] If true, then the relative length component of the original image P is the B-R relative length component; at this time, the B-R relative length component RDCP B∝R This is a mask image of the original image P; RDCP is used in this case. B∝R Remove the background.
[0146] In the background removal method based on color channel operations, after the background removal operation on the original image P, the following steps are also included: repeating S2 to S5 to obtain the foreground of all samples in the sample set of the image to be processed. In this process, the parameters of intermediate processes such as erosion and dilation can be optimized, so that when obtaining the ideal mask of the original image P, the obtained parameters of erosion and dilation operations can be used to further improve the speed of obtaining the ideal mask of the original image P.
[0147] An embodiment of the present invention is as follows:
[0148] The color channel scheme was evaluated using the following test platform parameters: Core™ i7-9700K CPU, dual-core, both with a clock speed of 3.6GHz.
[0149] Development environment used: Visual Studio 2017 Community
[0150] Development language used: C++
[0151] Relevant libraries used: OpenCV 4.5.3
[0152] Ease of use comparison:
[0153] Table 1 shows a comparison of the ease of use between the background removal method based on color channel operations and the traditional distance domain method in this example:
[0154] Table 1. Comparison of ease of use
[0155] Item Channel operation method Distance domain method Difficulty of foreground color specification Simple Complex Applicable scenario Specific scenario Universal Computational form and computational complexity Relational operator / low Square sum square root / high
[0156] In this embodiment, the foreground selection is based on the color channel. Compared to the distance domain method, this method is much simpler to specify the foreground when the original image P has both long component images and relatively long component images. The calculation method is also simpler.
[0157] The background removal method based on color channel operations in this embodiment uses relational operations as its basic computational unit, while the basic computational unit of the distance domain method is the spatial distance formula, such as... Figure 5 As shown, since the two methods are based on different computational methods, the average value is taken after performing multiple operations on images of different resolutions. The data in the figure represents the time taken for 10 basic operations. From Figure 5 It can be seen that the relational operations using the color channel-based background removal method are faster than the spatial distance operations used by the distance domain method, showing a clear advantage.
[0158] Table 2 compares the performance and time complexity of the traditional distance domain method and the channel algorithm in background removal. In terms of performance, the channel algorithm and the distance domain method are comparable. However, their time complexities differ significantly.
[0159] Table 2. Comparison of specific parameters for background instance removal
[0160]
[0161] To verify the time efficiency of the channel operation algorithm, the method in this embodiment was used. The 120 long component images and relatively long component images were grouped by resolution. The distribution of the mean time complexity is as follows: Figure 7 As shown. By Figure 7 It can be seen that at all resolutions, the time consumed by channel operations is less than 4.6% of that consumed by distance domain operations. When applied to real-time image recognition scenarios, it can effectively improve work efficiency and significantly enhance the user experience.
[0162] Beneficial effects: The method of color channel operation in this invention reflects the features of an image by the quantitative relationship between color channels. It filters the color space by using the long component and relative long component features of the color channels. On the one hand, it is easier to specify the target color, without the need for quantitative sampling like the distance method. On the other hand, the use of relational operations in this invention greatly reduces the computational complexity. When applied to real-time image recognition scenarios, it can effectively improve the user experience.
[0163] This paper proposes a background removal method based on color channel operations. It utilizes the quantitative relationships (i.e., the relationships between the three color components of a pixel) within the pixels of a color image (RGB color mode) to construct a foreground and background separation scheme. This method fully leverages image features, specifically long or relatively long component features, and employs simple relational operators to achieve background removal, significantly improving computational complexity. It demonstrates a clear advantage in background removal when the background or foreground is composed of similar colors, effectively optimizing the time complexity of the background removal method. In emerging application scenarios such as industrial control, medical services, and facial recognition, where there are extreme demands for real-time response, minimal errors, and a good user experience, this color channel operation-based method can overcome the limitations of current sensing technologies and meet the requirements of large amounts of real-time data in these scenarios. It fulfills the market demand for "intelligent and high-performance" applications.
[0164] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A background removal method based on color channel operations, characterized in that, include: Includes the following steps: S1: Obtain a sample set of images to be processed; And select one image from them as the original image P; S2: Obtain the R channel value r, G channel value g, and B channel value b from the original image P respectively; S3: Based on the R channel value r, G channel value g, and B channel value b, determine whether there is a mask image of the original image P; If it exists, obtain the mask image of the original image P and execute S4; otherwise, execute S6. In step S3, the method for determining whether a mask image of the original image P exists is as follows: S31: Obtain the long component image of the original image P, including the R long component image, the G long component image and the B long component image; In step S31, the long component image of the original image P is obtained as follows: Let the original graph P = [C x,y |C x,y = (r, g, b)], where C x,y If it is a pixel of the original image P; then In the formula, DCP R Represents the R-length component map; DCP G Represents the G-length component of the original image P; DCP B Represents the B-length component of the original image P; C x,y 1 represents the pixel value of the original image P; x is the x-coordinate of the pixel; y is the y-coordinate of the pixel; r is the R channel value; g is the G channel value; b is the B channel value; S32: Determine whether the long component image of the original image P is a long component separable image. If the long component image of the original image P is a long component separable image, then there exists a mask image of the original image P, and the long component separable image is the mask image of the original image P; otherwise, execute S33. In step S32, the method for determining whether the long component of the original image P is a long component separable image is as follows: like If true, then the long component of the original image P is a long component separable image of R. like If true, then the long component of the original graph P is a long component separable graph of G. like If true, then the long component of the original image P is a long component separable image of B. In the formula, ∧ is the conjunction operator; ∈ is the membership operator for a set. O represents the implication operator; O represents the foreground of the original image P; B represents the foreground and background of the original image P. S33: Obtain the relative long component image of the original image P; In step S33, the relative length component image of the original image P is obtained as follows: The relative length component of the original image P includes the R-G relative length component, the R-B relative length component, the G-R relative length component, the G-B relative length component, the B-R relative length component, and the B-G relative length component. The relative length component image of G to B is obtained as follows: The relative length component image of G to R is obtained as follows: The relative length component diagram of R to B is obtained as follows: The relative length component diagram of R to G is obtained as follows: The B-R relative length component image is obtained as follows: The relative length component image of B to G is obtained as follows: S34: Determine whether the relative long component image of the original image P is a relatively long component separable image; if the relative long component image of the original image P is a relatively long component separable image, then there exists a mask image of the original image P, and the relatively long component separable image is the mask image of the original image P; otherwise, there does not exist a mask image of the original image P. S4: Based on the mask image of the original image P, obtain the ideal mask image of the original image P; S5: Perform a mask operation between the ideal mask image of the original image P and the original image P to obtain the foreground of the original image P; execute S6; S6: Remove the background from the original image P to finish.
2. The background removal method based on color channel operations according to claim 1, characterized in that, In step S34, the method for determining whether the relatively long component of the original image P is a relatively long component separable image is as follows: like If true, then the original image P is a relatively long component image, specifically an R-to-G relatively long component image; in this case, the R-to-G relatively long component image RDCP R∝G This is a mask image of the original image P; like If true, then the original image P is a relatively long component image, specifically an R-to-B relatively long component image; in this case, the R-to-B relatively long component image RDCP... R∝B This is a mask image of the original image P; like If true, then the original image P is a relatively long component image, which is the G-R relatively long component image; at this time, the G-R relatively long component image RDCP G∝R This is a mask image of the original image P; like If true, then the original image P is a relatively long component image, specifically a G-to-B relatively long component image; in this case, the G-to-B relatively long component image RDCP... G∝B This is a mask image of the original image P; like If true, then the original image P is a relatively long component image, specifically a B-to-G relatively long component image; in this case, the B-to-G relatively long component image RDCP... B∝G This is a mask image of the original image P; like If true, then the original image P is a relatively long component image, specifically a B-to-R relatively long component image; in this case, the B-to-R relatively long component image RDCP B∝R This is the mask image of the original image P.
Citation Information
Patent Citations
Target candidate region extraction method based on image background mask
CN108648197A
Improved local binarization method
CN112215781A