CN113409221B - Image color matting method, system, computer equipment and storage medium - Google Patents

Image color matting method, system, computer equipment and storage medium Download PDF

Info

Publication number
CN113409221B
CN113409221B CN202110732312.1A CN202110732312A CN113409221B CN 113409221 B CN113409221 B CN 113409221B CN 202110732312 A CN202110732312 A CN 202110732312A CN 113409221 B CN113409221 B CN 113409221B
Authority
CN
China
Prior art keywords
value
component
image
difference
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110732312.1A
Other languages
Chinese (zh)
Other versions
CN113409221A (en
Inventor
侯海娜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Wondershare Software Co Ltd
Original Assignee
Shenzhen Wondershare Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Wondershare Software Co Ltd filed Critical Shenzhen Wondershare Software Co Ltd
Priority to CN202110732312.1A priority Critical patent/CN113409221B/en
Publication of CN113409221A publication Critical patent/CN113409221A/en
Application granted granted Critical
Publication of CN113409221B publication Critical patent/CN113409221B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • G06T5/94
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses an image color matting method, an image color matting system, computer equipment and a storage medium, wherein the method comprises the following steps: acquiring an SRC image, converting the SRC image into an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image; taking a pixel point of the HSV image subjected to color subtraction as a reference pixel point, and acquiring corresponding H component value, S component value and V component value; calculating a difference value and a tolerance value of corresponding components between each pixel point in the HSV image and the reference pixel point, and calculating a difference value duty ratio according to the difference value and the tolerance value; and calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain the target image. According to the invention, the transparency map is obtained by calculating the difference value and the difference value ratio of each component value of each pixel point and each reference pixel point in the SRC image, and the transparency map is used for fusing the SRC image and the base image, so that the background color is more accurately scratched and removed, and the application range is wider.

Description

Image color matting method, system, computer equipment and storage medium
Technical Field
The present invention relates to the field of color subtraction technology, and in particular, to a method, a system, a computer device, and a storage medium for color matting of an image.
Background
Blue Screen technology (Blue Screen) is the most dominant means of extracting channels. The method is to shoot characters or other foreground contents and then remove the monochromatic background by utilizing the difference of chromaticity. Blue screen technology has a name called Chroma key (Chroma Keying). The digital synthesis software allows the user to specify a range of colors, pixels with colors within this range being used as background, the corresponding Alpha channel value being set to 0; pixels outside this range are used as foreground and the corresponding Alpha channel value is set to 1. The primary principle is that the background color selected cannot be included on the foreground object. In principle, any color may be used as the background as long as the color used for the background is not present in the foreground picture, but in practice, both blue and green backgrounds are most commonly used. The reason is that the natural colors of the human body do not contain the two colors, and the human body cannot be mixed with the human body by using the natural colors as the background; at the same time, the two colors are primary colors in the RGB system, and the processing is relatively convenient.
In order to facilitate the extraction of channels in post-production, there are some problems to be noted when taking a blue (green) screen shot: firstly, the foreground object cannot contain the selected background color, and other background colors can be selected if necessary; secondly, the background color must be consistent, the illumination is uniform, and the background or the illumination intensity is avoided as much as possible. In the process of color matting production in the later stage, a better effect can be obtained.
The primary detection of the matting technique and the related color matting technique mainly aims at matting green curtain or blue curtain, and a corresponding foreground image is left and is fused with a new background image. When color matting is performed, firstly, the image color is converted from BGR to HSV space, and BGR of pixels determined as the background color in the original image is set to 0 by setting the approximate range of color H (hue) to be scratched. However, most of the methods are directed to blue curtains and green curtains, and few methods for scratching out any color are available. Most importantly, when the background of the green (blue) curtain is uneven or the illumination condition is not ideal, residues are easy to occur on the background or pixels in the foreground are directly scratched off, and the edges are easy to generate saw-tooth conditions.
Disclosure of Invention
The embodiment of the invention provides an image color matting method, an image color matting system, computer equipment and a storage medium, which aim to solve the problem that matting colors cannot be suitable for all background colors in the prior art.
In a first aspect, an embodiment of the present invention provides an image color matting method, including:
acquiring an SRC image to be processed, converting the SRC image into an HSV space from a BGR color space to obtain an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image;
taking a pixel point needing color deduction in the HSV image as a reference pixel point, and acquiring an H component value, an S component value and a V component value corresponding to the reference pixel point;
calculating difference values and tolerance values of corresponding components among an H component, an S component and a V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating a difference value duty ratio according to the difference values and the tolerance values;
and calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain a target image.
In a second aspect, an embodiment of the present invention provides an image color matting system, including:
the space conversion unit is used for acquiring an SRC image to be processed, converting the SRC image into an HSV space from a BGR color space to obtain an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image;
a reference pixel component value obtaining unit, configured to take a pixel to be color subtracted in the HSV image as a reference pixel, and obtain an H component value, an S component value, and a V component value corresponding to the reference pixel;
the difference value duty ratio calculation unit is used for calculating difference values and tolerance values of corresponding components among an H component, an S component and a V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating a difference value duty ratio according to the difference values and the tolerance values;
and the target image acquisition unit is used for calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain a target image.
In a third aspect, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the image color matting method described in the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program when executed by a processor causes the processor to perform the image color matting method described in the first aspect.
The embodiment of the invention provides an image color matting method, an image color matting system, computer equipment and a storage medium, wherein the method comprises the following steps: acquiring an SRC image to be processed, converting the SRC image into an HSV space from a BGR color space to obtain an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image; taking a pixel point needing color deduction in the HSV image as a reference pixel point, and acquiring an H component value, an S component value and a V component value corresponding to the reference pixel point; calculating difference values and tolerance values of corresponding components among an H component, an S component and a V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating a difference value duty ratio according to the difference values and the tolerance values; and calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain a target image. According to the embodiment of the invention, the transparency map is obtained by calculating the difference value and the difference value ratio of each component value of each pixel point and each reference pixel point in the SRC image, and the transparency map is used for fusing the SRC image and the base image, so that the background color is more accurately scratched and removed, and the application range is wider.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of an image color matting method according to an embodiment of the present invention;
fig. 2 is a schematic block diagram of an image color matting system provided by an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flowchart of an image color matting method according to an embodiment of the present invention, and the method includes steps S101 to S104.
S101, acquiring an SRC image to be processed, converting the SRC image into an HSV space from a BGR color space to obtain an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image;
s102, taking a pixel point needing color subtraction in the HSV image as a reference pixel point, and acquiring an H component value, an S component value and a V component value corresponding to the reference pixel point;
s103, calculating difference values and tolerance values of corresponding components among an H component, an S component and a V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating a difference value duty ratio according to the difference values and the tolerance values;
and S104, calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain a target image.
In this embodiment, firstly, an SRC image to be processed is acquired, then, the SRC image is subjected to color space conversion to obtain an HSV image, and then, an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image are calculated; selecting an HSV value of a color to be vacated, namely selecting a reference pixel point in the HSV image, taking the color corresponding to the reference pixel point as a deducted color, and calculating an H component value, an S component value and a V component value of the reference pixel point; the difference value and the tolerance value between each pixel point in the HSV image and each corresponding component of the reference pixel point are calculated, and the difference value duty ratio is calculated; after the difference value and the difference value duty ratio are obtained, a corresponding transparency map can be calculated, then a new image is selected as a basic image, the SRC image and the basic image are fused according to the transparency map, and a target image is obtained, so that the color deduction processing of the image is completed.
The SRC image is subjected to color space conversion, namely the SRC image is converted from RGB color space into HSV space, wherein R in the RGB color space represents a red channel, G represents a green channel, B represents a blue channel, H in the HSV image represents a tone, S represents saturation, and V represents brightness. The images acquired in the natural environment are easily affected by natural illumination, shielding of foreign objects, shadow and the like, namely are sensitive to brightness. While the three components of the RGB color space are all closely related to luminance, i.e. as luminance changes, the three components change accordingly. However, the sensitivity of the human eye to these three color components is different, and in a single color, the human eye is least sensitive to red and most sensitive to blue, so that the RGB color space is a color space with poor uniformity. If the similarity of colors is measured directly by Euclidean distance, the result will deviate greatly from human vision. For a certain color, it is difficult to infer more accurate three component values to represent. The RGB color space is therefore suitable for display systems but not for image processing, and therefore the SRC image is first converted from RGB image format to HSV image for processing the image.
In an embodiment, the calculating the H component value, the S component value, and the V component value corresponding to each pixel in the HSV image includes:
the range of V component values is calculated using the following formula: v=max (R, G, B);
calculating the value range of the S component by using the V component:
when v+.0, s= (V-min (R, G, B))/V; when v=0, s=0;
calculating the value range of the H component by using the V component:
when v=r, h=60 x (G-B)/(V-min (R, G, B));
when v=g, h=120+60 (B-R)/(V-min (R, G, B));
when v=b, h=240+60 (R-G)/(V-min (R, G, B)).
In this embodiment, the values of the components in the HSV image are calculated using the above formula. When performing RGB color space conversion, the value range of each channel of RGB should be normalized to 32-bit floating point number, i.e. the variation range of the value of each channel is 0-1. At this time, v=max (R, G, B), and then the values of the S component and the H component are calculated according to the values of the V component, and the values of the components of the HSV image corresponding to the SRC image are calculated, where the calculated value range of the H component is 0-360, the value range of the S component is 0-1, and the value range of the V component is 0-1.
In an embodiment, the calculating the difference and tolerance values of the corresponding components between the H component, the S component, and the V component in each pixel point in the HSV image and the H component, the S component, and the V component of the reference pixel point, and calculating the difference duty ratio according to the difference and tolerance values includes:
acquiring a low value range which is larger than 0 and a high value range which is smaller than 360 in a red area in the HSV image, and carrying out normalization processing on the difference value according to the low value range and the high value range to obtain a normalization value;
calculating a reference range of a difference value between an H component in each pixel point and an H component of the reference pixel point and a tolerance value of the reference range;
and calculating the difference duty ratio of the difference value in the area range of the reference range and the tolerance value according to the normalized value and the tolerance value.
In this embodiment, a high value range and a low value range of a red region in the HSV image are obtained, normalization processing is performed, then a difference value of an H component between each pixel point and a reference pixel point, a reference range of the difference value and a tolerance value are calculated, and a difference value duty ratio is calculated according to the normalization value and the tolerance value.
Specifically, in the HSV image, the red region spans the hue ranges of 0 and 360, so that the value range of the red region is calculated first in the calculation. Let control_h_low be the value range of red when the hue range is greater than 0 and control_h_high be the value range of red when the hue range is less than 360. After debugging and verification, when control_h_low=10, the display effect of red is better, namely, a tone area between 0 and 10 is judged as a red area; when control_h_high=330, the display effect of red is excellent, that is, the color tone region between 330 and 360 is determined as the red region.
And setting a reference range of a difference value between any pixel point H component value in the HSV image and the reference pixel point H component value as range, and setting a tolerance value as offset. And taking the pixel point with the difference value smaller than the sum of the reference range and the tolerance value as a candidate pixel point capable of being scratched, and taking the pixel point with the difference value larger than the sum of the reference range and the tolerance value as a foreground pixel point. The range of range and offset may be 1-360 (the range of hues is 0-360), but to better scratch the designated colors, the range and offset values need to be reduced and rationalized. According to the RGB color circles, 0 (360), 120, 240 represent respectively the three primary colors red, green and blue, the place where the color change in the middle is obvious is basically 30, 60, 90, etc., so range and offset take values to verify within 90 and 60, respectively. The verification result shows that when range is between 20 and 80 and offset is between 20 and 40, the color display effect is not obvious and the effect is good.
When hue < = control_h_low and h > = control_h_high:
dif_h=(360.0-h+hue)/360
value_h=(range_-abs(dif_h)+offset_)/offset_
when hue > = control_h_high and h < = control_h_low:
dif_h=(360-hue+h)/360.0;
value_h=(range_-abs(dif_h)+offset_)/offset_
otherwise:
dif_h=abs(h-hue)/360;
value_h=(range_-abs(dif_h)+offset_)/offset_
wherein range_ = range/360, offset_ = offset/360, range_ is a normalized reference range, offset_ is a normalized tolerance value, dif_h represents a normalized value (normalized value is a normalized value of an absolute value of a difference value between an H component of a pixel point in an HSV image and an H component of a reference pixel point, wherein the value range of H is 0 to 360), and value_h represents a difference value duty ratio.
In an embodiment, the calculating the transparency map according to the difference value and the difference value duty ratio includes:
acquiring the minimum value and the maximum value of the S component and the minimum value and the maximum value of the V component of the reference pixel point;
normalizing the difference value duty ratio to obtain a normalized difference value duty ratio, and calculating the display duty ratio of each pixel point in the SRC image according to a preset calculation rule by combining the minimum value and the maximum value of the S component and the minimum value and the maximum value of the V component;
and normalizing the display duty ratio to obtain the transparency map.
In this embodiment, the display duty ratio of each pixel is calculated according to the maximum and minimum values of the S component, the maximum and minimum values of the V component, and the normalized difference duty ratio, and the transparency map is calculated according to the display duty ratio. In the transparency map, if the pixel value is 0, the pixel point is represented as a background, and if the pixel value is 1, the pixel point is represented as a foreground, and if the pixel value is between 0 and 1, the transition condition between the foreground and the background at the edge is represented.
The maximum value and the minimum value of the S component are denoted as control_s_high and control_s_low, respectively, and the maximum value and the minimum value of the V component are denoted as control_v_high and control_v_low, respectively. In this embodiment, control_s_low=0.15, control_s_high=0.3, control_v_low=0.2, and control_v_high=0.4 are set. The size of the four values is continuously adjusted by utilizing pre-stored image data, wherein the image data comprises images with less influence on saturation and brightness of the scratched colors and uniform visual color (pure color) and images with non-uniform scratched colors (the same color but different depths are obviously seen by visual effects); in the process of removing the colors, colors of different positions of the non-uniform background are selected for removing. The larger the control_s_high or control_v_high (the larger the control_s_low and control_v_low are, the more pixels can be scratched out in the screen, and conversely the fewer. The average value of the S component and the V component is 0-1, so that the range of the control_s_low and the control_s_high is 0-1, and the range of the control_v_low and the control_v_high is 0-1. Through multiple parameter adjustment and verification, the difference between control_s_low and control_s_high in this embodiment is kept at 0.15, the difference between control_v_low and control_v_high is kept at 0.2, and control_s_low is smaller than control_v_low by 0.05, so that the effect obtained in this case is better.
For any one pixel point I (I, j), I represents a row number, and j represents a column number:
when value_h < = 0.1: mask (i, j) =1.0;
when value_h > =0.9:
if: dif_s < = control_s_low and dif_v < = control_v_high
Mask (i, j) =0.0
If: control_s_high or dif_v > control_v_high
Mask (i, j) =1.0
Otherwise: mask (i, j) = (control_s_high-dif_s)/(control_s_high-control_s_low) ((control_v_high-dif_v)/(control_v_high-control_v_low));
when 0.1< value_h < 0.9:
if: dif_s > control_s_high or dif_v > control_v_high
Mask (i, j) =1.0
Otherwise: mask (i, j) =value_h (control_s_high-dif_s)/(control_s_high-control_s_low) ((control_v_high-dif_v)/(control_v_high-control_v_low));
where mask (I, j) is the value of a certain pixel in the transparency map, value_h represents the difference ratio, dif_s refers to the absolute value of the difference between the S component value of the reference pixel and the S component value of pixel I, and dif_v is the absolute value of the difference between the V component value of the reference pixel and the V component value of pixel I.
In an embodiment, the fusing the SRC image and the base image according to the transparency map to obtain the target image includes:
performing edge smoothing processing operation on the transparency map to obtain an edge transparency map;
and carrying out fusion processing on the SRC image and the basic image according to the edge transparency map, and carrying out expansion operation and corrosion operation on the fused image to obtain a target image.
In this embodiment, the transparency map is subjected to edge smoothing to obtain an edge transparency map, so that a target image obtained when the SRC image and the base image are fused according to the edge transparency map is smoother, and then expansion operation and corrosion operation are performed to obtain a final target image.
The edge smoothing process may employ the following method: and smoothing the transparency map by adopting a window of 3*3, and carrying out windowing processing by taking the window as a center for each pixel point in the transparency map. For example, centered around a pixel with a pixel value of 0.3, the window covering 3*3 performs the following calculations: value= (0.3×1+0.4×1+0.15×1+0.01×1+0.3×1+0.58×1+0.77×1+0.14×1+0.35×1)/9, and 0.3 is replaced with the calculated Value. Then the window is moved to the right by one pixel point, and the next value is calculated to replace the pixel point through the formula. Similarly, firstly, starting from an initial pixel point of the transparency map, sequentially calculating to the right until the edge, and then returning to sequentially calculate by taking the pixel point of the initial pixel point right below the transparency map as the center and sliding to the right until the edge.
Expansion operation: and for each pixel point, obtaining the maximum value in the window taking the pixel point as the center, and assigning the maximum value to the center pixel of the current window. And (3) corrosion operation: in contrast to the dilation operation, for each pixel point, a minimum is found within the window centered around it and assigned to the center pixel of the current window.
In an embodiment, the fusing the SRC image and the base image according to the edge transparency map includes:
the fusion process is performed according to the following formula:
combine(i,j)=src(i,j)*mask(i,j)+b_img(i,j)*(1-mask(i,j))
wherein SRC (i, j) is a pixel point in the SRC image, i is a row number, j is a column number, mask (i, j) is a transparency map corresponding to the pixel point in the SRC image, and b_img (i, j) is one of the pixel points in the base image.
In this embodiment, the image fusion is performed according to the above formula, and since the SRC image is a multi-channel image (R, G, B three color channels) at the time of input, each channel needs to perform the calculation of the above formula, and the obtained combination is an image with the same number of channels as the SRC image. The Mask image may be a single channel, i.e. one pixel has only one value representation, or may be an image with the same number of channels as the SRC image, if it is greater than 1 channel, then the channel value used to represent each pixel is the same.
In an embodiment, the normalizing the difference duty ratio includes:
the difference duty ratio is normalized according to the following formula:
value_h=min(value_h,1.0)
value_h=max(value_h,0.0)
wherein value_h represents the difference duty cycle;
the normalizing the display duty ratio includes:
the display duty ratio is normalized according to the following formula:
mask(i,j)=min(mask(i,j),1.0)
mask(i,j)=max(mask(i,j),0.0)
wherein mask (i, j) represents a pixel point in the transparency map.
In this embodiment, normalization is required after the difference duty ratio and the display duty ratio are obtained, so as to avoid data overflow. The rule of the normalization processing is as follows: when the data is greater than 1, then the data is considered to be 1; when the data is less than 0, then the data is considered to be 0; when the data is larger than 0 and smaller than 1, the actual value of the data is taken. And carrying out normalization processing on the data through the rules, so as to control the value range of the data to be kept between 0 and 1.
Referring to fig. 2, fig. 2 is a schematic block diagram of an image color matting system according to an embodiment of the present invention, where the image color matting system 200 includes:
the space conversion unit 201 is configured to obtain an SRC image to be processed, convert the SRC image from BGR color space into HSV space, obtain an HSV image, and calculate an H component value, an S component value, and a V component value corresponding to each pixel point in the HSV image;
a reference pixel component value obtaining unit 202, configured to take a pixel to be color subtracted in the HSV image as a reference pixel, and obtain an H component value, an S component value, and a V component value corresponding to the reference pixel;
a difference duty ratio calculating unit 203, configured to calculate a difference value and a tolerance value of corresponding components among the H component, the S component, and the V component in each pixel point in the HSV image and the H component, the S component, and the V component of the reference pixel point, and calculate a difference duty ratio according to the difference value and the tolerance value;
and the target image obtaining unit 204 is configured to calculate a transparency map according to the difference value and the difference value duty ratio, and perform fusion processing on the SRC image and the base image according to the transparency map, so as to obtain a target image.
In an embodiment, the space conversion unit 201 includes:
the V component value taking unit is used for calculating the value range of the V component by using the following formula: v=max (R, G, B);
an S component value unit for calculating a value range of the S component using the V component:
when v+.0, s= (V-min (R, G, B))/V; when v=0, s=0;
an H component value unit for calculating a value range of the H component using the V component:
when v=r, h=60 x (G-B)/(V-min (R, G, B));
when v=g, h=120+60 (B-R)/(V-min (R, G, B));
when v=b, h=240+60 (R-G)/(V-min (R, G, B)).
In an embodiment, the difference duty ratio calculation unit 203 includes:
the normalization value acquisition unit is used for acquiring a low value range which is larger than 0 and a high value range which is smaller than 360 in a red area in the HSV image, and normalizing the difference value according to the low value range and the high value range to obtain a normalization value;
a tolerance value calculation unit for calculating a reference range of a difference value between an H component in each pixel point and an H component of the reference pixel point and a tolerance value of the reference range;
and the difference value duty ratio calculation unit is used for calculating the difference value duty ratio of the difference value in the area range of the reference range and the tolerance value according to the normalized value and the tolerance value.
In one embodiment, the target image acquisition unit 204 includes:
a reference pixel component value obtaining unit, configured to obtain a minimum value and a maximum value of an S component and a minimum value and a maximum value of a V component of the reference pixel;
the display duty ratio obtaining unit is used for carrying out normalization processing on the difference duty ratio to obtain normalized difference duty ratio, and calculating the display duty ratio of each pixel point in the SRC image according to a preset calculation rule by combining the minimum value and the maximum value of the S component and the minimum value and the maximum value of the V component;
and the transparency map acquisition unit is used for normalizing the display duty ratio to obtain the transparency map.
In an embodiment, the target image acquisition unit 204 further comprises:
an edge transparency map obtaining unit, configured to perform edge smoothing operation on the transparency map to obtain an edge transparency map;
and the post-processing unit is used for carrying out fusion processing on the SRC image and the basic image according to the edge transparency map, and carrying out expansion operation and corrosion operation on the fused image to obtain a target image.
In an embodiment, the target image acquisition unit 204 further comprises:
a formula calculation unit for performing fusion processing according to the following formula:
combine(i,j)=src(i,j)*mask(i,j)+b_img(i,j)*(1-mask(i,j))
wherein SRC (i, j) is a pixel point in the SRC image, i is a row number, j is a column number, mask (i, j) is a transparency map corresponding to the pixel point in the SRC image, and b_img (i, j) is one of the pixel points in the base image.
In one embodiment, the difference duty cycle normalization processing unit comprises:
the first normalization processing unit is used for normalizing the difference value duty ratio according to the following formula:
value_h=min(value_h,1.0)
value_h=max(value_h,0.0)
wherein value_h represents the difference duty cycle;
the display duty ratio normalization processing unit includes:
the second normalization processing unit is used for normalizing the display duty ratio according to the following formula:
mask(i,j)=min(mask(i,j),1.0)
mask(i,j)=max(mask(i,j),0.0)
wherein mask (i, j) represents a pixel point in the transparency map.
The embodiment of the invention also provides computer equipment, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the image color matting method when executing the computer program.
Embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements an image color matting method as described above.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the invention can be made without departing from the principles of the invention and these modifications and adaptations are intended to be within the scope of the invention as defined in the following claims.
It should also be noted that in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (8)

1. An image color matting method, comprising:
acquiring an SRC image to be processed, converting the SRC image into an HSV space from a BGR color space to obtain an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image;
taking a pixel point needing color deduction in the HSV image as a reference pixel point, and acquiring an H component value, an S component value and a V component value corresponding to the reference pixel point;
calculating difference values and tolerance values of corresponding components among an H component, an S component and a V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating a difference value duty ratio according to the difference values and the tolerance values;
calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain a target image;
the calculating the difference and tolerance values of the corresponding components between the H component, the S component and the V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating the difference duty ratio according to the difference and tolerance values includes:
acquiring a low value range which is larger than 0 and a high value range which is smaller than 360 in a red area in the HSV image, and carrying out normalization processing on the difference value according to the low value range and the high value range to obtain a normalization value;
calculating a reference range of a difference value between an H component in each pixel point and an H component of the reference pixel point and a tolerance value of the reference range;
calculating the difference value duty ratio of the difference value in the area range of the reference range and the tolerance value according to the normalized value and the tolerance value;
the calculating the transparency map according to the difference value and the difference value duty ratio comprises the following steps:
acquiring the minimum value and the maximum value of the S component and the minimum value and the maximum value of the V component of the reference pixel point;
normalizing the difference value duty ratio to obtain a normalized difference value duty ratio, and calculating the display duty ratio of each pixel point in the SRC image according to a preset calculation rule by combining the minimum value and the maximum value of the S component and the minimum value and the maximum value of the V component;
and normalizing the display duty ratio to obtain the transparency map.
2. The method of claim 1, wherein the calculating the H component value, the S component value, and the V component value corresponding to each pixel in the HSV image comprises:
the range of V component values is calculated using the following formula: v=max (R, G, B);
calculating the value range of the S component by using the V component:
when v+.0, s= (V-min (R, G, B))/V; when v=0, s=0;
calculating the value range of the H component by using the V component:
when v=r, h=60 x (G-B)/(V-min (R, G, B));
when v=g, h=120+60 (B-R)/(V-min (R, G, B));
when v=b, h=240+60 (R-G)/(V-min (R, G, B)).
3. The image color matting method according to claim 1, wherein the fusing the SRC image and the base image according to the transparency map to obtain a target image includes:
performing edge smoothing processing operation on the transparency map to obtain an edge transparency map;
and carrying out fusion processing on the SRC image and the basic image according to the edge transparency map, and carrying out expansion operation and corrosion operation on the fused image to obtain a target image.
4. The image color matting method according to claim 3, wherein the fusing the SRC image with a base image according to the edge transparency map includes:
the fusion process is performed according to the following formula:
combine(i,j)=src(i,j)*mask(i,j)+b_img(i,j)*(1-mask(i,j))
wherein SRC (i, j) is a pixel point in the SRC image, i is a row number, j is a column number, mask (i, j) is a transparency map corresponding to the pixel point in the SRC image, and b_img (i, j) is one of the pixel points in the base image.
5. An image color matting method according to claim 1, characterized in that the normalizing the difference ratio comprises:
the difference duty ratio is normalized according to the following formula:
value_h=min(value_h,1.0)
value_h=max(value_h,0.0)
wherein value_h represents the difference duty cycle;
the normalizing the display duty ratio includes:
the display duty ratio is normalized according to the following formula:
mask(i,j)=min(mask(i,j),1.0)
mask(i,j)=max(mask(i,j),0.0)
wherein mask (i, j) represents a pixel point in the transparency map.
6. An image color matting system comprising:
the space conversion unit is used for acquiring an SRC image to be processed, converting the SRC image into an HSV space from a BGR color space to obtain an HSV image, and calculating an H component value, an S component value and a V component value corresponding to each pixel point in the HSV image;
a reference pixel component value obtaining unit, configured to take a pixel to be color subtracted in the HSV image as a reference pixel, and obtain an H component value, an S component value, and a V component value corresponding to the reference pixel;
the difference value duty ratio calculation unit is used for calculating difference values and tolerance values of corresponding components among an H component, an S component and a V component in each pixel point in the HSV image and the H component, the S component and the V component of the reference pixel point, and calculating a difference value duty ratio according to the difference values and the tolerance values;
the target image acquisition unit is used for calculating a transparency map according to the difference value and the difference value duty ratio, and carrying out fusion processing on the SRC image and the basic image according to the transparency map to obtain a target image;
the difference duty ratio calculation unit includes:
the normalization value acquisition unit is used for acquiring a low value range which is larger than 0 and a high value range which is smaller than 360 in a red area in the HSV image, and normalizing the difference value according to the low value range and the high value range to obtain a normalization value;
a tolerance value calculation unit for calculating a reference range of a difference value between an H component in each pixel point and an H component of the reference pixel point and a tolerance value of the reference range;
a difference duty ratio calculation unit, configured to calculate a difference duty ratio of the difference in a region range of the reference range and the tolerance value according to the normalized value and the tolerance value;
the target image acquisition unit includes:
a reference pixel component value obtaining unit, configured to obtain a minimum value and a maximum value of an S component and a minimum value and a maximum value of a V component of the reference pixel;
the display duty ratio obtaining unit is used for carrying out normalization processing on the difference duty ratio to obtain normalized difference duty ratio, and calculating the display duty ratio of each pixel point in the SRC image according to a preset calculation rule by combining the minimum value and the maximum value of the S component and the minimum value and the maximum value of the V component;
and the transparency map acquisition unit is used for normalizing the display duty ratio to obtain the transparency map.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements an image color matting method according to any one of claims 1 to 5 when the computer program is executed.
8. A computer readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform an image color matting method as claimed in any one of claims 1 to 5.
CN202110732312.1A 2021-06-30 2021-06-30 Image color matting method, system, computer equipment and storage medium Active CN113409221B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110732312.1A CN113409221B (en) 2021-06-30 2021-06-30 Image color matting method, system, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110732312.1A CN113409221B (en) 2021-06-30 2021-06-30 Image color matting method, system, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113409221A CN113409221A (en) 2021-09-17
CN113409221B true CN113409221B (en) 2023-12-12

Family

ID=77680387

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110732312.1A Active CN113409221B (en) 2021-06-30 2021-06-30 Image color matting method, system, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113409221B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107087123A (en) * 2017-04-26 2017-08-22 杭州奥点科技股份有限公司 It is a kind of that image space method is scratched based on the real-time high-definition that high in the clouds is handled
CN107346553A (en) * 2016-05-06 2017-11-14 深圳超多维光电子有限公司 The determination method and apparatus of stripe information in a kind of image
WO2018107983A1 (en) * 2016-12-16 2018-06-21 深圳市中达瑞和科技有限公司 Colour recognition method and system
CN112330531A (en) * 2020-11-04 2021-02-05 广州博冠信息科技有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN112991366A (en) * 2021-02-18 2021-06-18 广州光锥元信息科技有限公司 Method and device for carrying out real-time chroma matting on image and mobile terminal
CN113034509A (en) * 2021-02-26 2021-06-25 北京达佳互联信息技术有限公司 Image processing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107346553A (en) * 2016-05-06 2017-11-14 深圳超多维光电子有限公司 The determination method and apparatus of stripe information in a kind of image
WO2018107983A1 (en) * 2016-12-16 2018-06-21 深圳市中达瑞和科技有限公司 Colour recognition method and system
CN107087123A (en) * 2017-04-26 2017-08-22 杭州奥点科技股份有限公司 It is a kind of that image space method is scratched based on the real-time high-definition that high in the clouds is handled
CN112330531A (en) * 2020-11-04 2021-02-05 广州博冠信息科技有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN112991366A (en) * 2021-02-18 2021-06-18 广州光锥元信息科技有限公司 Method and device for carrying out real-time chroma matting on image and mobile terminal
CN113034509A (en) * 2021-02-26 2021-06-25 北京达佳互联信息技术有限公司 Image processing method and device

Also Published As

Publication number Publication date
CN113409221A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
US9852499B2 (en) Automatic selection of optimum algorithms for high dynamic range image processing based on scene classification
CN108668093B (en) HDR image generation method and device
US11323676B2 (en) Image white balance processing system and method
US8644638B2 (en) Automatic localized adjustment of image shadows and highlights
CN109862389B (en) Video processing method, device, server and storage medium
JP2000171304A (en) Detecting method of color illumination color temperature and device therefor
JP2003271971A (en) Method for real-time discrimination and compensation for illuminance change in digital color image signal
CN104504722B (en) Method for correcting image colors through gray points
CN108965647B (en) Foreground image obtaining method and device
CN109325918B (en) Image processing method and device and computer storage medium
CN108389215B (en) Edge detection method and device, computer storage medium and terminal
KR20070090224A (en) Method of electronic color image saturation processing
CN107918928B (en) Color reduction method
CN109949248B (en) Method, apparatus, device and medium for modifying color of vehicle in image
Wang et al. Fast automatic white balancing method by color histogram stretching
CN113034509A (en) Image processing method and device
CN110782400A (en) Self-adaptive uniform illumination realization method and device
CN109583330B (en) Pore detection method for face photo
KR20020031630A (en) Method for extraction of face using distortion data of color
CN113409221B (en) Image color matting method, system, computer equipment and storage medium
CN106295679B (en) A kind of color image light source colour estimation method based on category correction
CN110298812B (en) Image fusion processing method and device
CN111861899A (en) Image enhancement method and system based on illumination nonuniformity
Fursov et al. Correction of distortions in color images based on parametric identification
Assefa et al. Correction of over-exposure using color channel correlations

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20211119

Address after: 518000 1001, block D, building 5, software industry base, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant after: Shenzhen Wanxing Software Co.,Ltd.

Address before: 518000 1002, block D, building 5, software industry base, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN SIBO TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant