CN111415367A - Method and device for removing image background - Google Patents

Method and device for removing image background Download PDF

Info

Publication number
CN111415367A
CN111415367A CN202010191058.4A CN202010191058A CN111415367A CN 111415367 A CN111415367 A CN 111415367A CN 202010191058 A CN202010191058 A CN 202010191058A CN 111415367 A CN111415367 A CN 111415367A
Authority
CN
China
Prior art keywords
image
test image
coordinate position
same coordinate
pixel points
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.)
Pending
Application number
CN202010191058.4A
Other languages
Chinese (zh)
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.)
Beijing Qiwei Visual Media Technology Co ltd
Original Assignee
Beijing Qiwei Visual Media Technology 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 Beijing Qiwei Visual Media Technology Co ltd filed Critical Beijing Qiwei Visual Media Technology Co ltd
Priority to CN202010191058.4A priority Critical patent/CN111415367A/en
Publication of CN111415367A publication Critical patent/CN111415367A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Abstract

The application provides a method and a device for removing an image background, wherein the method comprises the following steps: acquiring a reference image and a test image; analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively; comparing color parameters of pixel points at the same coordinate position in the reference image and the test image; under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are the same, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as the value for expressing the transparent channel; and under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as the value for representing the non-transparent channel. The background of the test image is the same as that of the reference image, the background is not limited, and the complexity of obtaining the reference image and the test image is reduced.

Description

