CN107230182B - Image processing method and device and storage medium - Google Patents
Image processing method and device and storage medium Download PDFInfo
- Publication number
- CN107230182B CN107230182B CN201710657280.7A CN201710657280A CN107230182B CN 107230182 B CN107230182 B CN 107230182B CN 201710657280 A CN201710657280 A CN 201710657280A CN 107230182 B CN107230182 B CN 107230182B
- Authority
- CN
- China
- Prior art keywords
- image
- quantile
- alpha channel
- pixel point
- mask image
- 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
Links
- 238000003672 processing method Methods 0.000 title abstract description 19
- 238000012545 processing Methods 0.000 claims abstract description 81
- 238000000034 method Methods 0.000 claims description 38
- 230000002829 reductive effect Effects 0.000 claims description 19
- 230000009467 reduction Effects 0.000 claims description 5
- 238000001514 detection method Methods 0.000 claims description 4
- 238000005286 illumination Methods 0.000 abstract description 21
- 230000000694 effects Effects 0.000 abstract description 18
- 230000008859 change Effects 0.000 abstract description 12
- 238000004422 calculation algorithm Methods 0.000 description 35
- 230000008569 process Effects 0.000 description 17
- 230000006870 function Effects 0.000 description 16
- 238000010586 diagram Methods 0.000 description 13
- 238000005516 engineering process Methods 0.000 description 12
- 230000015654 memory Effects 0.000 description 12
- 238000004891 communication Methods 0.000 description 6
- 238000004364 calculation method Methods 0.000 description 5
- 230000001413 cellular effect Effects 0.000 description 4
- 230000000873 masking effect Effects 0.000 description 4
- 239000003086 colorant Substances 0.000 description 3
- 230000036039 immunity Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000005260 corrosion Methods 0.000 description 2
- 230000007797 corrosion Effects 0.000 description 2
- 230000010339 dilation Effects 0.000 description 2
- 238000005315 distribution function Methods 0.000 description 2
- 230000003628 erosive effect Effects 0.000 description 2
- 230000004927 fusion Effects 0.000 description 2
- 230000000670 limiting effect Effects 0.000 description 2
- 238000006748 scratching Methods 0.000 description 2
- 230000002393 scratching effect Effects 0.000 description 2
- 230000005236 sound signal Effects 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000003321 amplification Effects 0.000 description 1
- 230000015572 biosynthetic process Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000007599 discharging Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000004880 explosion Methods 0.000 description 1
- 230000005484 gravity Effects 0.000 description 1
- 238000009499 grossing Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 238000003199 nucleic acid amplification method Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000036961 partial effect Effects 0.000 description 1
- 230000008447 perception Effects 0.000 description 1
- 238000012805 post-processing Methods 0.000 description 1
- 238000010079 rubber tapping Methods 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000010897 surface acoustic wave method Methods 0.000 description 1
- 238000003786 synthesis reaction Methods 0.000 description 1
- 230000002123 temporal effect Effects 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/14—Transformations for image registration, e.g. adjusting or mapping for alignment of images
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/50—Image enhancement or restoration using two or more images, e.g. averaging or subtraction
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/12—Edge-based segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/194—Segmentation; Edge detection involving foreground-background segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10016—Video; Image sequence
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20172—Image enhancement details
- G06T2207/20192—Edge enhancement; Edge preservation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20212—Image combination
- G06T2207/20221—Image fusion; Image merging
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Processing (AREA)
Abstract
The embodiment of the invention discloses an image processing method, an image processing device and a storage medium, which are used for eliminating large-area noise caused by illumination environment change and achieving the effect of self-adaption noise resistance. The embodiment of the invention provides an image processing method, which comprises the following steps: carrying out green curtain cutout processing on the obtained current image frame to obtain a first mask image, wherein the first mask image comprises: a first foreground target image and a first background curtain image; adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image; and replacing the second background curtain image in the second mask image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image.
Description
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an image processing method, an image processing apparatus, and a storage medium.
Background
In the prior art, image frames based on a green curtain background are often subjected to matting processing, and then the background of the image frames is replaced. In the technology, foreground information and background information in a video or a picture need to be separated, and the separated foreground needs to be synthesized into another background, so that the technology is widely applied to the field of video editing and video segmentation.
For the scheme of replacing the foreground with the background, the prior art adopts a video matting technology under a green screen background, also called a green screen matting algorithm, and the technology mainly absorbs the color of a green component in a picture as transparent color and removes other color components from the picture, so that the background is transparent, and the superposition and synthesis of two layers of pictures are formed. Thus, the character shot by the common camera is combined with various background pictures after being scratched, and the effect of replacing the background can be achieved.
The green screen matting algorithm provided by the prior art has high requirements on the flatness of a green screen background on site, the color uniformity of the green screen background and illumination environment conditions. This is because the existing green screen matting algorithm method does not consider whether the green screen is flat, whether the green screen background color is uniform, and whether the illumination environment condition is appropriate when processing the acquired video or picture. If one or more of the above conditions do not satisfy the requirements when the picture is shot, the boundary of the image to be scratched is not smooth enough, in the process of scratching, the lighting environment is not ideal due to the light, and then noise exists in the image obtained by the green curtain scratching algorithm, so that the edge part of the foreground is not smooth enough, the sudden change is irregular, and further the final output image contains noise, so that the image looks fake and is not natural enough.
In summary, the green-curtain matting algorithm provided by the prior art is affected by the change of the illumination environment, which may cause noise in the final output image. In particular, it is not effective for large-area noise generated by illumination variation.
Disclosure of Invention
The embodiment of the invention provides an image processing method, an image processing device and a storage medium, which are used for eliminating large-area noise caused by illumination environment change and achieving the effect of self-adaption noise resistance.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
in a first aspect, an embodiment of the present invention provides an image processing method, including:
carrying out green curtain cutout processing on the obtained current image frame to obtain a first mask image, wherein the first mask image comprises: a first foreground target image and a first background curtain image;
adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image;
and replacing the second background curtain image in the second mask image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image.
In a second aspect, an embodiment of the present invention further provides an apparatus for processing an image, including:
the green curtain processing module is used for carrying out green curtain cutout processing on the obtained current image frame to obtain a first mask image, and the first mask image comprises: a first foreground target image and a first background curtain image;
an alpha channel adjusting module, configured to adjust an alpha channel component of each pixel point in the first mask image according to a preset quantile parameter, to obtain a second mask image, where the second mask image includes: a second foreground target image and a second background curtain image;
and the background replacement module is used for replacing the second background curtain image in the second mask image with a preset background template image and outputting an image result obtained by fusing the second foreground target image and the background template image.
In a third aspect of the present application, a computer-readable storage medium is provided, having stored therein instructions, which, when run on a computer, cause the computer to perform the method of the above-described aspects.
According to the technical scheme, the embodiment of the invention has the following advantages:
in the embodiment of the present invention, first, a green screen matting process is performed on an acquired current image frame to obtain a first mask image, where the first mask image includes: a first foreground object image and a first background curtain image. Then, adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image. And finally, replacing the second background curtain image in the second shade image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image. In the embodiment of the invention, the quantile parameters can be used for adjusting the alpha channel component of each pixel point in the first mask image, so that the alpha channel component of each pixel point can be adjusted according to the quantile parameters, the change of the illumination environment can be sensed, and particularly, the self-adaptive anti-noise effect can be achieved on large-area noise generated by the illumination change.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings.
Fig. 1 is a schematic flow chart diagram of an image processing method according to an embodiment of the present invention;
fig. 2 is a schematic view of an application scenario of an image processing process according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an unsmooth matting boundary caused by an illumination environment after background replacement is performed on an image frame in the prior art;
fig. 4 is a schematic diagram of an image result generated after the image processing method provided by the embodiment of the present invention performs background replacement on the image frame shown in fig. 3;
FIG. 5-a is a schematic diagram of an image processing apparatus according to an embodiment of the present invention;
fig. 5-b is a schematic structural diagram illustrating an alpha channel adjustment module according to an embodiment of the present invention;
fig. 5-c is a schematic structural diagram illustrating an alpha channel adjustment module according to another embodiment of the present invention;
FIG. 5-d is a schematic diagram of another image processing apparatus according to an embodiment of the present invention;
FIG. 5-e is a schematic diagram of another image processing apparatus according to an embodiment of the present invention;
FIG. 5-f is a schematic diagram of another image processing apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a terminal to which the image processing method according to the embodiment of the present invention is applied.
Detailed Description
The embodiment of the invention provides an image processing method, an image processing device and a storage medium, which are used for eliminating large-area noise caused by illumination environment change and achieving the effect of self-adaption noise resistance.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments that can be derived by one skilled in the art from the embodiments given herein are intended to be within the scope of the invention.
The terms "comprises" and "comprising," and any variations thereof, in the description and claims of this invention and the above-described drawings are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The following are detailed below.
The embodiment of the image processing method can be particularly applied to the background replacement of a single picture or the real-time background replacement in a live video scene. The image frame provided by the embodiment of the invention can be an RGB image, wherein RGB is the color representing three channels of red, green and blue, so that 3 channels exist, and the 3 channels display the proportion of the three primary colors of the current picture. Referring to fig. 1, a method for processing an image according to an embodiment of the present invention includes the following steps:
101. carrying out green screen matting processing on the obtained current image frame to obtain a first mask image, wherein the first mask image comprises: a first foreground object image and a first background curtain image.
The image frame may be a frame of image obtained from a single picture or a frame of image obtained from a live video, and the processing procedure of each frame of image may refer to the description in the embodiment herein, and then, for example, processing of the obtained current image frame is taken as an example, where the current image frame may be one or more currently obtained image frames, and for example, the current image frame may be obtained by acquiring an image frame output from live video software or reading the image frame from a memory of the mobile terminal. After the current image frame is obtained, the image frame is processed by adopting a green curtain matting algorithm, so that an initial Mask (Mask) image can be obtained, the initial Mask image is defined as a 'first Mask image' for distinguishing Mask images obtained after the image is operated under different subsequent scenes, the original image can be divided into a foreground image and a background image by a green curtain matting algorithm, the foreground is used for representing an image of a foreground object, the background is used for representing an image of a background curtain, a first mask image can be generated by the green curtain matting algorithm (also called as a green curtain algorithm), the first mask image may be separated into two parts of a first foreground object image and a first background mask image, the first foreground object image is an image including a foreground object in the current image frame, and the first background curtain image is an image including a curtain area in the current image frame. In practical applications, there are various green curtain matting algorithms that can be adopted in the embodiment of the present invention, which are described as follows: the original input video or image is processed by a green screen algorithm to obtain an initial Mask, wherein the green screen algorithm can be selected from a plurality of algorithms, such as a high quality chroma key (high chroma key) algorithm, a seriously algorithm, and the like.
In the embodiment of the present invention, the image frame may include a foreground object and a background, and in this embodiment, the foreground object is focused on, so that in the embodiment of the present invention, a green-screen region may be specifically set, and only an image portion corresponding to the set green-screen region in the video image is captured for processing.
The image processing method in the embodiment of the invention can be suitable for live video. Firstly, the video image of the current frame is collected for processing, and then the processed video image is played after the image processing is finished in the embodiment of the invention. When the current frame video image is played, the next frame video image can be processed, so that each frame video image in the video is continuously processed and played, and live broadcast after the whole video image matting processing is completed. It should be noted that, since the processing of each frame of video image is the same, in this embodiment, only one image frame is taken as an example, and other image frames can be processed by referring to this method.
In some embodiments of the present invention, before the step 101 performs green-curtain matting on the acquired current image frame to obtain the first mask image, the image processing method provided in the embodiments of the present invention may further include the following steps, in addition to performing the step 101:
and A1, carrying out reduction processing on each pixel point in the current image frame to obtain the reduced current image frame.
Wherein, in order to improve the processing speed to the image, before carrying out the green curtain cutout processing to current image frame, can also see to reduce the processing to this current image frame earlier to obtain the current image frame after reducing, through the processing of reducing to image frame, can reduce image processing's time complexity, improve image speed, all need carry out the efficiency handled to every image frame under being applicable to the live scene of video. The image reduction processing method adopted by the embodiment of the invention can be various, for example, each image frame can be reduced in a spatial pyramid mode, or each image frame can be directly reduced to a fixed size in an image cutting mode, so that each reduced image frame can be obtained.
In the implementation scenario of executing step a1, step 101 performs green-curtain matting on the obtained current image frame, which may specifically include the following steps:
and B1, performing green screen matting processing on the reduced current image frame.
After the current image frame is obtained, the current image frame is reduced to obtain the reduced current image frame, then the reduced current image frame is subjected to green curtain matting, and the processing speed of the green curtain matting can be improved through image reduction processing.
102. Adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image.
In the embodiment of the present invention, a first mask image may be obtained through the green-curtain matting processing, where the first mask image may include a first foreground object image and a first background curtain image, and in the matting process, due to light, the color and shade of the curtain may be uneven, so that noise exists in the first mask image obtained by the green-curtain matting algorithm. In order to solve the technical problem, in the embodiment of the present invention, the gray value of each pixel point in the first mask image needs to be adjusted, because the gray values of the first mask image obtained by the green curtain algorithm at the foreground target are not all 1 and the gray values at the background curtain are not all 0 due to the difference between the curtain color and the light environment, the gray value of each pixel point needs to be adjusted according to the quantile parameter pre-configured in the embodiment of the present invention. The quantile parameter is a parameter for adjusting an alpha channel component of the pixel point, so that a gray value between 0 and 1 is adjusted to be 0 or 1, and the quantile parameter can be obtained according to a first mask image generated by a green curtain algorithm. Wherein, Alpha (Alpha) channel is an 8-bit gray scale channel, which records transparency information in an image with 256 levels of gray scale, and defines transparent, opaque and translucent areas, wherein black represents transparent, and Alpha channel component takes a value of 0. White indicates opaque and the Alpha channel component takes the value 1. The grey scale indicates translucency and the Alpha channel component has a value between 0 and 1.
Next, the quantile parameter preset in the embodiment of the present invention is illustrated, and the distribution function of the continuous random variable X is f (X), and the density function is p (X). Then, for any p of 0<1, X, which is called f (X) ═ p, is the quantile of this distribution, or the lower quantile. In short, a fractional number refers to a point in a continuous distribution function, and one side of the point corresponds to the probability p. The quantile parameter configured in the embodiment of the present invention may include an upper quantile and a lower quantile, the quantile parameter may be obtained by the upper quantile and the lower quantile, the quantile parameter may be used to adjust the alpha channel component of each pixel in the first mask image, so that the alpha channel component of each pixel in the first mask image may be re-valued according to the quantile parameter, the gray value between 0 and 1 is adjusted to 0 or 1 by the quantile parameter, the alpha channel component of all pixels in the first mask image may be adjusted to obtain a second mask image, and the second mask image includes: and in a similar way, the first background curtain image can generate the second background curtain image after the alpha channel component adjustment is performed on the first foreground target image according to the quantile parameter.
In some embodiments of the present invention, the step 102 of adjusting an alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image includes:
c1, respectively detecting an upper quantile and a lower quantile on the first mask image;
c2, determining quantile parameters according to the upper quantile and the lower quantile, wherein the quantile parameters comprise: a gray scale interval consisting of a gray scale upper limit and a gray scale lower limit, wherein the gray scale upper limit is an upper quantile, and the gray scale lower limit is a lower quantile;
and C3, adjusting the alpha channel component of each pixel point in the first mask image to be in the gray scale interval respectively, and forming a second mask image by all the adjusted pixel points.
After the first mask image is acquired, detecting the upper quantile H and the lower quantile L of the first mask image. For example, if H corresponds to a 90% quantile, the gray value of at least 90% of the pixels in the first mask image is smaller than H; similarly, assuming that L corresponds to a 10% quantile, the gray values in the first mask image that are ranked at the 10 th% are L. It should be noted that the upper quantile and the lower quantile may be set according to different image frames, for example, according to the color of the curtain and the illumination condition of the image frames, the upper quantile and the lower quantile may be set reasonably to achieve better effects, for example, the best effect is achieved by 90% upper quantile and 10% lower quantile. After an upper quantile and a lower quantile of the first mask image are obtained, quantile parameters are determined according to the upper quantile and the lower quantile, and the quantile parameters comprise: and the gray scale interval consists of a gray scale upper limit and a gray scale lower limit, wherein the gray scale upper limit is an upper quantile, and the gray scale lower limit is a lower quantile. Finally, the alpha channel component of each pixel point in the first mask image may be respectively adjusted to the gray scale interval, for example, for the alpha channel component of the original pixel point in the first mask image located in the gray scale interval, no adjustment may be made, for the alpha channel component of the original pixel point in the first mask image located outside the gray scale interval, the alpha channel components of the pixel points may be reduced or enlarged in value, so that the adjusted alpha channel component is located in the gray scale interval, and then all the pixel points after adjustment form the second mask image.
Further, in some embodiments of the present invention, the step C3 of adjusting the alpha channel component of each pixel point in the first mask image to be within the gray scale interval respectively includes:
c31, judging whether the alpha channel component of each pixel point is larger than the upper limit of the gray value and smaller than the lower limit of the gray value;
c32, if the alpha channel component of the pixel point before adjustment is larger than the upper limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the upper limit of the gray value; or,
c33, if the alpha channel component of the pixel point before adjustment is smaller than the lower limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the lower limit of the gray value; or,
and C34, if the alpha channel vector of the pixel point is greater than or equal to the lower limit of the gray value and less than or equal to the upper limit of the gray value, keeping the value of the alpha channel component of the pixel point unchanged.
Wherein, after the step of performing the judgment at the step C31, which step or steps of the steps C32, C33 and C34 to perform is determined according to the obtained judgment result. In step C32, when the alpha channel component of the pixel before adjustment is greater than the upper limit of the gray scale value, it indicates that the alpha channel component of the pixel is no longer within the interval of the gray scale value, and at this time, the value of the alpha channel component may be reduced to the upper limit of the gray scale value. When the alpha channel component of the pixel point in step C33 is smaller than the lower limit of the gray scale value, it indicates that the alpha channel component of the pixel point is no longer within the interval of the gray scale value, and at this time, the value of the alpha channel component may be increased to the lower limit of the gray scale value. Specifically, in the foregoing embodiment, the alpha channel component of each pixel point may be adjusted by the following calculation formula:
V2=max(L,min(V1,H)),
wherein, V1Alpha channel component, V, representing pixels before adjustment2And the alpha channel component of the pixel point after adjustment is represented, min represents a function with a smaller value taken from two numerical values, max represents a function with a larger value taken from two numerical values, H represents an upper limit of the gray value, and L represents a lower limit of the gray value.
For example, assume that H corresponds to a 90% quantile, L corresponds to a 10% quantile, and V1The corresponding alpha channel component is 0.95, min (V) is passed1H) can be 0.9, then max (L, min (V)1H)) can give V2The corresponding alpha channel component is 0.9. In another example, V1The corresponding alpha channel component is 0.05, min (V) is passed1H) can be 0.05, and max (L, min (V) is passed1H)) can give V2The corresponding alpha channel component is 0.1.
Further, in other embodiments of the present invention, after the step C3 adjusts the alpha channel component of each pixel point in the first mask image to be within the gray scale interval, the step 102 further includes:
c4, performing linear stretching processing on alpha channel components of all the pixel points in the gray scale interval.
After the alpha channel component of each pixel point in the first mask image is adjusted to the gray scale interval, the completely adjusted alpha channel component of each pixel point can be linearly stretched, the finally output alpha channel component is between 0 and 1, and the second mask image can be generated after the linear stretching processing is completed.
Further, in some embodiments of the present invention, the step C4 performs linear stretching processing on the alpha channel components of all the pixels in the gray scale interval, including:
c41, acquiring the interval length of the gray interval according to the upper limit and the lower limit of the gray value;
and C42, increasing the value of the alpha channel component of each pixel point according to the interval length of the gray value interval and the lower limit of the gray value.
And subtracting the upper limit of the gray value and the lower limit of the gray value to obtain the interval length of the gray interval. In step C42, the interval length of the gray value interval is the stretching measurement reference value of the linear stretching process, and the lower limit of the gray value is used as the starting point of the stretching process, that is, the component part exceeding the lower limit of the gray value in the alpha channel component of the pixel point is subjected to value amplification, so that the value of the alpha channel component of each pixel point can be increased. Examples are as follows:
performing linear stretching processing on the alpha channel component of each pixel point by the following calculation formula:
V3=(V2-L)/(H-L),
wherein, V2Alpha channel component, V, representing pixel points before stretching3And (3) showing the alpha channel component of the stretched pixel point, wherein H shows the upper limit of the gray value, and L shows the lower limit of the gray value.
For example, assume that H corresponds to a 90% quantile, L corresponds to a 10% quantile, and V1The corresponding alpha channel component is 0.95, min (V) is passed1H) can be 0.9, then max (L, min (V)1H) can give V2The corresponding alpha channel component is 0.9, and then V is set2By substituting the value of (V) into the above formula2V can be calculated by-L)/(H-L)3Equal to 1, so a linear stretching process of the pixel points can be achieved.
103. And replacing the second background curtain image in the second shade image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image.
In the embodiment of the present invention, after the second mask image is generated in step 102, after the alpha channel component in the second mask image is adjusted based on the quantile parameter, the noise influence caused by the illumination environment condition can be overcome, the background replacement can be performed based on the second mask image, that is, the second background curtain image in the second mask image can be replaced by the preset background template image, the second background curtain image in the second mask image is replaced by the background template image, the background template image can be fused with the second foreground target image in the second mask image, at this time, the image result obtained by fusing the second foreground target image and the background template image can be output, the image result is an image obtained by performing noise correction and background replacement according to the current image frame, and the image result is displayed to the user by using the background template image, so that the user can observe a picture or a live video using the background template image.
In some embodiments of the present invention, after the step 102 adjusts the alpha channel component of each pixel point in the first mask image according to the preset quantile parameter to obtain the second mask image, the image processing method provided in the embodiment of the present invention may further include the following steps, in addition to the step 103:
d1, performing an opening operation process on the second mask image, and/or performing a closing operation process on the second mask image.
Before step 103 is executed, in order to further reduce image noise, the second mask image may be subjected to an open operation process, or the second mask image may be subjected to a close operation process, or the second mask image may be subjected to an open operation process and a close operation process. As an example, the opening operation on the image is to erode and then expand, and the opening operation is performed on the image to remove the background hole noise. The closed operation of the image is to expand and then corrode, and the image is closed to remove the void noise of the foreground. Wherein, the concrete operation of corrosion is: each pixel in the image is scanned with a structuring element (e.g., 3 x 3 in size), and each pixel in the structuring element is anded with its overlying pixels, and if both are 1, the pixel is 1, otherwise 0, and if there is a point in the center and field that is not a black point, the point is eroded to a white point, the erosion operation being to take a minimum value within 8 fields of pixels. The specific operation of the expansion is as follows: each pixel in the image is scanned with a structuring element (e.g., 3 x 3 in size), and each pixel in the structuring element is anded with its overlying pixel, which is 0 if both are 0, and 1 otherwise. The dilation operation is to take a maximum value within 8 fields of pixels.
In some embodiments of the present invention, after the step 102 adjusts the alpha channel component of each pixel point in the first mask image according to the preset quantile parameter to obtain the second mask image, the image processing method provided in the embodiment of the present invention may further include the following steps, in addition to the step 103:
e1, performing gaussian blurring on the second mask image by using a preset gaussian kernel.
The specific gaussian kernel can be selected according to different application scenarios, so that the final effect is that edge aliasing is not obvious and the edge is not too fuzzy.
It should be noted that, in the implementation scenario of performing the foregoing step D1 and performing step E1, after the opening operation processing, the closing operation processing, and the gaussian blur processing are completed on the second mask image, step 103 is performed to perform background replacement, so that the image noise in the output image result can be further reduced.
As can be seen from the description of the embodiment of the present invention in the above embodiment, first, a first masking image is obtained by performing green-shade matting on an acquired current image frame, where the first masking image includes: a first foreground object image and a first background curtain image. Then, adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image. And finally, replacing the second background curtain image in the second shade image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image. In the embodiment of the invention, the quantile parameters can be used for adjusting the alpha channel component of each pixel point in the first mask image, so that the alpha channel component of each pixel point can be adjusted according to the quantile parameters, the change of the illumination environment can be sensed, and particularly, the self-adaptive anti-noise effect can be achieved on large-area noise generated by the illumination change.
In order to better understand and implement the above-mentioned schemes of the embodiments of the present invention, the following description specifically illustrates corresponding application scenarios.
In the green curtain algorithm provided by the embodiment of the invention, the image frame is subjected to the green curtain algorithm to obtain a mask image, wherein the whole white (alpha is 1.0) at a certain position of the mask represents a foreground, the whole black (alpha is 0.0) at a certain position of the mask represents a background, the gray (alpha is between 0 and 1) at a certain position of the mask represents translucency, and the original video frame and the background are fused according to the mask to obtain final output. In the process, due to the fact that light causes uneven color and shade of the curtain, and noise exists in the mask, the embodiment of the invention provides a green curtain anti-noise scheme, quantiles of each image frame can be detected, time complexity of an algorithm is in direct proportion to the size of the image, the quantiles of the mask in a space pyramid are detected after the image frames are subjected to space pyramid processing, the time complexity can be reduced, the value of the mask is adjusted in real time according to the quantiles, the part close to the foreground is directly pulled to be the foreground, the part close to the background is directly pulled to be the background, and accordingly green curtain noise is relieved. When the green screen algorithm provided by the embodiment of the invention is applied to video live broadcasting, real-time performance is required, so that the image is expected to be reduced in proportion to ensure certain precision, and meanwhile, the time complexity is reduced.
The embodiment of the invention aims to utilize global information to realize self-adaptive noise resistance. Global information is utilized to achieve adaptive noise immunity. In the embodiment of the invention, the upper quantile (such as 90%) and the lower quantile (such as 10%) of the mask corresponding to each frame can be calculated, and the original mask is dynamically adjusted according to the mask value, so that large-area noise caused by the change of the illumination environment can be eliminated. The embodiment of the invention has the characteristics of strong adaptability, strong noise resistance and low time complexity.
In the embodiment of the invention, the green screen technology has many application scenes, such as weather forecast, news live broadcast, movie special effects and the like, a host or an actor only needs to normally move in front of a pure-color screen (generally, a green screen and a blue screen), and the color supported by the screen is related to the selected green screen matting algorithm. The embodiment of the invention can be matched with different green screen algorithms to realize real-time noise resistance. After the camera takes a picture or a video, the foreground is extracted through the processing of the green curtain algorithm, and the foreground can be fused with various wanted backgrounds, so that a live picture of a real person in various virtual scenes appears. In addition, in the live broadcast field of the video of comparing the fire explosion at present, the anchor only needs to arrange a green screen at home, selects the background scene that oneself wanted through application, just can promote the visual effect of live broadcast of video, promotes the object for appreciation nature of live broadcast software.
In the embodiment of the invention, the quality of the fusion result of the green curtain technology is very dependent on the processing of noise, and if large-area noise exists in the finally fused video, the sense can be seriously influenced. Therefore, the green screen noise-resistant technology is the central importance of the whole green screen technology. As shown in fig. 2, a flowchart of an application scenario provided in the embodiment of the present invention includes the following specific steps:
1. after a video or an image is originally input, a current image frame can be obtained, and an initial mask is obtained through a green screen algorithm. The green curtain algorithm can be selected from a plurality of algorithms, such as high quality chromakey, seriously, and the like.
2. For the initial mask, its upper quantile H and lower quantile L are detected. Assuming that H corresponds to a 90% quantile, the gray value of at least 90% of pixel points in the mask is smaller than H; similarly, assuming that L corresponds to a 10% quantile, the gray values in mask that are ranked at 10% are L. The upper quantile and the lower quantile can be reasonably set according to different videos, curtain colors (green curtain, blue curtain and red curtain) and illumination conditions so as to achieve a better effect. The universal effect of 90% upper quantile and 10% lower quantile is the best in the experiment. The calculation of quantiles has the same temporal complexity as the calculation of medians o (mn logk), where M, N is the length and width of the video frame or image, respectively, and K is the several largest number, e.g., K0.1M N for a 10% quantile. If the requirement on the frame rate of the video is high, a spatial pyramid can be constructed for the mask (for example, an algorithm interface in opengl is adopted, and quantiles are detected by using a reduced version of the mask.
3. Has an upper partAfter the digit H and the lower quantile L, the mask needs to be adjusted to achieve the purpose of noise reduction. The adjustment is performed pixel by pixel, assuming that the original gray value of a certain pixel is V1Then the adjustment algorithm is as follows:
V2=max(L,min(V1,H)),
V3=(V2-L)/(H-L),
wherein, V1Alpha channel component, V, representing pixels before adjustment2And the alpha channel component of the pixel point after adjustment is represented, min represents a function with a smaller value taken from two numerical values, max represents a function with a larger value taken from two numerical values, H represents an upper limit of the gray value, and L represents a lower limit of the gray value. V3And (3) showing the alpha channel component of the stretched pixel point, wherein H shows the upper limit of the gray value, and L shows the lower limit of the gray value.
The purpose of the adjustment in the embodiment of the invention is to set H as an upper gray limit and L as a lower gray limit, and perform linear stretching on the gray value in the region, so that the obtained final output gray value alpha is between 0 and 1.
4. Opening the mask, namely expanding and corroding to remove background cavity noise; and a closing operation, i.e. corrosion first and then expansion, for removing the hole noise of the foreground. The dilation operation is to take the maximum value in the 8 fields of the pixel and the erosion operation is to take the minimum value in the 8 fields of the pixel. Wherein, can select 3 x 3 around a certain pixel point 9 points altogether, except that central pixel 8 points are 8 fields.
5. And selecting proper Gaussian kernel to carry out Gaussian blur on the mask for smoothing and local noise resistance. Corresponding Gaussian kernels can be selected according to different application scenes, so that the final effect is that edge sawtooth is not obvious, and the edge is not too fuzzy.
Without limitation, in the foregoing technical solution, the order of using the anti-noise technique (switching operation, gaussian blur, etc.) and the real-time quantile adjustment may be exchanged, that is, step 4 and step 5 may be performed first, and then step 2 and step 3 may be performed.
6. And fusing the original video frame and the replaced background according to the mask to obtain final video output, wherein a fusion formula is as follows:
rbg=foreground*alpha+background*(1-alpha)。
wherein background is a background template image, and forkround is a foreground target image.
In the foregoing illustration, the mask quantile calculation is performed in real time by step 2, and the mask gray scale adjustment according to the quantile is performed by step 3. The two steps are very necessary for noise immunity of the green curtain, because the gray value of the mask obtained by the green curtain algorithm at the foreground portrait is not all 1 and the gray value of the mask obtained by the green curtain algorithm at the background green curtain is not all 0 due to different curtain colors and light environments, the embodiment of the invention is a post-processing algorithm and aims to achieve the noise immunity effect by matching with various green curtain algorithms. Whereas in practice it is desirable that only at the edges of the foreground and background will have values between 0 and 1. If the distance between the non-edge and 0 or 1 is large, large area noise which is easy to be distinguished by naked eyes can be generated, as shown in fig. 3, which is a schematic diagram of unsmooth cutout boundary caused by illumination environment after image frame background replacement in the prior art, as can be known from fig. 3, noise is formed at the position where the cutout boundary of the foreground object is fuzzy, fig. 3 is a schematic illustration of fuzzy cutout boundary, the diagonal line part shown in fig. 3 is a background curtain, in fig. 3, there are situations of image fuzzy and not smooth enough line edge for the cutout boundary, fig. 4 is a schematic diagram of image result generated after image frame shown in fig. 3 is replaced by the image processing method provided by the embodiment of the invention, by using the scheme provided by the embodiment of the invention, the large area noise which is generated due to non-edge area alpha between 0-1 can be adaptively adjusted according to curtain color and illumination environment, FIG. 4 is a schematic illustration of continuous and smooth matting boundary according to an embodiment of the present invention, where the matting boundary in FIG. 4 has smooth line edge and does not have the problem of image blur of the matting boundary. The scheme provided by the embodiment of the invention fully considers the global pixel information, has real-time perception capability on the curtain color and the global illumination environment, and can achieve the self-adaptive anti-noise effect. Meanwhile, the scheme provided by the embodiment of the invention has the characteristic of low time complexity, can be used by matching with various green curtain algorithms, and can be adjusted according to the requirements of users besides setting the optimal values (10% and 90%) of quantiles so as to achieve better effect.
By the embodiment of the invention, the noise tolerance of the green screen technology can be higher, the finally output fused video has less noise and good effect.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
To facilitate a better implementation of the above-described aspects of embodiments of the present invention, the following also provides relevant means for implementing the above-described aspects.
Referring to fig. 5-a, an image processing apparatus 500 according to an embodiment of the present invention includes: a green curtain processing module 501, an alpha channel adjusting module 502, a background replacing module 503, wherein,
the green screen processing module 501 is configured to perform green screen matting on the obtained current image frame to obtain a first mask image, where the first mask image includes: a first foreground target image and a first background curtain image;
an alpha channel adjusting module 502, configured to adjust an alpha channel component of each pixel point in the first mask image according to a preset quantile parameter, to obtain a second mask image, where the second mask image includes: a second foreground target image and a second background curtain image;
a background replacement module 503, configured to replace the second background curtain image in the second mask image with a preset background template image, and output an image result obtained by fusing the second foreground target image and the background template image.
In some embodiments of the present invention, referring to fig. 5-b, the alpha channel adjustment module 502 comprises:
a quantile detection module 5021, configured to detect an upper quantile and a lower quantile for the first mask image, respectively;
a quantile parameter determining module 5022, configured to determine quantile parameters according to the upper quantile and the lower quantile, where the quantile parameters include: a gray level interval consisting of a gray level upper limit and a gray level lower limit, wherein the gray level upper limit is the upper quantile and the gray level lower limit is the lower quantile;
the gray value adjusting module 5023 is configured to adjust the alpha channel component of each pixel in the first mask image to the gray range, and all the adjusted pixels form a second mask image.
Further, as shown in fig. 5-c, the alpha channel adjusting module 502 further includes: a stretching module 5024, configured to perform linear stretching processing on the alpha channel components of all the pixels in the gray scale interval after the gray scale value adjusting module 5023 adjusts the alpha channel component of each pixel in the first mask image to the gray scale interval.
In some embodiments of the present invention, the gray value adjusting module 5023 is specifically configured to determine whether an alpha channel component of each pixel point is greater than the upper limit of the gray value and is less than the lower limit of the gray value; if the alpha channel component of the pixel point before adjustment is larger than the upper limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the upper limit of the gray value; or if the alpha channel component of the pixel point before adjustment is smaller than the lower limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the lower limit of the gray value; or if the alpha channel vector of the pixel point is greater than or equal to the lower limit of the gray value and less than or equal to the upper limit of the gray value, keeping the value of the alpha channel component of the pixel point unchanged.
In some embodiments of the present invention, the stretching module 5024 is specifically configured to obtain an interval length of the grayscale interval according to the upper grayscale value limit and the lower grayscale value limit; and increasing the value of the alpha channel component of each pixel point according to the interval length of the gray value interval and the lower limit of the gray value.
In some embodiments of the present invention, referring to fig. 5-d, the apparatus 500 for processing an image further includes: a scaling module 504, configured to perform scaling processing on each pixel point in the current image frame before the green-screen processing module 501 performs green-screen matting processing on the obtained current image frame, so as to obtain a scaled current image frame;
the green screen processing module 501 is specifically configured to perform green screen matting on the reduced current image frame.
In some embodiments of the present invention, referring to fig. 5-e, the apparatus 500 for processing an image may further include: an image operation module 505, configured to adjust the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter by the alpha channel adjustment module 502 to obtain a second mask image, and then perform an opening operation on the second mask image, and/or perform a closing operation on the second mask image.
In some embodiments of the present invention, referring to fig. 5-f, the apparatus 500 for processing an image may further include: a gaussian blur processing module 506, configured to, after the alpha channel adjusting module 502 adjusts an alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, perform gaussian blur processing on the second mask image by using a preset gaussian core.
As can be seen from the description of the embodiment of the present invention in the above embodiment, first, a first masking image is obtained by performing green-shade matting on an acquired current image frame, where the first masking image includes: a first foreground object image and a first background curtain image. Then, adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image. And finally, replacing the second background curtain image in the second shade image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image. In the embodiment of the invention, the quantile parameters can be used for adjusting the alpha channel component of each pixel point in the first mask image, so that the alpha channel component of each pixel point can be adjusted according to the quantile parameters, the change of the illumination environment can be sensed, and particularly, the self-adaptive anti-noise effect can be achieved on large-area noise generated by the illumination change.
As shown in fig. 6, for convenience of description, only the parts related to the embodiment of the present invention are shown, and details of the specific technology are not disclosed, please refer to the method part of the embodiment of the present invention. The terminal may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a vehicle-mounted computer, etc., taking the terminal as the mobile phone as an example:
fig. 6 is a block diagram illustrating a partial structure of a mobile phone related to a terminal provided in an embodiment of the present invention. Referring to fig. 6, the handset includes: radio Frequency (RF) circuit 1010, memory 1020, input unit 1030, display unit 1040, sensor 1050, audio circuit 1060, wireless fidelity (WiFi) module 1070, processor 1080, and power source 1090. Those skilled in the art will appreciate that the handset configuration shown in fig. 6 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile phone in detail with reference to fig. 6:
The memory 1020 can be used for storing software programs and modules, and the processor 1080 executes various functional applications and data processing of the mobile phone by operating the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 1020 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 1030 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also referred to as a touch screen, may collect touch operations by a user (e.g., operations by a user on or near the touch panel 1031 using any suitable object or accessory such as a finger, a stylus, etc.) and drive corresponding connection devices according to a preset program. Alternatively, the touch panel 1031 may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 1080, and can receive and execute commands sent by the processor 1080. In addition, the touch panel 1031 may be implemented by various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The input unit 1030 may include other input devices 1032 in addition to the touch panel 1031. In particular, other input devices 1032 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a track ball, a mouse, a joystick, or the like.
The display unit 1040 may be used to display information input by a user or information provided to the user and various menus of the cellular phone. The Display unit 1040 may include a Display panel 1041, and optionally, the Display panel 1041 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch panel 1031 can cover the display panel 1041, and when the touch panel 1031 detects a touch operation on or near the touch panel 1031, the touch operation is transmitted to the processor 1080 to determine the type of the touch event, and then the processor 1080 provides a corresponding visual output on the display panel 1041 according to the type of the touch event. Although in fig. 6, the touch panel 1031 and the display panel 1041 are two independent components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 1031 and the display panel 1041 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 1050, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1041 according to the brightness of ambient light, and the proximity sensor may turn off the display panel 1041 and/or the backlight when the mobile phone moves to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
WiFi belongs to short-distance wireless transmission technology, and the mobile phone can help the user to send and receive e-mail, browse web pages, access streaming media, etc. through the WiFi module 1070, which provides wireless broadband internet access for the user. Although fig. 6 shows the WiFi module 1070, it is understood that it does not belong to the essential constitution of the handset, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 1080 is a control center of the mobile phone, connects various parts of the whole mobile phone by using various interfaces and lines, and executes various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 1020 and calling data stored in the memory 1020, thereby integrally monitoring the mobile phone. Optionally, processor 1080 may include one or more processing units; preferably, the processor 1080 may integrate an application processor, which handles primarily the operating system, user interfaces, applications, etc., and a modem processor, which handles primarily the wireless communications. It is to be appreciated that the modem processor described above may not be integrated into processor 1080.
The handset also includes a power source 1090 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 1080 via a power management system to manage charging, discharging, and power consumption via the power management system.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which are not described herein.
In the embodiment of the present invention, the processor 1080 included in the terminal further has a flow of a processing method for controlling and executing the above image executed by the terminal.
It should be noted that the above-described embodiments of the apparatus are merely schematic, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present invention may be implemented by software plus necessary general hardware, and may also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components and the like. Generally, functions performed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same functions may be various, such as analog circuits, digital circuits, or dedicated circuits. However, the implementation of a software program is a more preferable embodiment for the present invention. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a readable storage medium, such as a floppy disk, a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk of a computer, and includes instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
In summary, the above embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the above embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the above embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (11)
1. A method of processing an image, comprising:
carrying out green curtain cutout processing on the obtained current image frame to obtain a first mask image, wherein the first mask image comprises: a first foreground target image and a first background curtain image;
adjusting the alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, wherein the second mask image comprises: a second foreground target image and a second background curtain image;
replacing the second background curtain image in the second mask image with a preset background template image, and outputting an image result obtained by fusing the second foreground target image and the background template image;
wherein, the adjusting the alpha channel component of each pixel point in the first mask image according to the preset quantile parameter to obtain a second mask image comprises:
the upper quantile H corresponds to the quantile of the first preset value, and the lower quantile L corresponds to the quantile of the second preset value; determining quantile parameters according to the upper quantile H and the lower quantile L, wherein the quantile parameters comprise: a gray level interval consisting of a gray level upper limit and a gray level lower limit, wherein the gray level upper limit is the upper quantile H, and the gray level lower limit is the lower quantile L; adjusting alpha channel components of each pixel point in the first mask image into the gray scale interval respectively, and forming a second mask image by all the adjusted pixel points;
wherein, the adjusting the alpha channel component of each pixel point in the first mask image into the gray scale interval respectively comprises:
judging whether the alpha channel component of each pixel point is larger than the upper limit of the gray value and is smaller than the lower limit of the gray value; if the alpha channel component of the pixel point before adjustment is larger than the upper limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the upper limit of the gray value; if the alpha channel component of the pixel point before adjustment is smaller than the lower limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the lower limit of the gray value; and if the alpha channel vector of the pixel point is greater than or equal to the lower limit of the gray value and less than or equal to the upper limit of the gray value, keeping the value of the alpha channel component of the pixel point unchanged.
2. The method of claim 1, wherein after adjusting alpha channel components of each pixel in the first mask image to be within the gray scale interval, further comprising:
and performing linear stretching treatment on alpha channel components of all the pixel points in the gray scale interval.
3. The method of claim 2, wherein the linear stretching of the alpha channel components of all the pixels in the gray scale interval comprises:
acquiring the interval length of the gray interval according to the upper gray value limit and the lower gray value limit;
and increasing the value of the alpha channel component of each pixel point according to the interval length of the gray value interval and the lower limit of the gray value.
4. A method as claimed in any one of claims 1 to 3, wherein after the adjusting alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, the method further comprises:
and carrying out opening operation processing on the second mask image, and/or carrying out closing operation processing on the second mask image.
5. A method as claimed in any one of claims 1 to 3, wherein after the adjusting alpha channel component of each pixel point in the first mask image according to a preset quantile parameter to obtain a second mask image, the method further comprises:
and performing Gaussian blur processing on the second mask image by using a preset Gaussian core.
6. The method according to any one of claims 1 to 3, wherein before performing the green-shade matting on the acquired current image frame to obtain the first mask image, the method further comprises:
carrying out reduction processing on each pixel point in the current image frame to obtain a reduced current image frame;
the processing of green curtain cutout is carried out to current image frame obtained, include:
and carrying out green curtain matting processing on the reduced current image frame.
7. An apparatus for processing an image, comprising:
the green curtain processing module is used for carrying out green curtain cutout processing on the obtained current image frame to obtain a first mask image, and the first mask image comprises: a first foreground target image and a first background curtain image;
an alpha channel adjusting module, configured to adjust an alpha channel component of each pixel point in the first mask image according to a preset quantile parameter, to obtain a second mask image, where the second mask image includes: a second foreground target image and a second background curtain image;
the background replacement module is used for replacing the second background curtain image in the second mask image with a preset background template image and outputting an image result obtained by fusing the second foreground target image and the background template image;
the alpha channel adjustment module comprises:
the quantile detection module is used for determining an upper quantile H and a lower quantile L, wherein the upper quantile H corresponds to the quantile of a first preset value, and the lower quantile L corresponds to the quantile of a second preset value;
a quantile parameter determination module, configured to determine quantile parameters according to the upper quantile H and the lower quantile L, where the quantile parameters include: a gray level interval consisting of a gray level upper limit and a gray level lower limit, wherein the gray level upper limit is the upper quantile H, and the gray level lower limit is the lower quantile L;
the gray value adjusting module is used for adjusting alpha channel components of all pixel points in the first mask image into the gray range respectively, and all the adjusted pixel points form a second mask image;
the gray value adjusting module is specifically configured to determine whether an alpha channel component of each pixel point is greater than the upper limit of the gray value and is less than the lower limit of the gray value; if the alpha channel component of the pixel point before adjustment is larger than the upper limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the upper limit of the gray value; if the alpha channel component of the pixel point before adjustment is smaller than the lower limit of the gray value, adjusting the alpha channel component of the pixel point before adjustment to the lower limit of the gray value; and if the alpha channel vector of the pixel point is greater than or equal to the lower limit of the gray value and less than or equal to the upper limit of the gray value, keeping the value of the alpha channel component of the pixel point unchanged.
8. The apparatus of claim 7, wherein the alpha channel adjustment module further comprises: and the stretching module is used for performing linear stretching processing on the alpha channel components of all the pixels in the gray scale interval after the gray scale value adjusting module respectively adjusts the alpha channel components of each pixel in the first mask image into the gray scale interval.
9. The apparatus according to claim 8, wherein the stretching module is specifically configured to obtain an interval length of the grayscale interval according to the upper grayscale value limit and the lower grayscale value limit; and increasing the value of the alpha channel component of each pixel point according to the interval length of the gray value interval and the lower limit of the gray value.
10. The apparatus according to any one of claims 7 to 9, wherein the apparatus for processing the image further comprises: the zooming module is used for carrying out zooming-out processing on each pixel point in the current image frame before the green-screen processing module carries out green-screen matting processing on the obtained current image frame so as to obtain a zoomed-out current image frame;
and the green screen processing module is specifically used for carrying out green screen matting processing on the reduced current image frame.
11. A computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the method of any of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710657280.7A CN107230182B (en) | 2017-08-03 | 2017-08-03 | Image processing method and device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710657280.7A CN107230182B (en) | 2017-08-03 | 2017-08-03 | Image processing method and device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107230182A CN107230182A (en) | 2017-10-03 |
CN107230182B true CN107230182B (en) | 2021-11-09 |
Family
ID=59958126
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710657280.7A Active CN107230182B (en) | 2017-08-03 | 2017-08-03 | Image processing method and device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107230182B (en) |
Families Citing this family (22)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108171677B (en) * | 2017-12-07 | 2023-03-24 | 腾讯科技(深圳)有限公司 | Image processing method and related equipment |
CN108124194B (en) * | 2017-12-28 | 2021-03-12 | 北京奇艺世纪科技有限公司 | Video live broadcast method and device and electronic equipment |
CN110853071A (en) * | 2018-08-21 | 2020-02-28 | Tcl集团股份有限公司 | Image editing method and terminal equipment |
CN109285160B (en) * | 2018-08-29 | 2022-08-02 | 成都品果科技有限公司 | Image matting method and system |
WO2020062898A1 (en) * | 2018-09-26 | 2020-04-02 | 惠州学院 | Video foreground target extraction method and apparatus |
CN109413338A (en) * | 2018-09-28 | 2019-03-01 | 北京戏精科技有限公司 | A kind of method and system of scan picture |
CN109544587A (en) * | 2018-10-31 | 2019-03-29 | 深圳变设龙信息科技有限公司 | A kind of FIG pull handle method, apparatus and terminal device |
CN110136163B (en) * | 2019-04-29 | 2021-02-12 | 中国科学院自动化研究所 | Hand motion fuzzy automatic cutout and application in human body soft segmentation and background replacement |
CN112700513B (en) * | 2019-10-22 | 2024-10-22 | 阿里巴巴集团控股有限公司 | Image processing method and device |
CN110956592B (en) * | 2019-11-14 | 2023-07-04 | 北京达佳互联信息技术有限公司 | Image processing method, device, electronic equipment and storage medium |
CN111208521B (en) * | 2020-01-14 | 2021-12-07 | 武汉理工大学 | Multi-beam forward-looking sonar underwater obstacle robust detection method |
CN112129345A (en) * | 2020-09-14 | 2020-12-25 | 安徽军松现代农业科技有限公司 | Soil monitoring's environmental monitoring system based on data acquisition |
CN112102219B (en) * | 2020-11-10 | 2021-02-09 | 卡莱特(深圳)云科技有限公司 | Method and device for picking image-text in image |
CN112235520B (en) * | 2020-12-07 | 2021-05-04 | 腾讯科技(深圳)有限公司 | Image processing method and device, electronic equipment and storage medium |
CN112561906B (en) * | 2020-12-24 | 2024-08-02 | 百果园技术(新加坡)有限公司 | Image processing method, device, equipment and medium |
CN112752038B (en) * | 2020-12-28 | 2024-04-19 | 广州虎牙科技有限公司 | Background replacement method, device, electronic equipment and computer readable storage medium |
WO2022188056A1 (en) * | 2021-03-10 | 2022-09-15 | 深圳市大疆创新科技有限公司 | Method and device for image processing, and storage medium |
CN113382276A (en) * | 2021-06-09 | 2021-09-10 | 湖南快乐阳光互动娱乐传媒有限公司 | Picture processing method and system |
CN117085322B (en) * | 2021-06-24 | 2024-09-10 | 腾讯科技(深圳)有限公司 | Interactive observation method, device, equipment and medium based on virtual scene |
CN116168076A (en) * | 2021-11-24 | 2023-05-26 | 腾讯科技(深圳)有限公司 | Image processing method, device, equipment and storage medium |
CN117152192A (en) * | 2022-05-24 | 2023-12-01 | 腾讯科技(深圳)有限公司 | Image processing method, apparatus, device, storage medium, and program product |
CN117522717B (en) * | 2024-01-03 | 2024-04-19 | 支付宝(杭州)信息技术有限公司 | Image synthesis method, device and equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1635294A1 (en) * | 2004-09-10 | 2006-03-15 | Avid Technology, Inc. | Graphical user interface for a keyer |
CN105100646A (en) * | 2015-08-31 | 2015-11-25 | 北京奇艺世纪科技有限公司 | Video processing method and device |
CN105654436A (en) * | 2015-12-24 | 2016-06-08 | 广东迅通科技股份有限公司 | Backlight image enhancement and denoising method based on foreground-background separation |
CN105678724A (en) * | 2015-12-29 | 2016-06-15 | 北京奇艺世纪科技有限公司 | Background replacing method and apparatus for images |
CN105681686A (en) * | 2015-12-31 | 2016-06-15 | 北京奇艺世纪科技有限公司 | Image processing method and system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101764914B (en) * | 2008-12-10 | 2011-07-27 | 新奥特(北京)视频技术有限公司 | Method of alpha channel boundary corrosion |
CN105120185B (en) * | 2015-08-27 | 2018-05-04 | 新奥特(北京)视频技术有限公司 | A kind of video image is scratched as method and apparatus |
-
2017
- 2017-08-03 CN CN201710657280.7A patent/CN107230182B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1635294A1 (en) * | 2004-09-10 | 2006-03-15 | Avid Technology, Inc. | Graphical user interface for a keyer |
CN105100646A (en) * | 2015-08-31 | 2015-11-25 | 北京奇艺世纪科技有限公司 | Video processing method and device |
CN105654436A (en) * | 2015-12-24 | 2016-06-08 | 广东迅通科技股份有限公司 | Backlight image enhancement and denoising method based on foreground-background separation |
CN105678724A (en) * | 2015-12-29 | 2016-06-15 | 北京奇艺世纪科技有限公司 | Background replacing method and apparatus for images |
CN105681686A (en) * | 2015-12-31 | 2016-06-15 | 北京奇艺世纪科技有限公司 | Image processing method and system |
Non-Patent Citations (2)
Title |
---|
Learning matte extraction in green screen images with MLP classifiers and the back-propagation algorithm;Roberto Rosas-Romero et al;《 2016 International Conference on Electronics, Communications and Computers (CONIELECOMP)》;20160324;第148-155页 * |
影视后期制作中AE抠像技术的教学研究;周娟;《中国优秀硕士学位论文全文数据库电子期刊 信息科技辑》;20160315;第2016年卷(第3期);第I138-6553页 * |
Also Published As
Publication number | Publication date |
---|---|
CN107230182A (en) | 2017-10-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107230182B (en) | Image processing method and device and storage medium | |
CN107230192B (en) | Image processing method, image processing device, computer-readable storage medium and mobile terminal | |
US10810720B2 (en) | Optical imaging method and apparatus | |
CN107038715B (en) | Image processing method and device | |
CN105809647B (en) | Automatic defogging photographing method, device and equipment | |
CN107438163B (en) | Photographing method, terminal and computer readable storage medium | |
CN107507160B (en) | Image fusion method, terminal and computer readable storage medium | |
CN107451979B (en) | Image processing method, device and storage medium | |
CN108038836B (en) | Image processing method and device and mobile terminal | |
CN108111754B (en) | Method for determining image acquisition mode and mobile terminal | |
CN109361867B (en) | Filter processing method and mobile terminal | |
CN108200421B (en) | White balance processing method, terminal and computer readable storage medium | |
CN108459799B (en) | Picture processing method, mobile terminal and computer readable storage medium | |
CN110868544B (en) | Shooting method and electronic equipment | |
CN111885307B (en) | Depth-of-field shooting method and device and computer readable storage medium | |
CN108200352B (en) | Method, terminal and storage medium for adjusting picture brightness | |
CN108198150B (en) | Method for eliminating image dead pixel, terminal and storage medium | |
CN109697698B (en) | Low illuminance enhancement processing method, apparatus and computer readable storage medium | |
CN109104578B (en) | Image processing method and mobile terminal | |
CN109544441B (en) | Image processing method and device, and skin color processing method and device in live broadcast | |
CN109639981B (en) | Image shooting method and mobile terminal | |
CN110944163A (en) | Image processing method and electronic equipment | |
CN114333001A (en) | Image processing method, intelligent terminal and storage medium | |
CN112598678A (en) | Image processing method, terminal and computer readable storage medium | |
CN108449560B (en) | Video recording method and terminal |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |