A chroma keying method, system, terminal and storage medium for suppressing a background color in a chroma keying
By calculating the chroma angle and saturation and performing outward interpolation to adjust the chroma angle, the problem of screen color overflow in chroma keying is solved and color deviation is improved.
Patent Information
- Application Number
- CN202310559696.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-17
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2043-05-17
AI Technical Summary
Existing technologies have difficulty in effectively suppressing screen color overflow in chroma keying, especially in live broadcast and TV shooting scenarios, where color deviation is severe.
By sampling the color components of the screen and foreground objects, calculating the hue angle and saturation, performing outward interpolation to adjust the hue angle, recalculating the color components of the foreground object to suppress the screen color, and using the set value for correction.
Effectively correct chroma overflow problems, improve color deviation, and enhance chroma keying effects.
Smart Images

Figure CN116546177B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of chroma keying, and more particularly to a method, system, terminal and storage medium for suppressing screen color in chroma keying. Background Art
[0002] Chroma keying converts the background color of a video into a transparent color while preserving the main pixels in the video. After applying chroma keying to a video, it can be superimposed on other videos, such as in live game or sports broadcasts, where a person commentating in the lower right or left corner of the live screen appears.
[0003] The principle behind chroma keying is relatively simple: it compares the colors of two pixels, removes a specific color, and converts it directly into a transparent color. This is a function that allows you to key out a single-color background. If you want to use chroma keying, there are two things you should keep in mind.
[0004] 1. The colors absorbed by chroma keying are generally pure colors. If the background is multi-color, the effect of chroma keying will be reduced.
[0005] 2. The part of the image or video to be retained for chroma keying cannot have the color components to be removed, otherwise the same colors as the retained part will be removed together.
[0006] Generally, chroma keying requires specifying the desired foreground keying color. The foreground area containing the keying color is replaced with the background image. If the screen is green, the foreground object may be light green. This is caused by green light reflected from the green screen or diffuse reflection in the camera lens. This chroma overflow is difficult to eliminate because the overflow color is not the original key color. Especially in keying scenes such as live broadcasts, TV and movie shooting, chroma overflow and color deviation are serious, and a method to solve the chroma overflow problem is needed. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a method for suppressing screen color in chroma keying, a system for suppressing screen color in chroma keying, a terminal for suppressing screen color in chroma keying, and a computer-readable storage medium in response to the above-mentioned defects of the prior art.
[0008] The technical solution adopted by the present invention to solve its technical problem is:
[0009] A method for suppressing screen color in chroma keying is constructed, which includes the following steps:
[0010] Sampling the curtain color to obtain the blue component cb1' and the red component cr1', respectively subtracting the set value from the two components to position the component value range around 0, to obtain cb1 and cr1;
[0011] Get the blue component cbx' and red component crx' of each pixel on the foreground object, subtract the set value from the two components so that the component value range is located near 0, and get cbx and crx;
[0012] Calculate the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object;
[0013] Perform outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color respectively;
[0014] Calculate the blue component cb and red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set value to restore them to positive values to obtain new cb and new cr;
[0015] The brightness information y of each foreground object pixel is retained, and the obtained new cb and new cr are used to replace the blue component cbx' and red component crx' of the original foreground object pixel color.
[0016] The method for suppressing screen color in chroma keying of the present invention, wherein the setting value is 128;
[0017] cb1=cb1'-128;
[0018] cr1=cr1'-128;
[0019] cbx = cbx'-128;
[0020] crx=crx'-128;
[0021] new cb = cb + 128;
[0022] new cr=cr+128.
[0023] In the method for suppressing screen color in chroma keying of the present invention, the step of calculating the chroma angle θ1 of the screen color and the chroma angle θx and saturation sx of each pixel on the foreground object adopts the formula:
[0024] cb=s×sinθ;
[0025] cr=s×cosθ;
[0026] Where s is the saturation and θ is the hue angle.
[0027] In the method for suppressing screen color in chroma keying of the present invention, the chroma angle has an angle range of: -Π<θ<=Π.
[0028] In the method for suppressing screen color in chroma keying of the present invention, the step of performing outward interpolation on the chroma angle θ1 and each chroma angle θx to obtain the chroma angle newθx corresponding to the new color adopts the formula:
[0029] newθx=θx+k(θx-θ1);
[0030] Here, k is the suppression coefficient and changes according to the size of (θx-θ1).
[0031] In the method for suppressing background color in chroma keying of the present invention, the step of calculating the blue component cb and the red component cr of the new color of each pixel point on the foreground object based on the new chroma angle newθx, and adding a set value to restore them to positive values, to obtain new cb and new cr, adopts the formula:
[0032] new cb=sx×sin(newθx)+128;
[0033] new cr=sx×cos(newθx)+128.
[0034] A system for suppressing curtain color in chroma keying is applied to the above-mentioned method for suppressing curtain color in chroma keying, wherein the system comprises a data sampling module and a data processing module;
[0035] The data sampling module is used to sample the color of the curtain to obtain the blue component cb1' and the red component cr1', and to obtain the blue component cbx' and the red component crx' of the color of each pixel on the foreground object;
[0036] The data processing module is configured to subtract set values from the two blue components cb1' and the red component cr1', respectively, so that the component value range is positioned near 0, thereby obtaining cbx and crx; and subtract set values from the blue component cbx' and the red component crx', respectively, so that the component value range is positioned near 0; calculate the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object; perform outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain corresponding chromaticity angles newθx of the new color; calculate the blue component cb and the red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set values to restore them to positive values, thereby obtaining new cb and new cr; retain the brightness information y of each foreground object pixel, and replace the blue component cbx' and red component crx' of the original foreground object pixel color with the obtained new cb and new cr.
[0037] The screen color suppression system in chroma keying of the present invention, wherein the setting value is 128;
[0038] cb1=cb1'-128;
[0039] cr1=cr1'-128;
[0040] cbx = cbx'-128;
[0041] crx=crx'-128;
[0042] new cb = cb + 128;
[0043] new cr = cr + 128;
[0044] The steps for calculating the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object are as follows:
[0045] cb=s×sinθ;
[0046] cr=s×cosθ;
[0047] Wherein, s is saturation, θ is chromaticity angle, and the angular range of chromaticity angle is: -Π<θ<=Π;
[0048] The steps of performing outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color are as follows:
[0049] newθx=θx+k(θx-θ1);
[0050] Where k is the suppression coefficient and changes according to the size of (θx-θ1);
[0051] Calculate the blue component cb and red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set value to restore them to positive values. The steps of obtaining new cb and new cr are as follows:
[0052] new cb=sx×sin(newθx)+128;
[0053] new cr=sx×cos(newθx)+128.
[0054] A screen color suppression terminal for chroma keying includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0055] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0056] The beneficial effect of the present invention is that: by applying the method of the present application, the chroma overflow situation in chroma keying can be corrected, which can better solve the current problem of serious color deviation. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described below with reference to the accompanying drawings and embodiments. The drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive efforts.
[0058] Figure 1 This is a flow chart of a method for suppressing screen color in chroma keying according to a preferred embodiment of the present invention;
[0059] Figure 2 2. It is a schematic diagram of the YCbcr color space of the method for suppressing screen color in chroma keying in a preferred embodiment of the present invention;
[0060] Figure 3 This is a principle block diagram of the screen color suppression system in chroma keying according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0061] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the following will be a clear and complete description of the technical solutions in the embodiments of the present invention. Obviously, the embodiments described are some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work shall fall within the scope of protection of the present invention.
[0062] The method for suppressing screen color in chroma keying in a preferred embodiment of the present invention is as follows: Figure 1 As shown, the following steps are included:
[0063] S01: Sample the curtain color to obtain the blue component cb1' and the red component cr1', and subtract the set value from the two components to position the component value range to near 0, to obtain cb1 and cr1;
[0064] Get the blue component cbx' and red component crx' of each pixel on the foreground object, subtract the set value from the two components so that the component value range is located near 0, and get cbx and crx;
[0065] S02: Calculate the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object;
[0066] S03: Perform outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color respectively;
[0067] S04: Calculate the blue component cb and red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set value to restore them to positive values to obtain new cb and new cr;
[0068] S05: retain the brightness information y of each foreground object pixel, and use the obtained new cb and new cr to replace the blue component cbx' and red component crx' of the original foreground object pixel color;
[0069] By applying the method of the present application, the chroma overflow in chroma keying can be corrected, which can effectively solve the current problem of severe color deviation.
[0070] More specific implementations are as follows:
[0071] Sample the curtain color to obtain cb1' and cr1', subtract 128 from each to position their value range around 0, and obtain cb1 = cb1'-128 and cr1 = cr1'-128.
[0072] Get the color cbx' and crx' of each pixel on the foreground object, and subtract 128 from them to position their value range around 0, so that cbx = cbx'-128 and crx = crx'-128.
[0073] According to the formula cb = s × sinθ, cr = s × cosθ, where s is the saturation and θ is the hue angle, calculate θ and s, and -Π<θ<=Π.
[0074] The chromaticity angle θ1 of the curtain color, the chromaticity angle θx and the saturation sx of each pixel are obtained respectively.
[0075] Performing outward interpolation on θ1 and θx yields the new color's chromaticity angle, newθx = θx + k(θx - θ1). k is the suppression coefficient, which has an adjustable range and changes with the magnitude of (θx - θ1). The larger (θx - θ1), the smaller k. Calculate the Cb and Cr values for each pixel corresponding to the new color, then add 128 to return them to positive values. We obtain new Cb = sx × sin(newθx) + 128, and new Cr = sx × cos(newθx) + 128.
[0076] The brightness information y of each foreground object pixel is retained, and the color information cbx', crx' of all foreground object pixels are replaced with the corresponding new pixel color information new cb = sx × sin (newθx) + 128, new cr = sx × cos (newθx) + 128. Then, the foreground color can be suppressed according to the configuration parameter k.
[0077] like Figure 2 As shown, the principles of this application are as follows:
[0078] In the YCbCr color space, colors are represented by Cb and Cr values. Cb = s × sinθ, Cr = s × cosθ, where s is the saturation and θ is the hue angle. Adjusting the hue angle changes the hue, or color. When a foreground object (e.g., a person) is in front of a screen (e.g., a green screen), the green light reflected from the green screen or diffuse reflection from the camera lens can cause the foreground object's color to be superimposed with green (e.g., if a person's skin is yellow, the green light will become yellow-green after being superimposed).
[0079] In order to eliminate the screen color on the foreground object, it is necessary to change the hue, that is, change the chromaticity angle θ, and appropriately move it away from the screen color (for example, the green of a green screen), so that the color of the foreground object can be restored (for example, the yellow-green color of the character's skin is restored to yellow). The specific chromaticity angle change formula is: newθx=θx+k(θx-θ1). The chromaticity angle of the foreground object is θx, and the chromaticity angle of the screen color is θ1. On the basis of the chromaticity angle of the foreground object θx, a correction value k(θx-θ1) is added, where k is a positive value. Adjusting the k value to change the correction value can correct the color to be away from the screen color. The K value range is adjustable, and k changes according to the absolute value of (θx-θ1). The larger |θx-θ1| is, the smaller k is, because the larger |θx-θ1| is, the farther the foreground color is from the screen color, and no major correction is needed.
[0080] It should be noted that the symbols used in the present application are only for facilitating the understanding of the present solution and are not intended to limit the symbols. Those skilled in the art may also replace them with other symbols.
[0081] A system for suppressing screen color in chroma keying is applied to the above-mentioned method for suppressing screen color in chroma keying, such as Figure 3 As shown, it includes a data sampling module 100 and a data processing module 101;
[0082] The data sampling module 100 is used to sample the screen color to obtain the blue component cb1' and the red component cr1', and to obtain the blue component cbx' and the red component crx' of each pixel on the foreground object;
[0083] Data processing module 101 is configured to subtract set values from the two blue components cb1' and the red component cr1', respectively, to position the component value range around 0, thereby obtaining cbx and crx, and to subtract set values from the blue component cbx' and the red component crx', respectively, to position the component value range around 0; calculate the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object; perform outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain corresponding chromaticity angles newθx of the new color; calculate the blue component cb and the red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add set values to each pixel to restore them to positive values, thereby obtaining new cb and new cr; retain the brightness information y of each foreground pixel, and replace the blue component cbx' and red component crx' of the original foreground pixel color with the obtained new cb and new cr.
[0084] The screen color suppression system in the chroma keying of the present invention, wherein the setting value is 128;
[0085] cb1=cb1'-128;
[0086] cr1=cr1'-128;
[0087] cbx = cbx'-128;
[0088] crx=crx'-128;
[0089] new cb = cb + 128;
[0090] new cr = cr + 128;
[0091] The steps for calculating the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object are as follows:
[0092] cb=s×sinθ;
[0093] cr=s×cosθ;
[0094] Wherein, s is saturation, θ is chromaticity angle, and the angular range of chromaticity angle is: -Π<θ<=Π;
[0095] The steps of performing outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color are as follows:
[0096] newθx=θx+k(θx-θ1);
[0097] Where k is the suppression coefficient and changes according to the size of (θx-θ1);
[0098] Calculate the blue component cb and red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set value to restore them to positive values. The steps of obtaining new cb and new cr are as follows:
[0099] new cb=sx×sin(newθx)+128;
[0100] new cr=sx×cos(newθx)+128;
[0101] By using the system of the present application, chroma overflow in chroma keying can be corrected, which can effectively solve the current problem of severe color deviation.
[0102] A screen color suppression terminal for chroma keying includes a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0103] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0104] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all such improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A method for suppressing screen color in chroma keying, characterized in that: The following steps are involved: Sampling the curtain color to obtain the blue component cb1' and the red component cr1', respectively subtracting the set value from the two components to position the component value range around 0, to obtain cb1 and cr1; Get the blue component cbx' and red component crx' of each pixel on the foreground object, subtract the set value from the two components so that the component value range is located near 0, and get cbx and crx; Calculate the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object; Perform outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color respectively; Calculate the blue component cb and red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set value to restore them to positive values to obtain new cb and new cr; Keep the brightness information y of each foreground pixel, and use the obtained new cb and new cr to replace the blue component cbx' and red component crx' of the original foreground pixel color; The step of performing outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color respectively adopts the formula: newθx=θx+k(θx-θ1); Here, k is the suppression coefficient and changes according to the size of (θx-θ1).
2. The method for suppressing screen color in chroma keying according to claim 1, wherein: The set value is 128; cb1=cb1'-128; cr1=cr1'-128; cbx = cbx'-128; crx=crx'-128; new cb = cb + 128; new cr=cr+128.
3. The method for suppressing screen color in chroma keying according to claim 1 or 2, wherein: The step of calculating the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object adopts the formula: cb=s×sinθ; cr=s×cosθ; Where s is the saturation and θ is the hue angle.
4. The method for suppressing screen color in chroma keying according to claim 3, wherein: The angular range of the chromaticity angle is: -Π<θ<=Π.
5. The method for suppressing screen color in chroma keying according to claim 1, wherein: The step of calculating the blue component cb and the red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and adding the set value to restore them to positive values to obtain new cb and new cr adopts the formula: new cb=sx×sin(newθx)+128; new cr=sx×cos(newθx)+128.
6. A system for suppressing screen color in chroma keying, applied to the method for suppressing screen color in chroma keying according to any one of claims 1 to 5, characterized in that: Including data sampling module and data processing module; The data sampling module is used to sample the color of the curtain to obtain the blue component cb1' and the red component cr1', and to obtain the blue component cbx' and the red component crx' of the color of each pixel on the foreground object; The data processing module is used to respectively subtract set values from the two blue components cb1' and the red component cr1' so that the component value range is located near 0, thereby obtaining cbx and crx, and respectively subtract set values from the blue component cbx' and the red component crx' so that the component value range is located near 0; calculate the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel point on the foreground object; perform outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain corresponding chromaticity angles newθx of the new color; calculate the blue component cb and the red component cr of the new color of each pixel point on the foreground object based on the new chromaticity angle newθx, and respectively add the set values to restore them to positive values to obtain new cb and new cr; retain the brightness information y of each foreground object pixel, and use the obtained new cb and new cr to replace the blue component cbx' and red component crx' of the original foreground object pixel color; The step of performing outward interpolation on the chromaticity angle θ1 and each chromaticity angle θx to obtain the chromaticity angle newθx of the new color respectively adopts the formula: newθx=θx+k(θx-θ1); Here, k is the suppression coefficient and changes according to the size of (θx-θ1).
7. The screen color suppression system in chroma keying according to claim 6, characterized in that: The set value is 128; cb1=cb1'-128; cr1=cr1'-128; cbx = cbx'-128; crx=crx'-128; new cb = cb + 128; new cr = cr + 128; The steps for calculating the chromaticity angle θ1 of the screen color and the chromaticity angle θx and saturation sx of each pixel on the foreground object are as follows: cb=s×sinθ; cr=s×cosθ; Wherein, s is saturation, θ is chromaticity angle, and the angular range of chromaticity angle is: -Π<θ<=Π; Calculate the blue component cb and red component cr of the new color of each pixel on the foreground object based on the new chromaticity angle newθx, and add the set value to restore them to positive values. The steps of obtaining new cb and new cr are as follows: new cb=sx×sin(newθx)+128; new cr=sx×cos(newθx)+128.
8. A screen color suppression terminal for chroma keying, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Blue screen image-matting method
CN104200470A
Image processing method, electronic equipment and computer readable storage medium
CN111524076A