Method and device for removing image background
Technical Field
The present application relates to the field of image processing, and in particular, to a method and an apparatus for removing an image background.
Background
The image usually has background and foreground, at present, the background in the image can be removed by means of matting, wherein the matting technology is widely used in the television and film industries, the term "matting" is obtained from early television production, and English is called "Key", which means that a certain color in the image is absorbed as transparent color, so that the color is scratched from the picture to make the background transparent. Specifically, the color to be used as the transparent color may be a color range specified in advance, in the pixels of the image to be scratched, the pixels with the color within the color range are used as background pixels, and the corresponding Alpha channel value is set to 1.
At present, the background of the image to be scratched is not usually a dedicated background color, and therefore, it is usually necessary to convert the background color of the image to be scratched into a dedicated background color (for example, pure blue or pure green), and to implement background removal by the above-mentioned scratching technology.
However, obtaining the image to be scratched with a special background color requires building related devices and apparatuses to build a special background color environment, and requires professional lighting to capture an image for background removal, i.e., the image for background removal has a high complexity.
Disclosure of Invention
The application provides a method and a device for removing an image background, and aims to solve the problem of low efficiency of obtaining an image with a background removed.
In order to achieve the above object, the present application provides the following technical solutions:
the application provides a method for removing an image background, which comprises the following steps:
acquiring a reference image and a test image; the reference image is an image obtained by shooting a background; the test image is obtained by shooting the background and the object to be reserved;
analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively;
comparing the color parameters of the pixel points at the same coordinate position in the reference image and the test image;
setting the value of an Alpha channel of the pixel point at the same coordinate position in the test image as a value for representing a transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are the same;
and under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as the value for representing the non-transparent channel to obtain the test image with the background removed.
Optionally, the color parameter of any pixel point is each component of the pixel point in the YUV color space;
comparing the color parameters of the pixel points at any same coordinate position in the reference image and the test image, wherein the comparing comprises the following steps:
comparing whether the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not;
under the condition that the Y components are the same, comparing whether the U components and the V components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not;
and under the condition that the U component and the V component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same.
Optionally, after the comparing whether the Y components in the color parameters of the pixel points at the same coordinate position of the reference image and the test image are the same, the method further includes:
and under the condition that the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different.
Optionally, under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as a value for representing a non-transparent channel, and after obtaining the test image after removing the background, the method further includes:
receiving a background image to be synthesized;
and synthesizing the background image to be synthesized and the test image with the background removed to obtain a synthesized image.
Optionally, under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as a value for representing a non-transparent channel, and after obtaining the test image after removing the background, the method further includes:
and outputting the test image with the background removed.
The present application further provides an image background removing apparatus, including:
the acquisition module is used for acquiring a reference image and a test image; the reference image is an image obtained by shooting a background; the test image is obtained by shooting the background and the object to be reserved;
the analysis storage module is used for analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively;
the comparison module is used for comparing the color parameters of the pixel points at the same coordinate position in the reference image and the test image;
the first processing module is used for setting the value of an Alpha channel of a pixel point at the same coordinate position in the test image as a value for representing a transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are the same;
and the second processing module is used for setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for representing the non-transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, so as to obtain the test image with the background removed.
Optionally, the color parameter of any pixel point is each component of the pixel point in the YUV color space;
the comparison module is configured to compare the color parameters of the pixel points at any one of the same coordinate positions in the reference image and the test image, and includes:
the comparison module is specifically configured to compare whether the Y components in the color parameters of the pixel points at the same coordinate position of the reference image and the test image are the same;
under the condition that the Y components are the same, comparing whether the U components and the V components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not;
and under the condition that the U component and the V component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same.
Optionally, after the comparing module is configured to compare whether the Y component in the color parameter of the pixel point of the same coordinate position of the reference image and the test image is the same, the comparing module is further configured to:
and under the condition that the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different.
Optionally, the apparatus further comprises:
the synthesis module is used for setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for representing the non-transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different by the second processing module, and receiving a background image to be synthesized after the test image with the background removed is obtained; and synthesizing the background image to be synthesized and the test image with the background removed to obtain a synthesized image.
Optionally, the apparatus further comprises:
and the output module is used for setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for representing a non-transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different by the second processing module, and outputting the test image after the background is removed after the test image after the background is obtained.
In the method and the device for removing the image background, the reference image and the test image are obtained, the coordinate positions and the color parameters of all the pixel points in the reference image and the test image are analyzed and stored respectively, the color parameters of the pixel points in the same coordinate positions in the reference image and the test image are compared, and the value of the Alpha channel of the pixel points in the same coordinate positions in the test image is set as the value for representing the transparent channel under the condition that all components in the color parameters of the pixel points in the same coordinate positions in the reference image and the test image are the same. And under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as the value for representing the non-transparent channel to obtain the test image with the background removed.
In other words, in the present application, the background in the test image is determined by comparing the components of the color parameters at the same coordinate position in the test image and the reference image, so as to remove the background of the test image. Based on the removal mode of the test image background in the application, the reference image is an image obtained by shooting the background, and the test image is an image obtained by shooting the background and the object to be reserved, namely, the reference image and the test image only need to be the same as the background of the test image. The background can be any background required by actual conditions, and is not limited to a special background color in the prior art, so that related equipment and devices do not need to be set up, professional light does not need to be adopted for shooting, and compared with the complexity of acquiring images for background removal in the prior art, the complexity of acquiring reference images and test images for background removal is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a method for removing an image background according to an embodiment of the present disclosure;
FIG. 2(a) is a schematic diagram of a test image disclosed in an embodiment of the present application;
FIG. 2(b) is a schematic diagram of a reference image disclosed in an embodiment of the present application;
FIG. 2(c) is a schematic diagram of an image with background removed as disclosed in the embodiments of the present application;
FIG. 2(d) is a schematic diagram of a background image to be synthesized according to an embodiment of the present application;
FIG. 2(e) is a schematic diagram of a composite image disclosed in an embodiment of the present application;
FIG. 3 is a schematic diagram of comparing color parameters of a test image and a reference image and a channel processing method disclosed in an embodiment of the present application;
fig. 4 is a schematic structural diagram of an image background removing apparatus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 1 is a method for removing an image background according to an embodiment of the present application, including the following steps:
and S101, acquiring a reference image and a test image.
In the present embodiment, the reference image is an image obtained by shooting the background. The test image is an image taken of the background and the object to be retained.
Taking the test image as fig. 2(a) as an example, the object to be retained in fig. 2(a) is a person in fig. 2(a), and the background is provided in addition to the person. Based on the test image of fig. 2(a), the corresponding reference image is an image obtained by photographing only the background, as shown in fig. 2 (b).
And S102, analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively.
In this step, no matter the test image or the reference image, taking the test image as an example, the color parameter of any pixel point in the test image may be an R component, a G component, and a B component of the pixel point in an RGB color space, or may be a Y component, a U component, and a V component of the pixel point in a YUV color space.
Among them, a color standard in the RGB industry is obtained by changing three color channels of red (R), green (G) and blue (B) and superimposing them with each other, RGB represents the colors of the three channels of red, green and blue, and the standard almost includes all the colors that can be perceived by human vision, and is one of the most widely used color systems at present. YUV is a kind of compiled true-color space (colorspace), and the proper terms such as Y' UV, YUV, YCbCr, and YPbPr can be called YUV. Where the Y component represents brightness and the U and V components represent chroma.
In this step, the coordinate position of any pixel point, whether it is a test image or a reference image, represents the position of the pixel point in the image.
In this step, the coordinate position and the color parameter of each pixel point in the reference image are analyzed and stored, and the coordinate position and the color parameter of each pixel point in the test image are analyzed and stored. In the case of a reference image or a test image, taking the reference image as an example, a process of analyzing the color parameter of each pixel in the reference image is a process of determining the color parameter of each pixel in the reference image.
If the color parameters are R component, G component and B component in RGB, the process of analyzing the color parameters of each pixel point in the reference image is to determine the R component, G component and B component of each pixel point in the reference image, and if the reference image is not an RGB image, the R component, G component and B component of each pixel point in the reference image can be obtained through conversion, wherein the specific implementation process of the conversion is the prior art. If the color parameters are Y component, U component and V component in YUV color space, the process of analyzing the color parameters of each pixel point in the reference image is to determine the Y component, U component and V component of each pixel point in the reference image, if the reference image is not a YUV image, the Y component, U component and V component of each pixel point in the reference image can be obtained through conversion, wherein the specific implementation process of the conversion is the prior art.
The specific implementation manner of storage is the prior art, and is not described herein again.
S103, judging whether the color parameters of the pixel points at the same coordinate positions in the reference image and the test image are the same, if so, executing S104, and if not, executing S105.
In this embodiment, when the color parameter obtained in S102 is an R component, a G component, and a B component in an RGB color space, the process of comparing the color parameters of the pixel points at the same coordinate position in the reference image and the test image includes: determining whether the R component in the color parameter of the pixel point at the same coordinate position in the test image is the same as the R component in the color parameter of the pixel point at the same coordinate position in the reference image, and obtaining a comparison result of the R components; determining whether the G component in the color parameter of the pixel point at the same coordinate position in the test image is the same as the G component in the color parameter of the pixel point at the same coordinate position in the reference image, and obtaining a comparison result of the G component; and determining whether the B component in the color parameter of the pixel point at the same coordinate position in the test image is the same as the B component in the color parameter of the pixel point at the same coordinate position in the reference image, and obtaining a comparison result of the B component. And then, determining whether the color parameters of the pixel points at the same position in the test image and the reference image are the same or not based on the comparison result of the R component, the comparison result of the G component and the comparison result of the B component.
That is, when the color parameter obtained in S102 is an R component, a G component, and a B component in an RGB color space, the color parameter of the pixel point at any one same coordinate position in the reference image and the test image is compared, and the pixel point at the same coordinate position in the test image and the reference image needs to be obtained. Therefore, the amount of calculation is large.
In the case that the color parameters obtained in S102 are Y, U, and V components in the YUV color space, the step of comparing the color parameters of the pixel points at the same coordinate position in the reference image and the test image includes the following steps a1 to A3:
a1, comparing whether the Y component in the color parameter of the pixel point at the same coordinate position in the reference image and the test image is the same, if yes, executing A2, and if no, executing A3.
In this step, the Y component in the color parameter of the pixel point at the same coordinate position in the test image is compared with the Y component in the color parameter of the pixel point at the same coordinate position in the reference image to determine whether the Y components are the same. If so, step A2 is performed, and if not, step A3 is performed.
And A2, comparing whether the U component and the V component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not.
In this step, if the U component and the V score in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, it indicates that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, i.e. the pixel points of the same coordinate position in the test image are background pixel points. Otherwise, it indicates that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different, that is, the pixel points at the same coordinate position in the test image are foreground pixel points.
And A3, determining that the color parameters of the pixel points of the reference image and the test image at the same position coordinate are different.
And executing the step under the condition that the Y component in the color parameter of the pixel point at the same coordinate position in the test image is different from the Y component in the color parameter of the pixel point at the same coordinate position in the reference image, namely determining that the color parameters of the pixel points at the same coordinate position of the test image and the reference image are different, namely that the pixel point at the same coordinate position in the test image is a foreground pixel point.
Under the condition that the color parameters are Y component, U component and V component in YUV color space, if the Y component of any pixel point at the same coordinate position in the test image and the reference image is different, whether the U component and the V component are the same or not does not need to be compared, the color parameters of the pixel points at the same coordinate position in the test image and the reference image can be determined to be different, and compared with the RGB comparison mode, the calculated amount is reduced.
S104, setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for expressing the transparent channel.
In this embodiment, if all the components in the color parameters of the pixel points at the same coordinate position in the reference image and the test image are the same, it indicates that the pixel points at the same coordinate position in the reference image and the test image are background pixel points.
Therefore, in this step, the value of the Alpha Channel of the pixel point at the same coordinate position in the test image is set to be the value for representing the transparent Channel, and the test image with the background removed is obtained, wherein the Alpha Channel is an Alpha Channel (α Channel or Alpha Channel) which means the transparency and translucency of a picture.
And S105, setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for expressing the non-transparent channel.
In this step, the value of Alpha channel may be 0, which is used to represent the non-transparent channel.
For a more intuitive description of the specific implementation process of S103 to S105, a YUV color space is taken as an example, as shown in fig. 3. Specifically, a reference image (without a reserved article or person) is used as the master in fig. 3, image information for analyzing and storing the master includes a coordinate parameter and a color parameter of each pixel point in the reference image, a test image (with a reserved article or person) is used as a sub-slice in fig. 3, and image information for analyzing and storing the sub-slice includes a coordinate parameter and a color parameter of each pixel point in the test image.
And comparing the sub-film with the color parameters of the pixel points with the same coordinate parameters in the master mask, and segmenting and retaining the test image to achieve the image matting effect of removing the background. Specifically, the color parameter of the master plate is used as an image reference, the color parameter of each pixel point with the same coordinate parameter in the storage information of the master plate and the character piece is compared and judged, if the color parameter of any pixel point with the same coordinate parameter in the master plate is the same as that of the sub-piece, the pixel point in the master plate is judged to be a background, transparent channel processing is carried out, namely the corresponding Alpha channel value is set to be 1, and if the color parameter of any pixel point with the same coordinate parameter in the master plate is different from that of any pixel point with the same coordinate parameter in the sub-piece, the pixel point is used as a foreground pixel point.
From fig. 3, it can be seen that the master and the sub-sheets are composed of two colors, color 1 and color 2, wherein color 1 and color 2 are both represented by YUV color space. However, since the color parameters of each of a1, a2, a4, B1, B4, C3, C4, D1, D2, and D3 do not change in the master and the sub-sheets, the KEY image (determination result image) is determined to be a clear channel, the Alpha value is 1, and the KEY image is represented by a blank lattice. A3, B2, B3, C1, C2 and D4 have color parameter differences between the master plate and the sub-plate, the Alpha value is 0, the image is judged as a foreground image in the KEY image, and the image is represented by black grids in the KEY image.
Optionally, in this embodiment, the test image after background removal may also be output.
The test image processed in S104 to S105 is referred to as a background-removed test image.
In this embodiment, the test image after background removal may also be output when a preset output instruction is received.
Taking the test image as fig. 2(a) and the reference image as fig. 2(b) as an example, the image with the background removed obtained through S101 to S105 of this embodiment is shown in fig. 2 (c).
In this embodiment, after the test image with the background removed is obtained, since the object to be retained is retained in the test image with the background removed and the background becomes a transparent state, the required background can be added on the basis of the test image with the background removed, so as to obtain the composite image. For convenience of description, the background image to be added is referred to as a background image to be synthesized. Specifically, the process of generating the synthetic image includes steps B1 to B2:
and B1, receiving a background image to be synthesized.
Also taking the image after background removal shown in fig. 2(c) as an example, it is assumed that the background image to be synthesized is as shown in fig. 2 (d).
And B2, synthesizing the background image to be synthesized and the test image with the background removed to obtain a synthesized image.
In this step, a specific implementation process of synthesizing the background image to be synthesized and the test image with the background removed is the prior art, and is not described herein again.
If the image with the background removed is the image shown in fig. 2(c), and the background image to be synthesized is the image shown in fig. 2(d), the synthesized image obtained in this step is shown in fig. 2 (e).
It should be noted that the above-mentioned steps B1 to B2 are optional steps, and in practice, whether to execute the steps may be selected according to actual situations.
The embodiment has the following beneficial effects:
the beneficial effects are that:
because the background of the test image and the reference image is not limited in the embodiment, the embodiment can remove the background at any place, so that the method has no color limitation on clothes dressing and prop use in a pure color background environment which does not need to be professional in the film and television industry, and can remove the background at any time and any place.
The beneficial effects are that:
the image after the background is removed and the background image to be synthesized are synthesized to obtain the synthesized image, wherein the background of the synthesized image is the background of the background image to be synthesized, so that related program production can be carried out by matching with virtual studio equipment in the film and television industry, the method is simple and rapid, the decoration of the site and the cost investment of lighting equipment are greatly reduced, and meanwhile, the construction time of the program production site is saved.
The beneficial effects are three:
in this embodiment, the color parameter of the pixel point at the same coordinate position in the test image and the reference image is the component of the pixel point at the coordinate position in the YUV color space, and for the YUV color space, under the condition that the Y component of the pixel point at the same coordinate position in the reference image and the test image is different, it can be determined that the color parameters of the two pixels at the same coordinate position are different, so that the comparison speed can be increased in the process of comparing whether the color parameters of the pixel points at the same coordinate position in the test image and the reference image are the same.
Fig. 4 is a device for removing an image background according to an embodiment of the present application, including: an acquisition module 401, a parsing storage module 402, a comparison module 403, a first processing module 404 and a second processing module 405, wherein,
an obtaining module 401, configured to obtain a reference image and a test image; the reference image is an image obtained by shooting a background; the test image is obtained by shooting a background and an object to be reserved;
the analysis storage module 402 is used for analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively;
a comparing module 403, configured to compare color parameters of pixel points in the same coordinate position in the reference image and the test image;
a first processing module 404, configured to set, in a case that color parameters of pixel points at the same coordinate position in the reference image and the test image are the same, a value of an Alpha channel of a pixel point at the same coordinate position in the test image as a value used for representing a transparent channel;
the second processing module 405 is configured to, under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, set the value of the Alpha channel of the pixel point at the same coordinate position in the test image to a value used for representing a non-transparent channel, and obtain the test image with the background removed.
Optionally, the color parameter of any pixel point is each component of the pixel point in the YUV color space;
the comparing module 403 is configured to compare color parameters of pixel points in the same coordinate position in the reference image and the test image, and includes:
a comparing module 403, configured to specifically compare whether the Y components in the color parameters of the pixel points at the same coordinate position of the reference image and the test image are the same; under the condition that the Y components are the same, comparing whether the U components and the V components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not; and under the condition that the U component and the V component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same.
Optionally, after the comparing module 403 is configured to compare whether the Y component in the color parameter of the pixel point of the same coordinate position of the reference image and the test image is the same, the comparing module is further configured to:
and under the condition that the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different.
Optionally, the apparatus may further include:
a synthesizing module 406, configured to set, in the case that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, the value of the Alpha channel of the pixel point at the same coordinate position in the test image to a value used for representing a non-transparent channel, and receive a background image to be synthesized after obtaining the test image with the background removed; and synthesizing the background image to be synthesized and the test image with the background removed to obtain a synthesized image.
Optionally, the apparatus may further include:
the output module 407 is configured to, under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, set the value of the Alpha channel of the pixel point at the same coordinate position in the test image as a value used for representing a non-transparent channel, and output the test image after the background removal after the test image after the background removal is obtained.
The functions described in the method of the embodiment of the present application, if implemented in the form of software functional units and sold or used as independent products, may be stored in a storage medium readable by a computing device. Based on such understanding, part of the contribution to the prior art of the embodiments of the present application or part of the technical solution may be embodied in the form of a software product stored in a storage medium and including several instructions for causing a computing device (which may be a personal computer, a server, a mobile computing device or a network device) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for removing an image background is characterized by comprising the following steps:
acquiring a reference image and a test image; the reference image is an image obtained by shooting a background; the test image is obtained by shooting the background and the object to be reserved;
analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively;
comparing the color parameters of the pixel points at the same coordinate position in the reference image and the test image;
setting the value of an Alpha channel of the pixel point at the same coordinate position in the test image as a value for representing a transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are the same;
and under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as the value for representing the non-transparent channel to obtain the test image with the background removed.
2. The method of claim 1, wherein the color parameter of any pixel is the component of the pixel in YUV color space;
comparing the color parameters of the pixel points at any same coordinate position in the reference image and the test image, wherein the comparing comprises the following steps:
comparing whether the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not;
under the condition that the Y components are the same, comparing whether the U components and the V components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not;
and under the condition that the U component and the V component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same.
3. The method according to claim 2, further comprising, after comparing whether the Y component in the color parameters of the pixel points of the same coordinate position of the reference image and the test image is the same, the steps of:
and under the condition that the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different.
4. The method according to any one of claims 1 to 3, wherein under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as a value for representing a non-transparent channel, and after obtaining the test image after background removal, the method further comprises:
receiving a background image to be synthesized;
and synthesizing the background image to be synthesized and the test image with the background removed to obtain a synthesized image.
5. The method according to any one of claims 1 to 3, wherein under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, setting the value of the Alpha channel of the pixel points at the same coordinate position in the test image as a value for representing a non-transparent channel, and after obtaining the test image after background removal, the method further comprises:
and outputting the test image with the background removed.
6. An apparatus for removing an image background, comprising:
the acquisition module is used for acquiring a reference image and a test image; the reference image is an image obtained by shooting a background; the test image is obtained by shooting the background and the object to be reserved;
the analysis storage module is used for analyzing and storing the coordinate position and the color parameter of each pixel point in the reference image and the test image respectively;
the comparison module is used for comparing the color parameters of the pixel points at the same coordinate position in the reference image and the test image;
the first processing module is used for setting the value of an Alpha channel of a pixel point at the same coordinate position in the test image as a value for representing a transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are the same;
and the second processing module is used for setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for representing the non-transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different, so as to obtain the test image with the background removed.
7. The apparatus of claim 6, wherein the color parameter of any pixel is the components of the pixel in YUV color space;
the comparison module is configured to compare the color parameters of the pixel points at any one of the same coordinate positions in the reference image and the test image, and includes:
the comparison module is specifically configured to compare whether the Y components in the color parameters of the pixel points at the same coordinate position of the reference image and the test image are the same;
under the condition that the Y components are the same, comparing whether the U components and the V components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same or not;
and under the condition that the U component and the V component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are the same.
8. The apparatus according to claim 7, wherein after the comparing module is configured to compare whether the Y component in the color parameters of the pixel points of the reference image and the test image at the same coordinate position is the same, the comparing module is further configured to:
and under the condition that the Y components in the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different, determining that the color parameters of the pixel points of the reference image and the test image at the same coordinate position are different.
9. The apparatus of any one of claims 6 to 8, further comprising:
the synthesis module is used for setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for representing the non-transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different by the second processing module, and receiving a background image to be synthesized after the test image with the background removed is obtained; and synthesizing the background image to be synthesized and the test image with the background removed to obtain a synthesized image.
10. The apparatus of any one of claims 6 to 8, further comprising:
and the output module is used for setting the value of the Alpha channel of the pixel point at the same coordinate position in the test image as the value for representing a non-transparent channel under the condition that the color parameters of the pixel points at the same coordinate position in the reference image and the test image are different by the second processing module, and outputting the test image after the background is removed after the test image after the background is obtained.
CN202010191058.4A 2020-03-18 2020-03-18 Method and device for removing image background Pending CN111415367A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010191058.4A CN111415367A (en) 2020-03-18 2020-03-18 Method and device for removing image background

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010191058.4A CN111415367A (en) 2020-03-18 2020-03-18 Method and device for removing image background

Publications (1)

Publication Number Publication Date
CN111415367A true CN111415367A (en) 2020-07-14

Family

ID=71491129

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010191058.4A Pending CN111415367A (en) 2020-03-18 2020-03-18 Method and device for removing image background

Country Status (1)

Country Link
CN (1) CN111415367A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112053419A (en) * 2020-09-21 2020-12-08 长沙景嘉微电子股份有限公司 Image superposition processing method and device, storage medium and electronic device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030152285A1 (en) * 2002-02-03 2003-08-14 Ingo Feldmann Method of real-time recognition and compensation of deviations in the illumination in digital color images
JP2012124873A (en) * 2010-12-10 2012-06-28 Canon Inc Image processing system and image processing method
CN103366364A (en) * 2013-06-07 2013-10-23 太仓中科信息技术研究院 Color difference-based image matting method
CN105827998A (en) * 2016-04-14 2016-08-03 广州市英途信息技术有限公司 Image matting system and image matting method
CN106504264A (en) * 2016-10-27 2017-03-15 锐捷网络股份有限公司 Video foreground image extraction method and device
CN108961299A (en) * 2017-05-18 2018-12-07 北京金山云网络技术有限公司 A kind of foreground image preparation method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030152285A1 (en) * 2002-02-03 2003-08-14 Ingo Feldmann Method of real-time recognition and compensation of deviations in the illumination in digital color images
JP2012124873A (en) * 2010-12-10 2012-06-28 Canon Inc Image processing system and image processing method
CN103366364A (en) * 2013-06-07 2013-10-23 太仓中科信息技术研究院 Color difference-based image matting method
CN105827998A (en) * 2016-04-14 2016-08-03 广州市英途信息技术有限公司 Image matting system and image matting method
CN106504264A (en) * 2016-10-27 2017-03-15 锐捷网络股份有限公司 Video foreground image extraction method and device
CN108961299A (en) * 2017-05-18 2018-12-07 北京金山云网络技术有限公司 A kind of foreground image preparation method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112053419A (en) * 2020-09-21 2020-12-08 长沙景嘉微电子股份有限公司 Image superposition processing method and device, storage medium and electronic device
CN112053419B (en) * 2020-09-21 2023-09-22 长沙景嘉微电子股份有限公司 Image superposition processing method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
US11455516B2 (en) Image lighting methods and apparatuses, electronic devices, and storage media
US8311355B2 (en) Skin tone aware color boost for cameras
CN103366364B (en) A kind of stingy drawing method based on color distortion
WO2017008377A1 (en) Image processing method and terminal
CN103440674B (en) A kind of rapid generation of digital picture wax crayon specially good effect
CN106570850B (en) A kind of image interfusion method
CN111862110A (en) Green curtain image matting method, system, equipment and readable storage medium
CN105681775A (en) White balance method and device
WO2022042754A1 (en) Image processing method and apparatus, and device
CN113132696A (en) Image tone mapping method, device, electronic equipment and storage medium
CN111626967A (en) Image enhancement method, image enhancement device, computer device and readable storage medium
CN110335279A (en) Real-time green curtain is scratched as method, apparatus, equipment and storage medium
CN111415367A (en) Method and device for removing image background
CN112419218A (en) Image processing method and device and electronic equipment
CN110780961B (en) Method for adjusting character color of application interface, storage medium and terminal equipment
WO2015189369A1 (en) Methods and systems for color processing of digital images
CN109859303B (en) Image rendering method and device, terminal equipment and readable storage medium
CN108053452B (en) Digital image color extraction method based on mixed model
US20180367776A1 (en) Image processing apparatus
CN113099191B (en) Image processing method and device
CN105991937A (en) Virtual exposure method and device based on Bayer format image
CN114882126A (en) Image processing method, device, equipment and storage medium
CN110298783B (en) Image matting method and system
CN113507572A (en) Video picture display method, device, terminal and storage medium
CN104954892A (en) Method and device for showing video subject content

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