CN110070507B - Matting method and device for video image, storage medium and matting equipment - Google Patents

Matting method and device for video image, storage medium and matting equipment Download PDF

Info

Publication number
CN110070507B
CN110070507B CN201910309802.3A CN201910309802A CN110070507B CN 110070507 B CN110070507 B CN 110070507B CN 201910309802 A CN201910309802 A CN 201910309802A CN 110070507 B CN110070507 B CN 110070507B
Authority
CN
China
Prior art keywords
pixel point
pixel
color conversion
value
color
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910309802.3A
Other languages
Chinese (zh)
Other versions
CN110070507A (en
Inventor
朱玉荣
彭泽波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anhui Kelang Electronic Technology Co.,Ltd.
Original Assignee
Anhui Kelang Electronic 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 Anhui Kelang Electronic Technology Co ltd filed Critical Anhui Kelang Electronic Technology Co ltd
Priority to CN201910309802.3A priority Critical patent/CN110070507B/en
Publication of CN110070507A publication Critical patent/CN110070507A/en
Application granted granted Critical
Publication of CN110070507B publication Critical patent/CN110070507B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence

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 invention discloses a method and a device for matting video images, a storage medium and matting equipment, wherein the method comprises the following steps: acquiring the color of a target video image; converting the color of the target video image from a first color space to a second color space to obtain a color conversion result of the target video image; acquiring a color conversion error value of each pixel point of the target video image according to the color conversion result; correcting the color conversion error value by using an error diffusion algorithm; and performing video image matting on the target video image after the color conversion error value is corrected. The invention utilizes the error diffusion algorithm to process the color conversion error of the color of the target video image after space conversion, can effectively reduce the visual error of the target video image to human eyes, and is beneficial to the quick cutout processing of the target video image.

Description

Matting method and device for video image, storage medium and matting equipment
Technical Field
The invention relates to the technical field of video image processing, in particular to a video image matting method and device, a storage medium and matting equipment.
Background
The video image matting technique refers to a process of accurately separating a foreground object of interest from a background from a still image or a continuous video sequence. The video image matting technology is a key technology in the field of visual special effects, and is widely applied to the fields of video image editing, film making and the like.
In the existing video image matting method in the prior art, RGB pixels are mainly converted into a hexagonal pyramid model (HSV), and since color value domains of different pixels are different, a color conversion algorithm based on the HSV model is relatively fixed in a color conversion process of a video image, and when lightness V is relatively small or color saturation S is relatively small, component values of chromaticities H respectively corresponding to the pixels fluctuate relatively greatly, so that obvious visual differences are easily generated in a color conversion process of the RGB pixels, and once error values of current pixel points are accumulated more and more in a conversion process, a picture of the image is finally caused to generate local fine lines.
Disclosure of Invention
In view of this, an embodiment of the present invention provides a method for matting a video image, so as to solve the problem that in a matting method for a video image in the prior art, an obvious visual difference is easily generated in a process of performing color conversion on RGB pixels, and once an error value of a current pixel point is accumulated more and more in the conversion process, a picture of the image finally generates local fine lines.
According to a first aspect, an embodiment of the present invention provides a method for matting a video image, including the following steps:
acquiring the color of a target video image;
converting the color of the target video image from a first color space to a second color space to obtain a color conversion result of the target video image;
acquiring a color conversion error value of each pixel point of the target video image according to the color conversion result;
correcting the color conversion error value by using an error diffusion algorithm;
and performing video image matting on the target video image after the color conversion error value is corrected.
With reference to the first aspect, in a first embodiment of the first aspect, the first color space is an RGB color space, and the second color space is an HSV color space.
With reference to the first embodiment of the first aspect, in the second embodiment of the first aspect, the color conversion result of the target video image obtained by converting the color of the target video image from the first color space to the second color space is obtained by a color conversion algorithm of converting the RGB color space to the HSV color space.
With reference to the first aspect, in a third implementation manner of the first aspect, the step of correcting the color conversion error value by using an error diffusion algorithm further includes:
acquiring a first pixel point, a second pixel point and a third pixel point which are adjacent to a target pixel point of the target video image, wherein the first pixel point is positioned in a first direction of the target pixel point, the second pixel point is positioned in a second direction of the target pixel point, and the third pixel point is positioned in a third direction of the target pixel point;
obtaining the color conversion error value of the target pixel point;
setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point respectively;
and diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point according to the preset proportion rule to correct the color conversion error value.
With reference to the third implementation manner of the first aspect, in the fourth implementation manner of the first aspect, the step of diffusing the color conversion error value to the first pixel, the second pixel, and the third pixel according to the preset proportion rule to correct the color conversion error value further includes:
respectively acquiring a first color conversion error value, a second color conversion error value and a third color conversion error value of the target pixel point according to the color conversion result;
respectively acquiring a first pixel chromaticity conversion value, a second pixel chromaticity conversion value and a third pixel chromaticity conversion value of the target pixel point according to the color conversion result;
and correcting the first color conversion error value, the second color conversion error value and the third color conversion error value according to the preset proportion rule and the first pixel chromaticity conversion value, the second pixel chromaticity conversion value and the third pixel chromaticity conversion value.
With reference to the fourth implementation manner of the first aspect, in the fifth implementation manner of the first aspect, the step of correcting the first color conversion error value, the second color conversion error value, and the third color conversion error value according to the preset scaling rule and the first pixel chrominance conversion value, the second pixel chrominance conversion value, and the third pixel chrominance conversion value is corrected by the following formulas:
HR1=HR+D1*x/(x+y+z);
HG1=HG+D2*y/(x+y+z);
HB1=HB+D3*z/(x+y+z);
wherein HR1Correction of the conversion value for the first pixel chromaticity, HG1Correction of the conversion value for the second pixel chrominance, HB1Correction of the conversion value for the third pixel chromaticity, HRIs the first pixel chrominance conversion value, HGIs the second pixel chrominance conversion value, HBFor said third pixel chrominance conversion value, D1Converting the error value for the first color, D2For the second color conversion error value, D3And for the third color conversion error value, x is a first scale coefficient allocated to the first pixel point in the preset scale rule, y is a second scale coefficient allocated to the second pixel point in the preset scale rule, and z is a third scale coefficient allocated to the third pixel point in the preset rule.
With reference to the fifth implementation manner of the first aspect, in the sixth implementation manner of the first aspect, the step of setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point, and the third pixel point respectively further includes:
and distributing the first scaling factor, the second scaling factor and the third scaling factor according to an iterative algorithm until the first pixel chrominance conversion value, the second pixel chrominance conversion value and the third pixel chrominance conversion value reach a target state, and ending the iteration.
According to a second aspect, an embodiment of the present invention provides a matting device for video images, including:
the color acquisition module is used for acquiring the color of the target video image;
the color conversion module is used for converting the color of the target video image from a first color space to a second color space to obtain a color conversion result of the target video image;
an error value obtaining module, configured to obtain a color conversion error value of each pixel point of the target video image according to the color conversion result;
the error correction module is used for correcting the color conversion error value by using an error diffusion algorithm;
and the matting module is used for carrying out video image matting on the target video image after the color conversion error value is corrected.
According to a third aspect, an embodiment of the present invention provides a GPU-based matting device, including a memory, a GPU processor, and a computer program stored on the memory and executable on the GPU processor, where the GPU processor executes the program to perform the steps of the method for matting an image as described in the first aspect or any one of the embodiments of the first aspect.
According to a fourth aspect, an embodiment of the present invention provides a storage medium, on which computer instructions are stored, which when executed by a GPU processor, perform the steps of the method for matting images of images as described in the first aspect or any one of the embodiments of the first aspect.
The technical scheme of the embodiment of the invention has the following advantages:
the invention provides a method and a device for matting video images, a storage medium and matting equipment, wherein the method comprises the following steps: acquiring the color of a target video image; converting the color of the target video image from a first color space to a second color space to obtain a color conversion result of the target video image; acquiring a color conversion error value of each pixel point of the target video image according to the color conversion result; correcting the color conversion error value by using an error diffusion algorithm; and performing video image matting on the target video image after the color conversion error value is corrected. The invention utilizes the error diffusion algorithm to process the color conversion error of the color of the target video image after space conversion, can effectively reduce the visual error of the target video image to human eyes, and is beneficial to the quick cutout processing of the target video image.
Drawings
In order to more clearly illustrate the embodiments of the present invention 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, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a first flowchart of a method for matting a video image according to an embodiment of the present invention;
FIG. 2 is a second flowchart of a method for matting a video image according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating error diffusion performed on a target pixel in an embodiment of the present invention;
FIG. 4 is a fourth flowchart of a matting method for video images according to an embodiment of the present invention;
FIG. 5 is a first block diagram of a matting device for video images according to an embodiment of the invention;
FIG. 6 is a second block diagram of a matting device for video images according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a hardware structure of a GPU-based matting device in an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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 invention.
Example 1
The embodiment of the invention provides a video image matting method, which is operated in a GPU (graphics processing unit) processor, and the video image processing speed can be obviously improved by utilizing the GPU processor to process the video image, as shown in figure 1, the video image matting method comprises the following steps:
step S1: and acquiring the color of the target video image. The target video image is a video image to be subjected to matting, and colors are extracted from the target video image, so that color conversion is facilitated.
Step S2: and converting the color of the target video image from the first color space to the second color space to obtain a color conversion result of the target video image. The first color space is an RGB color space, the second color space is an HSV color space, and the conversion of the target video image from the RGB color space to the HSV color space is also widely applied in video image processing.
Specifically, the color of the target video image is converted from a first color space to a second color space, and the color conversion result of the target video image is obtained through a color conversion algorithm for converting an RGB color space to an HSV color space.
The color conversion algorithm in the above is:
max=max(R,G,B);
min=min(R,G,B);
if R=max,H=(G-B)/(max-min);
if G=max,H=2+(B-R)/(max-min);
if B=max,H=4+(R-G)/(max-min);
H=H*60 if H<0,H=H+360;
V=max(R,G,B);
S=(max-min)/max;
wherein R is a red pixel, G is a green pixel, and B is a blue pixel; h is a chrominance conversion value, although H also represents gray information, generally H is an angle value, which represents a position of a chrominance conversion value of a certain pixel point of the target video image, a difference between chrominance conversion values of a red pixel, a green pixel and a blue pixel in HSV space is 120 degrees, V is a lightness of the target video image in HSV color conversion space, generally V is in a range of 0-1, and S is a color saturation or a color purity of the target video image in HSV color conversion space, generally S is in a range of 0-1.
Step S3: and acquiring a color conversion error value of each pixel point of the target video image according to the color conversion result. The color conversion error value is a color conversion error value corresponding to each pixel point of the target video image in the process of color conversion. The target video image is colored from RGB according to the aboveObtaining a color conversion error value of a target video image from a color space converted to an HSV color space, setting the color conversion error value as D, wherein the color conversion error value comprises a first color conversion error value, a second color conversion error value and a third color conversion error value, the first color conversion error value is a red pixel conversion error value, the second color conversion error value is a green pixel conversion error value, the third color conversion error value is a blue pixel conversion error value, and the first color conversion error value is used as D1Expressing the second color conversion error value as D2Expressing the third color conversion error value as D3And (4) showing.
Step S4: and correcting the color conversion error value by using an error diffusion algorithm. Correcting the color conversion error value using the error diffusion algorithm is to transfer the color conversion error to the surrounding space.
In an embodiment, the step S4 may specifically include, as shown in fig. 2, the following steps in the execution process:
step S41: the method comprises the steps of obtaining a first pixel point, a second pixel point and a third pixel point which are adjacent to a target pixel point of a target video image, wherein the first pixel point is located in a first direction of the target pixel point, the second pixel point is located in a second direction of the target pixel point, and the third pixel point is located in a third direction of the target pixel point. As shown in fig. 3, the target pixel is O, the pixels adjacent to the target pixel are the first pixel L, the second pixel M and the third pixel N, it can be seen in fig. 3 that the first pixel point L, the second pixel point M and the third pixel point N are respectively located in different directions of the target pixel point O, the first pixel point L is located in the first direction of the target pixel point O, the second pixel point M is located in the second direction of the target pixel point O, the third pixel point N is located in the third direction of the target pixel point O, precisely, the first pixel point in the first direction is the pixel point on the right side of the target pixel point, the second pixel point in the second direction is the pixel point on the lower side of the target pixel point, the third pixel point in the third direction is the pixel point on the lower right side of the target pixel point, the pixel points respectively corresponding to the three different directions are usually adopted, and the diffusion of the color conversion error of the target pixel point.
Step S42: and acquiring a color conversion error value of the target pixel point. The color conversion error value of the target pixel point comprises a first color conversion error value of the target pixel point, the color conversion error value is set as D, the color conversion error value comprises a first color conversion error value, a second color conversion error value and a third color conversion error value, wherein the first color conversion error value is a red pixel conversion error value, the second color conversion error value is a green pixel conversion error value, the third color conversion error value is a blue pixel conversion error value, and the first color conversion error value is used as D1Expressing the second color conversion error value as D2Expressing the third color conversion error value as D3And (4) showing.
And step S43, setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point respectively.
In a preferred embodiment, the step S43 may specifically include:
and distributing a first proportional coefficient of the first pixel point, a second proportional coefficient of the second pixel point and a third proportional coefficient of the third pixel point according to an iterative algorithm until the first pixel chrominance conversion value, the second pixel chrominance conversion value and the third pixel chrominance conversion value reach the target state, and ending the iteration. For example: the first scaling factor is x, the second scaling factor is y, the third scaling factor is z, x: z is assigned in an iterative manner until a target state is reached, which is the first pixel chrominance conversion value being modified to a first pixel chrominance modification conversion value, the second pixel chrominance conversion value being modified to a second pixel chrominance modification conversion value, and the third pixel chrominance conversion value being modified to a third pixel chrominance modification conversion value, so that there is no apparent visual difference to the human eye. The first pixel chrominance conversion value is a red pixel chrominance conversion value and is represented by HRIndicating that the second pixel chrominance conversion value is a green pixel chrominance conversion value, denoted by HGIndicating that the third pixel chrominance conversion value is a blue pixel chrominance conversion value, denoted by HBIndicating that the first pixel chrominance correction conversion value is HR1Indicating that the second pixel chrominance correction conversion value is HG1Indicating that the third pixel chrominance correction conversion value is HB1And (4) showing. For example: for HR1=HR+D1X/(x + y + z); specifically, the iterative algorithm continuously tries to set the first proportionality coefficient of the first pixel point, the second proportionality coefficient of the second pixel point and the third proportionality coefficient of the third pixel point until HR1The correction effect of (2) is optimal.
Step S44: and diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point according to a preset proportion rule to correct the color conversion error value.
In an embodiment, the step S44 may specifically include, as shown in fig. 4, the following steps in the execution process:
step S441: and respectively obtaining a first color conversion error value, a second color conversion error value and a third color conversion error value of the target pixel point according to the color conversion result. The color conversion error value comprises a first color conversion error value of the target pixel point, and the color conversion error value is set as D, the color conversion error value comprises a first color conversion error value, a second color conversion error value and a third color conversion error value, wherein the first color conversion error value is a red pixel conversion error value, the second color conversion error value is a green pixel conversion error value, the third color conversion error value is a blue pixel conversion error value, and the first color conversion error value is set as D1Expressing the second color conversion error value as D2Expressing the third color conversion error value as D3And (4) showing.
Step S442: and respectively acquiring a first pixel chromaticity conversion value, a second pixel chromaticity conversion value and a third pixel chromaticity conversion value of the target pixel point according to the color conversion result. The first pixel chrominance conversion value is a red pixel chrominance conversion value and is represented by HRIndicating that the second pixel chrominance conversion value is a green pixel chrominance conversion value, denoted by HGIndicating that the third pixel chrominance conversion value is a blue pixel chrominance conversion value, denoted by HBAnd (4) showing.
Step S443: and correcting the first color conversion error value, the second color conversion error value and the third color conversion error value according to a preset proportion rule and the first pixel chrominance conversion value, the second pixel chrominance conversion value and the third pixel chrominance conversion value.
In an embodiment, the step S443 is executed and can be modified by the following formula:
HR1=HR+D1*x/(x+y+z);
HG1=HG+D2*y/(x+y+z);
HB1=HB+D3*z/(x+y+z);
wherein HR1Correction of the conversion value for the first pixel chromaticity, HG1Correction of the conversion value for the second pixel chrominance, HB1Correction of the conversion value for the third pixel chromaticity, HRIs the first pixel chroma conversion value, HGIs the second pixel chroma conversion value, HBIs the third pixel chroma conversion value, D1For a first color conversion error value, D2For the second color conversion error value, D3And determining a third color conversion error value, wherein x is a first proportionality coefficient distributed to the first pixel point in the preset proportionality rule, y is a second proportionality coefficient distributed to the second pixel point in the preset proportionality rule, and z is a third proportionality coefficient distributed to the third pixel point in the preset rule.
In a more specific embodiment, in the execution process of the step S443, an upper error diffusion algorithm is added to correct the color conversion error of the target pixel point based on the color conversion algorithm from the RGB color space to the HSV color space. The specific formula is as follows:
max=max(R,G,B);
min=min(R,G,B);
if R=max,HR=(G-B)/(max-min);
if G=max,HG=2+(B-R)/(max-min);
if B=max,HB=4+(R-G)/(max-min);
H(R、G、B)=*60 if<0,H(R、G、B)=H(R、G、B)+360;V=max(R,G,B);
S=(max-min)/max;
HR1=HR+D1*x/(x+y+z);(R=max)
HG1=HG+D2*y/(x+y+z);(G=max)
HB1=HB+D3*z/(x+y+z);(B=max)
wherein R is a red pixel, G is a green pixel, and B is a blue pixel; h is a chrominance conversion value, although H also represents gray information, usually H is an angle value, which represents the position of a chrominance conversion value of a certain pixel point of the target video image, V is the lightness of the target video image in the color conversion space of HSV, usually V is in the range of 0-1, S is the color saturation or color purity of the target video image in the color conversion space of HSV, usually S is in the range of 0-1, and H is the color saturation or color purity of the target video image in the color conversion space of HSVR1Correction of the conversion value for the first pixel chromaticity, HG1Correction of the conversion value for the second pixel chrominance, HB1Correction of the conversion value for the third pixel chromaticity, HRIs the first pixel chroma conversion value, HGFor the second pixel chrominance conversion value,
HBis the third pixel chroma conversion value, D1For a first color conversion error value, D2For the second color conversion error value, D3And determining a third color conversion error value, wherein x is a first proportionality coefficient distributed to the first pixel point in the preset proportionality rule, y is a second proportionality coefficient distributed to the second pixel point in the preset proportionality rule, and z is a third proportionality coefficient distributed to the third pixel point in the preset rule.
The method is improved on the basis of a color conversion error algorithm, namely, an upper error diffusion algorithm is added to correct the color conversion error caused by the conversion from the RGB color space to the HSV color space, namely, the loss caused by the color conversion error is reduced, and the visual effect of the target video image can be obviously improved.
Step S5: and performing video image matting on the target video image after the color conversion error value is corrected.
And executing the process from the step S1 to the step S4, performing color conversion error processing on the whole target video image, that is, performing color conversion error processing on all pixel points of the target video image, specifically, scanning all pixels of the target video image row by row and column by combining an error diffusion algorithm through a GPU processor, completing color conversion error processing on all pixel points of all target video images, avoiding the visual error of people on the target video image, and further quickly completing the image matting of the target video image.
The video image matting method in the embodiment of the invention utilizes the error diffusion algorithm to process the color conversion error existing when the color of the target video image is subjected to space conversion, can effectively reduce the visual error of the target video image to human eyes, and is also beneficial to rapidly matting the target video image.
Example 2
An embodiment of the present invention provides a matting device for video images, as shown in fig. 5, including:
and a color obtaining module 51, configured to obtain colors of the target video image.
And a color conversion module 52, configured to convert the color of the target video image from the first color space to the second color space, so as to obtain a color conversion result of the target video image.
And an error value obtaining module 53, configured to obtain a color conversion error value of each pixel point of the target video image according to the color conversion result.
And an error correction module 54 for correcting the color conversion error value using an error diffusion algorithm.
And the matting module 55 is configured to perform video image matting on the target video image after the color conversion error value is corrected.
In the matting device for video images in the embodiment of the present invention, the first color space in the color conversion module 52 is an RGB color space, and the second color space is an HSV color space.
In the matting device for video images in the embodiment of the present invention, the color conversion module 52 converts the color of the target video image from the first color space to the second color space, and the color conversion result of the target video image is obtained by a color conversion algorithm that converts the RGB color space to the HSV color space.
In the matting device for video images in the embodiment of the present invention, in fig. 5, the error correction module 54 further includes:
the first obtaining sub-module 541 is configured to obtain a first pixel point, a second pixel point, and a third pixel point, where the first pixel point is located in a first direction of the target pixel point, the second pixel point is located in a second direction of the target pixel point, and the third pixel point is located in a third direction of the target pixel point, of the target video image;
the second obtaining submodule 542 is configured to obtain a color conversion error value of the target pixel point;
the setting submodule 543 is used for setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point respectively;
the correcting submodule 544 is configured to diffuse the color conversion error value to the first pixel point, the second pixel point, and the third pixel point according to the preset proportion rule to correct the color conversion error value.
In the matting apparatus for video images in the embodiment of the present invention, the modification submodule 544, as shown in fig. 6, further includes:
a first obtaining unit 5441, configured to obtain a first color conversion error value, a second color conversion error value, and a third color conversion error value of the target pixel point according to the color conversion result, respectively;
a second obtaining unit 5442, configured to obtain, according to the color conversion result, a first pixel chromaticity conversion value, a second pixel chromaticity conversion value, and a third pixel chromaticity conversion value of the target pixel point, respectively;
a correcting unit 5443 for correcting the first color conversion error value, the second color conversion error value, and the third color conversion error value according to a preset scale rule and the first pixel chrominance conversion value, the second pixel chrominance conversion value, and the third pixel chrominance conversion value.
In the apparatus for matting a video image in the embodiment of the present invention, the correction unit 5443 corrects the video image by the following formula:
HR1=HR+D1*x/(x+y+z);
HG1=HG+D2*y/(x+y+z);
HB1=HB+D3*z/(x+y+z);
wherein HR1Correction of the conversion value for the first pixel chromaticity, HG1Correction of the conversion value for the second pixel chrominance, HB1Correction of the conversion value for the third pixel chromaticity, HRIs the first pixel chroma conversion value, HGIs the second pixel chroma conversion value, HBIs the third pixel chroma conversion value, D1For a first color conversion error value, D2For the second color conversion error value, D3And determining a third color conversion error value, wherein x is a first proportionality coefficient distributed to the first pixel point in the preset proportionality rule, y is a second proportionality coefficient distributed to the second pixel point in the preset proportionality rule, and z is a third proportionality coefficient distributed to the third pixel point in the preset rule.
The matting device for video images in the embodiment of the present invention is provided with a sub-module 543, further including:
and the iteration unit is used for distributing the first scale coefficient, the second scale coefficient and the third scale coefficient according to an iteration algorithm until the first pixel chrominance conversion value, the second pixel chrominance conversion value and the third pixel chrominance conversion value reach the target state and the iteration is finished.
The video image matting device in the embodiment of the invention utilizes the error diffusion algorithm to process the color conversion error existing when the color of the target video image is subjected to space conversion, can effectively reduce the visual error of the target video image to human eyes, and is also beneficial to rapidly matting the target video image.
Example 3
The embodiment of the invention provides a matting device based on a GPU, which comprises a memory 720, a GPU processor 710 and a computer program which is stored on the memory 720 and can be run on the GPU processor 710 as shown in FIG. 7, wherein the steps of the method in the embodiment 1 are realized when the GPU processor 710 executes the program, the error diffusion algorithm in the embodiment 1 can be rapidly and comprehensively operated by using the GPU processor, the parallel operation and the multithreading can be performed by using the GPU processor, each thread can process one pixel point, the number of pixel points of a target video image is large, and the number of threads can be distributed by the GPU processor, so that the processing speed of the target video image can be obviously improved by using the GPU processor.
Fig. 7 is a schematic diagram of a hardware structure of a GPU-based matting device for performing a processing method of list item operations according to an embodiment of the present invention, as shown in fig. 7, the GPU-based matting device includes one or more processors 710 and a memory 720, and one processor 710 is taken as an example in fig. 7.
The GPU-based matting apparatus that performs the processing method of the list item operation may further include: an input device 730 and an output device 740.
The processor 710, the memory 720, the input device 730, and the output device 740 may be connected by a bus or other means, such as the bus connection in fig. 7.
Processor 710 may be a Central Processing Unit (CPU). The Processor 710 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or any combination thereof.
Example 4
Embodiments of the present invention provide a storage medium having stored thereon computer instructions that, when executed by a GPU processor, perform the steps of the method of embodiment 1. The storage medium also stores thereon the color of the target video image, the color conversion result, the color conversion error value, and the like. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.

Claims (6)

1. A matting method of a video image is characterized by comprising the following steps:
acquiring the color of a target video image;
converting the color of the target video image from an RGB color space to an HSV color space to obtain a color conversion result of the target video image;
acquiring a color conversion error value of each pixel point of the target video image according to the color conversion result;
acquiring a first pixel point, a second pixel point and a third pixel point which are adjacent to a target pixel point of the target video image, wherein the first pixel point is positioned in a first direction of the target pixel point, the second pixel point is positioned in a second direction of the target pixel point, and the third pixel point is positioned in a third direction of the target pixel point;
obtaining the color conversion error value of the target pixel point;
setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point respectively;
respectively acquiring a first color conversion error value, a second color conversion error value and a third color conversion error value of the target pixel point according to the color conversion result;
respectively acquiring a first pixel chromaticity conversion value, a second pixel chromaticity conversion value and a third pixel chromaticity conversion value of the target pixel point according to the color conversion result;
correcting the first color conversion error value, the second color conversion error value and the third color conversion error value according to the preset proportion rule and the first pixel chromaticity conversion value, the second pixel chromaticity conversion value and the third pixel chromaticity conversion value;
performing video image matting on the target video image after the color conversion error value is corrected;
the step of correcting the first color conversion error value, the second color conversion error value, and the third color conversion error value according to the preset scaling rule and the first pixel chromaticity conversion value, the second pixel chromaticity conversion value, and the third pixel chromaticity conversion value is corrected by the following formula:
HR1=HR+D1*x/(x+y+z);
HG1=HG+D2*y/(x+y+z);
HB1=HB+D3*z/(x+y+z);
wherein HR1Correction of the conversion value for the first pixel chromaticity, HG1Correction of the conversion value for the second pixel chrominance, HB1Correction of the conversion value for the third pixel chromaticity, HRIs the first pixel chrominance conversion value, HGIs the second pixel chrominance conversion value, HBFor said third pixel chrominance conversion value, D1Converting the error value for the first color, D2Is the second colorConversion of error value, D3And for the third color conversion error value, x is a first scale coefficient allocated to the first pixel point in the preset scale rule, y is a second scale coefficient allocated to the second pixel point in the preset scale rule, and z is a third scale coefficient allocated to the third pixel point in the preset rule.
2. The method as claimed in claim 1, wherein the color conversion of the target video image from a first color space to a second color space is obtained by a color conversion algorithm from RGB color space to HSV color space.
3. The method of matting of a video image according to claim 2, wherein the step of setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point respectively further comprises:
and distributing the first scaling factor, the second scaling factor and the third scaling factor according to an iterative algorithm until the first pixel chrominance conversion value, the second pixel chrominance conversion value and the third pixel chrominance conversion value reach a target state, and ending the iteration.
4. A matting apparatus for video images, comprising:
the color acquisition module is used for acquiring the color of the target video image;
the color conversion module is used for converting the color of the target video image from an RGB color space to an HSV color space to obtain a color conversion result of the target video image;
an error value obtaining module, configured to obtain a color conversion error value of each pixel point of the target video image according to the color conversion result;
the error correction module is used for acquiring a first pixel point, a second pixel point and a third pixel point which are adjacent to a target pixel point of the target video image, wherein the first pixel point is positioned in a first direction of the target pixel point, the second pixel point is positioned in a second direction of the target pixel point, and the third pixel point is positioned in a third direction of the target pixel point;
obtaining the color conversion error value of the target pixel point;
setting a preset proportion rule for diffusing the color conversion error value to the first pixel point, the second pixel point and the third pixel point respectively;
respectively acquiring a first color conversion error value, a second color conversion error value and a third color conversion error value of the target pixel point according to the color conversion result;
respectively acquiring a first pixel chromaticity conversion value, a second pixel chromaticity conversion value and a third pixel chromaticity conversion value of the target pixel point according to the color conversion result;
correcting the first color conversion error value, the second color conversion error value and the third color conversion error value according to the preset proportion rule and the first pixel chromaticity conversion value, the second pixel chromaticity conversion value and the third pixel chromaticity conversion value;
and the matting module is used for carrying out video image matting on the target video image after the color conversion error value is corrected.
5. A GPU-based matting device comprising a memory, a GPU processor and a computer program stored on the memory and executable on the GPU processor, characterized in that the GPU processor implements the steps of the method of matting an image according to any one of claims 1-3 when executing the program.
6. A storage medium having stored thereon computer instructions, characterized in that the instructions, when executed by a GPU processor, implement the steps of the method of matting video images according to any one of claims 1-3.
CN201910309802.3A 2019-04-17 2019-04-17 Matting method and device for video image, storage medium and matting equipment Active CN110070507B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910309802.3A CN110070507B (en) 2019-04-17 2019-04-17 Matting method and device for video image, storage medium and matting equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910309802.3A CN110070507B (en) 2019-04-17 2019-04-17 Matting method and device for video image, storage medium and matting equipment

Publications (2)

Publication Number Publication Date
CN110070507A CN110070507A (en) 2019-07-30
CN110070507B true CN110070507B (en) 2021-03-02

Family

ID=67367935

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910309802.3A Active CN110070507B (en) 2019-04-17 2019-04-17 Matting method and device for video image, storage medium and matting equipment

Country Status (1)

Country Link
CN (1) CN110070507B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110298894A (en) * 2019-06-28 2019-10-01 京东数字科技控股有限公司 Image processing method, device, system and medium
CN111277772A (en) * 2020-03-09 2020-06-12 北京文香信息技术有限公司 Matting method, device, equipment and storage medium
CN112330692B (en) * 2020-11-11 2022-06-28 安徽文香科技有限公司 Matting method, matting device, matting equipment and storage medium
CN112991366B (en) * 2021-02-18 2024-05-03 广州光锥元信息科技有限公司 Method, device and mobile terminal for carrying out real-time chromaticity matting on image
CN113436097B (en) * 2021-06-24 2022-08-02 湖南快乐阳光互动娱乐传媒有限公司 Video matting method, device, storage medium and equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103347140A (en) * 2009-04-17 2013-10-09 佳能株式会社 Image processing apparatus and image processing method
CN106847185A (en) * 2015-11-11 2017-06-13 株式会社日本有机雷特显示器 Display device, the bearing calibration of display device, manufacture method and display methods
CN109191520A (en) * 2018-09-30 2019-01-11 湖北工程学院 A kind of Measurement Approach of Leaf Area and system based on color calibration

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102011102999A1 (en) * 2011-05-24 2012-11-29 Leonhard Kurz Stiftung & Co. Kg Foil and its production process
CN104200470B (en) * 2014-08-29 2017-02-08 电子科技大学 Blue screen image-matting method
CN105893649B (en) * 2015-03-23 2019-02-01 温州大学 A kind of interactive image based on optimal model restains method
CN106204567B (en) * 2016-07-05 2019-01-29 华南理工大学 A kind of natural background video matting method
CN108460770B (en) * 2016-12-13 2020-03-10 华为技术有限公司 Matting method and device
CN108965647B (en) * 2017-05-18 2020-12-15 北京金山云网络技术有限公司 Foreground image obtaining method and device
CN107481261B (en) * 2017-07-31 2020-06-16 中国科学院长春光学精密机械与物理研究所 Color video matting method based on depth foreground tracking
CN107516299B (en) * 2017-08-10 2020-11-10 浙江理工大学 Symmetric multi-threshold error diffusion method for fabric color level conversion and application thereof
CN109543596B (en) * 2018-11-20 2022-06-07 浙江大华技术股份有限公司 Water level monitoring method and device, electronic equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103347140A (en) * 2009-04-17 2013-10-09 佳能株式会社 Image processing apparatus and image processing method
CN106847185A (en) * 2015-11-11 2017-06-13 株式会社日本有机雷特显示器 Display device, the bearing calibration of display device, manufacture method and display methods
CN109191520A (en) * 2018-09-30 2019-01-11 湖北工程学院 A kind of Measurement Approach of Leaf Area and system based on color calibration

Also Published As

Publication number Publication date
CN110070507A (en) 2019-07-30

Similar Documents

Publication Publication Date Title
CN110070507B (en) Matting method and device for video image, storage medium and matting equipment
WO2017024615A1 (en) Image enhancement method
WO2020082593A1 (en) Method and device for enhancing image contrast
TWI737979B (en) Image demosaicer and method
CN108230407B (en) Image processing method and device
US10204568B2 (en) Driving methods and driving devices of display panels
CN110910333B (en) Image processing method and image processing apparatus
JP2006191607A (en) Color interpolation method for digital photographing apparatus
WO2016058226A1 (en) Image colour enhancement method and system
WO2021218603A1 (en) Image processing method and projection system
CN112652027B (en) Pseudo color detection method and system
WO2018113050A1 (en) Drive method and drive apparatus of display panel
CN111107330B (en) Color cast correction method for Lab space
US8842932B2 (en) Image processing apparatus, image processing method, and recording medium recording a program
WO2018100950A1 (en) Image processing device, digital camera, image processing program, and recording medium
US20200160492A1 (en) Image Adjustment Method and Device, Image Display Method and Device, Non-Transitory Storage Medium
CN113850738A (en) Device and method for correcting purple border of image
WO2012153661A1 (en) Image correction device, image correction display device, image correction method, program, and recording medium
TWI479878B (en) Correction of pseudo - color pixels in digital image
JP2008219289A (en) Video correction device, video display device, imaging apparatus and video correction program
TW202021330A (en) Image zooming method and device
EP2802139B1 (en) Image color adjusting method and electronic device using the same
TWI531246B (en) Color adjustment method and its system
WO2012099013A1 (en) Image correction device, image correction display device, image correction method, program, and recording medium
WO2019085053A1 (en) Method and system for improving color gamut of display

Legal Events

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

Effective date of registration: 20210118

Address after: 247100 building A1, science and Technology Incubation Park, Jiangnan industrial concentration zone, Chizhou City, Anhui Province

Applicant after: Anhui Kelang Electronic Technology Co.,Ltd.

Address before: 100176 11th floor, block B, AVIC Plaza, 15 ronghua South Road, economic and Technological Development Zone, Daxing District, Beijing

Applicant before: BEIJING WENXIANG INFORMATION TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant