[go: up one dir, main page]

CN1224242C - Method for fast picking up picture with any image as background in digital image process - Google Patents

Method for fast picking up picture with any image as background in digital image process Download PDF

Info

Publication number
CN1224242C
CN1224242C CN 03116447 CN03116447A CN1224242C CN 1224242 C CN1224242 C CN 1224242C CN 03116447 CN03116447 CN 03116447 CN 03116447 A CN03116447 A CN 03116447A CN 1224242 C CN1224242 C CN 1224242C
Authority
CN
China
Prior art keywords
background
point
foreground
points
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.)
Expired - Fee Related
Application number
CN 03116447
Other languages
Chinese (zh)
Other versions
CN1445984A (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.)
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
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 Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CN 03116447 priority Critical patent/CN1224242C/en
Publication of CN1445984A publication Critical patent/CN1445984A/en
Application granted granted Critical
Publication of CN1224242C publication Critical patent/CN1224242C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)
  • Spectrometry And Color Measurement (AREA)
  • Image Processing (AREA)

Abstract

The present invention discloses a method for quickly picking up images in digital image processing by using any image as a background, which comprises the steps: 1) region segmentation is manually carried out for images; each image is divided into three parts: a foreground region, an unknown region and a background region; 2) according to the divided regions, the color of any point c in the unknown region is set as C, and the foreground color component F and the background color component B of the point c are calculated; 3) the values of F and B are adjusted by the measure of color adjustment according to the estimated foreground color component F and the background color component B; finally, the alpha value of the point c is estimated. Images can be picked up and processed effectively by the method for picking up the images; simultaneously, the speed of picking up images is greatly improved, the calculation cost is low, and the present invention has good practicability value.

Description

数字图像处理中以任意图像为背景的快速抠图方法A Fast Cutout Method Using Arbitrary Image as Background in Digital Image Processing

                        技术领域Technical field

本发明涉及一种数字图像处理中以任意图像为背景的快速抠图方法。The invention relates to a fast image-cutting method with an arbitrary image as the background in digital image processing.

                        背景技术 Background technique

抠图技术是一种把任意图像中的前景部分从背景中分离出来的一种图像处理技术。它在电影电视特效特技制作等方面有着广泛而深入的应用。根据对图像背景的有无限制,抠图技术大致可以分为两大类:Cutout technology is an image processing technique that separates the foreground part of any image from the background. It has extensive and in-depth applications in the production of film and television special effects and special effects. According to whether there are restrictions on the image background, the matting technology can be roughly divided into two categories:

对图像前景或背景有限制一类又可分为蓝屏抠图(blue screen matting)和差异抠图(difference matting)。蓝屏抠图技术对图像的背景有一定限制,背景通常是固定颜色,一般为蓝色或者绿色,或者是准备多张有相同前景的图像,利用这些图像中的背景颜色的不同,来达到准确抠取前景的目的。差异抠图技术需要另外准备一张背景图像,通过比较背景图像和原图中相应点的颜色差异来估计alpha值。There are restrictions on the foreground or background of the image and can be divided into blue screen matting and difference matting. The blue screen cutout technology has certain restrictions on the background of the image. The background is usually a fixed color, usually blue or green, or multiple images with the same foreground are prepared, and the background colors in these images are used to achieve accurate cutout. The purpose of taking the foreground. The difference matting technology needs to prepare another background image, and the alpha value is estimated by comparing the color difference between the background image and the corresponding point in the original image.

对图像背景无限制一类自然图像抠图(natural image matting)。它对图像的背景不做要求,且只需一张图像。A class of natural image matting with no restrictions on the image background. It does not require the background of the image, and only needs one image.

抠图问题可以定义为:对给定图像上任一点c,求c点的颜色C所含的前景色F和alpha值α。抠图问题的困难在于对图像上的任一点c,它的F和α的解并不是唯一的,我们要从无数对的解中找出最合理的解。The matting problem can be defined as: For any point c on a given image, find the foreground color F and alpha value α contained in the color C of point c. The difficulty of the matting problem is that for any point c on the image, its F and α solutions are not unique, and we need to find the most reasonable solution from countless pairs of solutions.

蓝屏抠图技术简单,计算量小,且抠图效果好。但是它有其致命的弱点,就是它对图像的背景的颜色有一定限制。一般情况下背景要求是蓝色或者绿色,应用该技术时需要一个人拿着块蓝色的背景到处跑,同时它一般还要求前景的颜色的RGB分量按某种比例分布,这些使蓝屏抠图技术在具体应用当中带来了很大的不便。The blue screen cutout technology is simple, the amount of calculation is small, and the cutout effect is good. But it has its fatal weakness, that is, it has certain restrictions on the color of the background of the image. Under normal circumstances, the background is required to be blue or green. When applying this technology, a person needs to run around with a blue background. At the same time, it generally requires the RGB components of the foreground color to be distributed in a certain proportion. These make the blue screen cutout Technology has brought great inconvenience in specific applications.

自然图像抠图技术有Knockout方法、Ruzon&Tomasi方法、Hillman方法和Chuang方法。自然图像抠图一般可以分为三个步骤:Natural image matting techniques include Knockout method, Ruzon&Tomasi method, Hillman method and Chuang method. Natural image matting can generally be divided into three steps:

1.区域分割。一般情况下以手工分割为主。由于区域分割的精确程度对抠图效果有很大的影响。手工分割区域可以有更好的精确度,一般一张图像的区域分割耗时2-3分钟左右。1. Regional segmentation. In general, manual segmentation is the main method. Because the accuracy of region segmentation has a great influence on the matting effect. Manually segmenting the region can have better accuracy. Generally, the region segmentation of an image takes about 2-3 minutes.

2.前景和背景颜色估计。Knockout方法利用邻近区域的点的加权平均来估计,方法简单,计算量较小;Ruzon&Tomasi方法、Hillman方法和Chuang方法都利用了统计学的规律,方法复杂,计算量大。2. Foreground and background color estimation. The Knockout method uses the weighted average of the points in the adjacent area to estimate, the method is simple, and the calculation amount is small; the Ruzon&Tomasi method, the Hillman method and the Chuang method all use the law of statistics, the method is complicated, and the calculation amount is large.

3.Alpha值估计。利用估计出的前景和背景颜色来估计alpha值。在已知的方法中,除了Knockout方法外,其余方法都没有对前景和背景颜色做调整。而Knockout方法所作的调整又过于粗糙,导致其抠图效果不佳。3. Alpha value estimation. Use the estimated foreground and background colors to estimate the alpha value. Among the known methods, except for the Knockout method, the other methods do not adjust the foreground and background colors. However, the adjustment made by the Knockout method is too rough, resulting in poor matting effect.

                        发明内容Contents of the invention

本发明的目的是提供一种数字图像处理中以任意图像为背景的快速抠图方法。The purpose of the present invention is to provide a fast method for cutting out images with any image as the background in digital image processing.

数字图像处理中以任意图像为背景的快速抠图方法是对图像进行区域划分,把它划分成三个部分:前景区域,未知区域和背景区域,其特征在于:其步骤为:In the digital image processing, the fast matting method with any image as the background is to divide the image into three parts: the foreground area, the unknown area and the background area, and it is characterized in that: its steps are:

1)根据分割的区域,对未知区域中的任意一点c,设其颜色为C,计算出其初始的前景和背景颜色分量 F和 B;所说初始的前景和背景颜色分量 F和 B的计算是:对于未知区域中的任意一点c,找出前景轮廓线和背景轮廓线上离c点距离最近的点f′和b′,点f′和b′离c点的距离分别为d1和d2,给定一个正实数θ(1.0<θ≤10.0),以点c为圆心,分别以θd1和θd2长为半径,做两个同心圆C1和C2,设在圆C1内部且位于前景轮廓线上的所有点为f1、f2、……、fk,这些点离c点的距离为d11、d12、……、d1k,在圆C2内部且位于背景轮廓线上的所有点为b1、b2、……、b1,这些点离c点的距离为d21、d22、……、d21,计算出fi(i=1,2,…,k)点颜色的加权平均值 F &OverBar; = &Sigma; i = 1 k w 1 i f i , b j ( j = 1,2 , &CenterDot; &CenterDot; &CenterDot; , l ) 点颜色的加权平均值 B &OverBar; = &Sigma; j = 1 l w 2 j b j , 其中 w 1 i = &theta; &theta; - 1 - 1 &theta; - 1 &CenterDot; d 1 i d 1 ( i = 1,2 , &CenterDot; &CenterDot; &CenterDot; , k ) , w 2 j = &theta; &theta; - 1 - 1 &theta; - 1 &CenterDot; d 2 j d 2 ( j = 1,2 , &CenterDot; &CenterDot; &CenterDot; , l ) , F和 B就是所估计的初始的前景和背景颜色分量;1) According to the segmented area, for any point c in the unknown area, set its color as C, and calculate its initial foreground and background color components F and B; the calculation of said initial foreground and background color components F and B Yes: For any point c in the unknown area, find out the points f' and b' closest to point c on the foreground contour line and background contour line, and the distances between point f' and b' from point c are d 1 and d 2 , given a positive real number θ (1.0<θ≤10.0), with point c as the center, and θd 1 and θd 2 as the radius, make two concentric circles C 1 and C 2 , set them in circle C 1 All points inside and located on the foreground contour line are f 1 , f 2 , ..., f k , and the distances of these points from point c are d 11 , d 12 , ..., d 1k , which are inside the circle C 2 and located at All points on the background contour line are b 1 , b 2 , ..., b 1 , and the distances from these points to point c are d 21 , d 22 , ..., d 21 , and f i (i=1, 2 ,...,k) the weighted average of point colors f &OverBar; = &Sigma; i = 1 k w 1 i f i , b j ( j = 1,2 , &CenterDot; &Center Dot; &CenterDot; , l ) weighted average of point colors B &OverBar; = &Sigma; j = 1 l w 2 j b j , in w 1 i = &theta; &theta; - 1 - 1 &theta; - 1 &Center Dot; d 1 i d 1 ( i = 1,2 , &Center Dot; &Center Dot; &Center Dot; , k ) , w 2 j = &theta; &theta; - 1 - 1 &theta; - 1 &Center Dot; d 2 j d 2 ( j = 1,2 , &Center Dot; &Center Dot; &Center Dot; , l ) , F and B are the estimated initial foreground and background color components;

2)据估计出的初始前景和背景颜色分量 F和 B,采取颜色调整措施调整为F和B的值,最后估计出c点的alpha值,所说的alpha值估计是:其步骤为:1)根据图像中前景物体和背景物体的颜色亮度差异,决定色差参数ρ的取值,2)根据 F和 B的颜色亮度比值λ与色差参数ρ的关系,调整 F和 B的值为F和B,3)根据调整后的F和B,由公式 &alpha; = ( C - B ) &CenterDot; ( F - B ) | | F - B | | 2 计算出未知区域中的一点c的alpha值α。2) According to the estimated initial foreground and background color components F and B, take color adjustment measures to adjust to the values of F and B, and finally estimate the alpha value of point c. The estimated alpha value is: the steps are: 1 ) Determine the value of the color difference parameter ρ according to the color brightness difference between the foreground object and the background object in the image, 2) adjust the values of F and B to F and B according to the relationship between the color brightness ratio λ of F and B and the color difference parameter ρ , 3) According to the adjusted F and B, by the formula &alpha; = ( C - B ) &CenterDot; ( f - B ) | | f - B | | 2 Calculate the alpha value α of a point c in the unknown area.

本发明具有速度块,效果好的优点。以前的自然图像抠图技术都把大部分的精力放在了第二个步骤,也即如何估计前景和背景颜色,而忽略了第三个步骤,也即alpha的估计。关注步骤2忽略步骤3的结果导致出现了各种复杂的颜色估计模型,虽然在一定程度上改进了抠图效果,但同时也大大增加了计算量,这使得自然图像抠图技术在实际中的应用受到了很大的限制。The invention has the advantages of speed block and good effect. Previous natural image matting techniques put most of their energy on the second step, that is, how to estimate the foreground and background colors, while ignoring the third step, that is, the estimation of alpha. Focusing on step 2 and ignoring the results of step 3 lead to the emergence of various complex color estimation models. Although the matting effect is improved to a certain extent, it also greatly increases the amount of calculation, which makes the natural image matting technology in practice. Applications are very limited.

本发明突破了这个框架,设计了一种计算量小,抠图效果好的抠图技术来满足实际的需要。它的颜色估计模型非常简单,alpha值的估计方案则别出心裁。The present invention breaks through this framework and designs a cutout technology with a small amount of calculation and good cutout effect to meet actual needs. Its color estimation model is very simple, and the alpha value estimation scheme is ingenious.

表1列出了不同抠图例子在不同的机器上所需的处理时间。与当今国际上抠图效果最好的Chuang方法相比,本发明的速度比它提高了10~12倍,而抠图效果却没有降低。Chuang方法在CPU为P3 1.0G,RAM为512M的环境下,处理Syringe图像需要120秒左右。使用本发明的方法在机器条件比Chuang方法略差的条件下,速度是Chuang方法的11倍左右。Table 1 lists the processing time required for different matting examples on different machines. Compared with the Chuang method with the best matting effect in the world today, the speed of the present invention is 10-12 times higher than it, but the matting effect is not reduced. Chuang's method takes about 120 seconds to process the Syringe image in the environment where the CPU is P3 1.0G and the RAM is 512M. Use method of the present invention under the condition that machine condition is slightly worse than Chuang method, speed is about 11 times of Chuang method.

           表格1  不同抠图例子在不同环境下的抠图时间 CPU:Celeron 400RAM:320M   CPU:P3 600RAM:512M  CPU:P4 1.8GRAM:256M Syringe     16.484秒     10.485秒     5.680秒 Feather_edge     25.696秒     16.474秒     8.844秒 Galadriel     4.266秒     2.754秒     1.406秒 Gandalf     5.618秒     3.635秒     1.891秒 Tiger     5.658秒     3.666秒     1.922秒 Water     9.303秒     5.988秒     3.281秒 Table 1 Cutting time of different cutout examples in different environments CPU: Celeron 400RAM: 320M CPU: P3 600 RAM: 512M CPU: P4 1.8GRAM: 256M Syringes 16.484 seconds 10.485 seconds 5.680 seconds Feather_edge 25.696 seconds 16.474 seconds 8.844 seconds Galadriel 4.266 seconds 2.754 seconds 1.406 seconds Gandalf 5.618 seconds 3.635 seconds 1.891 seconds Tiger 5.658 seconds 3.666 seconds 1.922 seconds Water 9.303 seconds 5.988 seconds 3.281 seconds

应用本发明可以快速有效地抠出任意图像中的前景部分。大量的例子证明,本发明很好地解决了抠图中存在的速度和效果之间的矛盾,具有很好的实用价值。By applying the invention, the foreground part in any image can be extracted quickly and effectively. A large number of examples prove that the present invention well solves the contradiction between the speed and the effect existing in the cutout, and has very good practical value.

                              附图说明Description of drawings

图1是本发明流程示意图;Fig. 1 is a schematic flow chart of the present invention;

图2(a)(b)描述的是区域划分和前景背景颜色分量的估计示意图;Figure 2(a)(b) depicts a schematic diagram of region division and estimation of foreground and background color components;

图3(a)(b)(c)(d)是颜色F、B和C在颜色空间中的几种相对位置示意图;Figure 3(a)(b)(c)(d) is a schematic diagram of several relative positions of colors F, B and C in the color space;

图4(a)(b)是本发明中的颜色调整方案示意图;Figure 4(a)(b) is a schematic diagram of the color adjustment scheme in the present invention;

图5是本发明与其他抠图方法的关于例子Syringe图像的效果比较示意图;Fig. 5 is the schematic diagram of the effect comparison about the example Syringe image of the present invention and other matting methods;

图6是本发明与Chuang方法的关于例子Feather_edge图像的效果比较示意图;Fig. 6 is a schematic diagram of the effect comparison between the present invention and the Chuang method on the example Feather_edge image;

图7是本发明的其他一些效果示意图。Fig. 7 is a schematic diagram of some other effects of the present invention.

                        具体实施方式 Detailed ways

数字图像处理中以任意图像为背景的快速抠图方法的原理是:对于前景和背景之间的过渡区域(也即区域分割中的未知区域)中的任意一点c,以图像空间中离该点最近的一些前景点和背景点的颜色加权平均值 F和 B做为c点颜色的前景和背景颜色分量,然后采用适当的alpha值估计方案估计出c点的alpha值α。本方法无需建立复杂的模型来求前景和背景颜色,颜色的调整方案也很简单,因此,本方法是一种快速的抠图方法。The principle of the fast matting method with an arbitrary image as the background in digital image processing is: for any point c in the transition area between the foreground and the background (that is, the unknown area in the area segmentation), the distance from the point c in the image space is Color-weighted average of some nearest foreground and background points F and B is used as the foreground and background color components of point c, and then an appropriate alpha value estimation scheme is used to estimate the alpha value α of point c. This method does not need to establish a complex model to calculate the foreground and background colors, and the color adjustment scheme is also very simple. Therefore, this method is a fast method for image matting.

首先,在本抠图方法的第二个步骤中,计算前景颜色分量F和背景颜色分量B的模型简单实用。本方法只计算包含在两个圆区域内部的轮廓线上的点,且权重的计算和这些点与c点的距离成线性关系,距离最近的点的权重最大,随着距离的增大权重线性减小。本发明的抠图方法在第二步的颜色估计模型尽可能地做了简化。First, in the second step of the matting method, the model for calculating the foreground color component F and the background color component B is simple and practical. This method only calculates the points on the contour lines contained in the two circle areas, and the calculation of the weight is linearly related to the distance between these points and point c. The weight of the nearest point is the largest, and the weight is linear as the distance increases. decrease. In the matting method of the present invention, the color estimation model in the second step is simplified as much as possible.

其次,在第三个步骤中,本方法的颜色调整方案简单直观。该方案保持颜色的RGB分量的比例不变,利用人眼对颜色亮度的微小变化不甚敏感的特点,在最小程度上调整前景和背景颜色的亮度,最后利用调整后的前景和背景颜色估计出C点的alpha值。该方案的具体如下:Second, in the third step, the color adjustment scheme of our method is simple and intuitive. This scheme keeps the ratio of the RGB components of the color unchanged, uses the characteristic that the human eye is not very sensitive to small changes in color brightness, adjusts the brightness of the foreground and background colors to a minimum extent, and finally uses the adjusted foreground and background colors to estimate the The alpha value of point C. The details of the program are as follows:

在三维RGB颜色空间中,一点的颜色可以表示为一个点或者一个向量。在颜色三维坐标中,点O为坐标原点,它表示黑色。给定颜色空间中的任意两点P1,P2,|P1P2|表示线段P1P2的长度。设未知区域内任一点c,其颜色为C,估计出来的初始前景和背景颜色分量为B、F。在三维颜色空间中,为了表述方便,我们做如下定义:In the three-dimensional RGB color space, the color of a point can be expressed as a point or a vector. In the color three-dimensional coordinates, point O is the coordinate origin, which represents black. Any two points P 1 , P 2 , |P 1 P 2 | in a given color space represent the length of the line segment P 1 P 2 . Suppose any point c in the unknown area, its color is C, and the estimated initial foreground and background color components are B, F. In the three-dimensional color space, for the convenience of expression, we define as follows:

抠图偏差:点C和线段BF之间的距离称为抠图偏差。在图3(a)中,点C位于线段BF上,此时抠图偏差为0;图2(b)中,点C在线段BF外,做线段CC′垂直于线段BF并交于点C′,此时抠图偏差为线段CC′的长度|CC′|。Cutout bias: The distance between point C and line segment BF is called cutout bias. In Figure 3(a), point C is located on line segment BF, and the matting deviation is 0 at this time; in Figure 2(b), point C is outside line segment BF, and line segment CC′ is perpendicular to line segment BF and intersects at point C ’, at this time, the matting deviation is the length |CC′| of the line segment CC′.

规则点和不规则点:当C点离线段BF的距离不太远时,我们称此时的C点为规则点,否则为不规则点。线段CC′和BF的长度的比值在一定程度上反应了C点的规则性。Regular point and irregular point: When point C is not too far from the line segment BF, we call point C at this time a regular point, otherwise it is an irregular point. The ratio of the lengths of line segment CC' to BF reflects the regularity of point C to a certain extent.

当C点刚好落在线段BF上时,这种情况是C点的最理想的情况。从颜色合成方程可以推出:When point C just falls on the line segment BF, this situation is the most ideal situation of point C. From the color composition equation can be deduced:

&alpha;&alpha; == (( CC -- BB )) &CenterDot;&Center Dot; (( Ff -- BB )) || || Ff -- BB || || 22 -- -- -- (( 11 ))

式(1)中,向量(C-B)对应于有向线段BC,向量(F-B)对应于有向线段BF,α则是线段BC在BF上的投影的长度和BF的长度的比值。当C点在线段BF上时,抠图偏差为0,线段BC在BF上的投影的长度就是线段BC的长度。在绝大多数情况下,抠图偏差不为0,应用(1)式计算α会有一定的偏差。于是问题转化为如何尽可能合理地减小抠图偏差的值。本发明的颜色调整方案基于以下的几个观察:In formula (1), the vector (C-B) corresponds to the directed line segment BC, the vector (F-B) corresponds to the directed line segment BF, and α is the ratio of the length of the projection of the line segment BC on BF to the length of BF. When point C is on the line segment BF, the matting deviation is 0, and the length of the projection of line segment BC on BF is the length of line segment BC. In most cases, the matting deviation is not 0, and the calculation of α by formula (1) will have a certain deviation. So the problem is transformed into how to reduce the value of the matting deviation as reasonably as possible. The color adjustment scheme of the present invention is based on the following observations:

观察1:当C点为规则点时,由公式(3)计算出的alpha值的误差可以忽略。(如图3(b)所示);Observation 1: When point C is a regular point, the error of the alpha value calculated by formula (3) can be ignored. (as shown in Figure 3(b));

观察2:当角∠BCF为钝角时,点C离线段BF的距离并不太远。Observation 2: When the angle ∠BCF is an obtuse angle, the distance between point C and line segment BF is not too far.

观察3:当线段OC的长度介于线段OB和OF之间时,点C离线段BF的距离也不太远。Observation 3: When the length of segment OC is between segments OB and OF, point C is not too far from segment BF.

满足观察2和3的C点是规则点。并非所有的规则点都满足观察2或者3。在估计出初始的前景和背景颜色分量 F和 B后,通过本发明介绍的方法在颜色空间中调整 F和 B的位置,可以把大部分不规则的C点转化为规则点。Point C that satisfies observations 2 and 3 is a regular point. Not all rule points satisfy observations 2 or 3. After estimating the initial foreground and background color components F and After B, adjust in color space by the method that the present invention introduces F and The position of B can convert most of the irregular C points into regular points.

本发明定义: F=( Fr, Fg, Fb), B=( Br, Bg, Bb),C=(Cr,Cg,Cb),其中Ar,Ag,Ab为颜色A在RGB三个通道上的分量,这里A= F, B,C,计算l F = Fr+ Fg+ Fb,l B = Br+ Bg+ Bb,lC=Cr+Cg+Cb,比值 &lambda; = l F &OverBar; / l H &OverBar; , 此时分为三种情况讨论:①如果 &lambda; > 1 / &rho; 且lC>lF,或者 &lambda; &le; 1 / &rho; 且lC<l F ,则把 F调整为F=( Fr×lC/l F , Fg×lC/l F , Fb×lC/l F ), B不作调整,也即B= B,②如果 &lambda; > 1 / &rho; 且lC<l B ,或者 &lambda; &le; 1 / &rho; 且lC>l B ,把 B调整为B=( Br×lC/l B , Bg×lC/lB, Bb×lC/l B ), F不作调整,也即F= F,③在其余的情况下, F和 B均不作调整,也即F= F,B= B。把调整后的F和B代入公式(1),计算出alpha值α。Definition of the present invention: F=( F r , F g , F b ), B=( B r , B g , B b ), C=(C r , C g , C b ), wherein A r , A g , A b is the component of color A on three channels of RGB, where A=F, B, C, calculate l F = F r + F g + F b , l B = B r + B g + B b , l C =C r +C g +C b , the ratio &lambda; = l f &OverBar; / l h &OverBar; , At this time, it is divided into three situations for discussion: ① If &lambda; > 1 / &rho; and l C > l F , or &lambda; &le; 1 / &rho; And l C < l F , then adjust F to F=( Fr×l C /l F , F g ×l C /l F , F b ×l C /l F ), B is not adjusted, that is, B= B, ② if &lambda; > 1 / &rho; and l C < l B , or &lambda; &le; 1 / &rho; And l C >l B , adjust B to B=( B r ×l C /l B , Bg×l C /l B , B b ×l C /l B ), F is not adjusted, that is, F= F , ③ In the rest of the cases, F and B are not adjusted, that is, F = F, B = B. Substitute the adjusted F and B into formula (1) to calculate the alpha value α.

本发明的颜色调整方案只对初始前景和背景颜色分量 F和 B的亮度在最小程度上做了修改,而并没有改变它们的颜色。一般情况下,人眼对颜色的亮度的微小变化不太敏感,因此完全可以用F和B代替 F和 B来计算α值。这种替换保持了α估计值的连续性,不会对人眼造成很大的冲击。用F和B计算出来的α值更为接近真实的α值。The color adjustment scheme of the present invention is only for the initial foreground and background color components F and The brightness of B was modified minimally, without changing their color. In general, the human eye is not very sensitive to small changes in the brightness of the color, so it can be replaced by F and B F and B to calculate the alpha value. This replacement maintains the continuity of the estimated value of α and does not cause a great impact on the human eye. The α value calculated by F and B is closer to the real α value.

图1是本发明的详细流程图。首先,对输入图像进行区域划分,共分为三个部分:前景区域、背景区域和未知区域;其次,根据划分的区域,对未知区域中的每一点,初步估计出它的前景和背景颜色分量;最后,本发明采用颜色调整方案对估计出的前景和背景颜色分量进行调整,估计出它的alpha值。Fig. 1 is a detailed flow chart of the present invention. First, the input image is divided into three parts: foreground area, background area and unknown area; secondly, according to the divided area, for each point in the unknown area, its foreground and background color components are preliminarily estimated ; Finally, the present invention uses a color adjustment scheme to adjust the estimated foreground and background color components to estimate its alpha value.

图2(a)是本发明中区域划分的一个例子;图2(b)描述了在本发明中如何估计未知区域中的点的前景和背景颜色分量。其中较小的圆C1内部包含的那段红色的前景轮廓线上的点就是计算前景分量所需的所有点,较大的圆C2内部所包含的那段绿色的背景轮廓线上的点就是计算背景分量所需的所有点。Fig. 2(a) is an example of region division in the present invention; Fig. 2(b) describes how to estimate the foreground and background color components of points in unknown regions in the present invention. The points on the red foreground contour line contained in the smaller circle C 1 are all the points needed to calculate the foreground component, and the points on the green background contour line contained in the larger circle C 2 That is all the points needed to compute the background component.

图3(a)中点C恰好在线段 BF上;图3(b)中点C在线段 BF之外,但和线段 BF距离很近;图3(c)中lC不介于l B 和l F 之间,但∠ BC F为钝角;图3(d)中lC介于l B 和l F 之间,但∠ BC F为锐角。The point C in Figure 3(a) is just on the line segment BF; the point C in Figure 3(b) is outside the line segment BF, but very close to the line segment BF; in Figure 3(c), l C is not between l B and l F , but ∠ BC F is an obtuse angle; in Figure 3(d), l C is between l B and l F , but ∠ BC F is an acute angle.

图4是本发明中的颜色调整方案示意图。这里只讨论当l B <l F 时的情况。此时如果lC不介于l B 和l F 之间,则有两种情况:lC<l B <l F (如图4(a)所示)和l B <l F <l C (如图4(b)所示)。在图4(a)中,在 BF的延长线上找一点F,使lF=lC,这样就有l B <lC≤lF,满足观察3,可以认为C点此时是规则点,可以应用公式(1)计算alpha值。图4(b)的处理与之类似。Fig. 4 is a schematic diagram of a color adjustment scheme in the present invention. Here we only discuss the case when l B <l F. At this time, if l C is not between l B and l F , there are two situations: l C <l B <l F (as shown in Figure 4(a)) and l B <l F <l C ( As shown in Figure 4(b)). In Figure 4(a), find a point F on the extension line of BF, so that l F = l C , so that l B < l C ≤ l F , satisfying observation 3, it can be considered that point C is a regular point at this time , you can apply the formula (1) to calculate the alpha value. The processing of Fig. 4(b) is similar.

本说明书共举了6个实施例子。在本说明书所举的实施例子中,参数取值都为θ=2.0,ρ=1.428。图5,图6为实施例子1、2,图7包含实施例子3~6。This specification has cited 6 implementation examples altogether. In the implementation examples cited in this specification, the values of the parameters are all θ=2.0 and ρ=1.428. Fig. 5 and Fig. 6 are embodiment examples 1 and 2, and Fig. 7 includes embodiment examples 3-6.

实施例1Example 1

图5中的放大图1是由三部分组合而成,其中左边是原图,中间是灰度图,右边是背景为黑色的合成图。Knockout方法在放大图1中没有把一些头发丝抠出来,另外放大图1上有一些点的结果失真。Ruzon & Tomasi方法则有一些头发丝出现比较严重的断裂现象,另外合成图中有明显的不连续的现象。Chuang方法的效果较好,但仔细观察,可以发现放大图2的底部有轻微的不连续现象,在放大图1中也有些微的不连续。本发明的方法在本例子中则没有上述的缺点。The enlarged image 1 in Figure 5 is composed of three parts, the left is the original image, the middle is the grayscale image, and the right is the composite image with a black background. The Knockout method did not pick out some hair strands in the enlarged image 1, and the results of some points on the enlarged image 1 were distorted. In the Ruzon & Tomasi method, some hair strands are severely broken, and there are obvious discontinuities in the composite image. The effect of Chuang's method is better, but on closer inspection, it can be found that there is a slight discontinuity at the bottom of the enlarged image 2, and there is also a slight discontinuity in the enlarged image 1. The method according to the invention does not have the above-mentioned disadvantages in this example.

实施例2Example 2

图6中Chuang方法在放大图1中的两个椭圆内部的区域中抠图结果错误或者出现杂质。在上部的小椭圆内部,一部分发丝被强行割掉,这里的抠图结果是错误的,而在下面的大椭圆内部,则出现了一片杂质。本发明的方法则很好的处理了这些问题。In Figure 6, the Chuang method zooms in on the area inside the two ellipses in Figure 1, resulting in errors or impurities. Inside the upper small ellipse, a part of the hair was forcibly cut off, and the cutout result here is wrong, while inside the lower big ellipse, a piece of impurity appeared. The method of the present invention then handles these problems well.

实施例3~6Embodiment 3~6

图7中(a)图是Gandalf例子,(b)图是Galadriel例子,(c)图是Tiger例子,(d)图是Water例子。In Figure 7, (a) is an example of Gandalf, (b) is an example of Galadriel, (c) is an example of Tiger, and (d) is an example of Water.

数字图像处理中以任意图像为背景的快速抠图方法的要点是:The main points of the fast matting method with an arbitrary image as the background in digital image processing are:

1.手工进行区域划分,确保轮廓线经过合适的区域,并具有足够的精度;1. Manually divide the area to ensure that the contour line passes through the appropriate area and has sufficient accuracy;

2.颜色估计中用到的样本点为圆内部的轮廓线上的点,两个圆的半径的长度一般为最短距离的1.5~3.0倍;2. The sample points used in color estimation are points on the contour line inside the circle, and the length of the radius of the two circles is generally 1.5 to 3.0 times the shortest distance;

3.调整估计出来的前景和背景颜色,使C点转为规则点;3. Adjust the estimated foreground and background colors to turn point C into a regular point;

4.利用调整后的颜色来估计c点的alpha值。4. Use the adjusted color to estimate the alpha value of point c.

区域划分的精确与否对自然图像抠图的精度有很大的影响。抠图时应注意以下几点:①保证前景轮廓线内的点全部为前景点,背景轮廓线外的点全部为背景点,不能允许有交叉,否则将大大影响交叉区域的抠图精确度;②由于光照和空气的影响,人眼中物体的边界处总是有一点模糊。前景和背景轮廓线不要太靠近物体的边界,要留有一定的余地,保证过渡区域不划入前景或者背景区域。边界到两条轮廓线的距离大致相等;③尽量使轮廓线不穿过颜色突变剧烈的区域。The accuracy of region division has a great influence on the accuracy of natural image matting. The following points should be paid attention to when matting: ① Make sure that all points inside the foreground contour line are foreground points, and all points outside the background contour line are background points, and no intersection is allowed, otherwise the matting accuracy of the intersection area will be greatly affected; ②Due to the influence of light and air, the boundaries of objects in the human eye are always a little blurred. The foreground and background contour lines should not be too close to the boundary of the object, and a certain amount of room should be left to ensure that the transition area does not fall into the foreground or background area. The distance from the boundary to the two contour lines is approximately equal; ③ try to keep the contour lines from passing through areas with sharp color mutations.

本发明中前景和背景颜色的估计用到的样本点仅为轮廓线上的点,这使样本点的个数大大减小,提高了计算速度。The sample points used in the estimation of the foreground and background colors in the present invention are only the points on the contour line, which greatly reduces the number of sample points and improves the calculation speed.

本发明的颜色调整方案是整个方法的重点。它的核心就是把C点由不规则点转化为规则点,使α的求解能够利用公式(1)。在颜色的RGB比例不变的情况下,最小程度地调整颜色的亮度,利用人眼对颜色亮度的小范围变化不敏感的特点,把调整后前景和背景颜色代替原来估计出的颜色,来求得更合理的alpha值。The color adjustment scheme of the present invention is the focus of the whole method. Its core is to convert the point C from an irregular point to a regular point, so that the solution of α can use the formula (1). In the case that the RGB ratio of the color remains unchanged, the brightness of the color is adjusted to the minimum, and the human eye is not sensitive to small-scale changes in the brightness of the color, and the adjusted foreground and background colors replace the original estimated color to find Get a more reasonable alpha value.

Claims (4)

1.一种数字图像处理中以任意图像为背景的快速抠图方法,对图像进行区域划分,把它划分成三个部分:前景区域,未知区域和背景区域,其特征在于:其步骤为:1. in a kind of digital image processing, take arbitrary image as the fast matting method of background, carry out area division to image, it is divided into three parts: foreground area, unknown area and background area, it is characterized in that: its steps are: 1)根据分割的区域,对未知区域中的任意一点c,设其颜色为C,计算出其初始的前景和背景颜色分量 F和 B;所说初始的前景和背景颜色分量 F和 B的计算是:对于未知区域中的任意一点c,找出前景轮廓线和背景轮廓线上离c点距离最近的点f′和b′,点f′和b′离c点的距离分别为d1和d2,给定一个正实数θ,其中,1.0<θ≤10.0,以点c为圆心,分别以θd1和θd2长为半径,做两个同心圆C1和C2,设在圆C1内部且位于前景轮廓线上的所有点为f1、f2、……、fk,这些点离c点的距离为d11、d12、……、d1k,在圆C2内部且位于背景轮廓线上的所有点为b1、b2、……、bl,这些点离c点的距离为d21、d22、……、d2l,计算出fi,其中,i=1,2,...,k,点颜色的加权平均值 F &OverBar; = &Sigma; i = 1 k w 1 i f i , bj,其中,j=1,2,...,l,点颜色的加权平均值 B &OverBar; = &Sigma; j = 1 l w 2 j b j , 其中 w 1 i = &theta; &theta; - 1 - 1 &theta; - 1 &CenterDot; d 1 i d 1 , 式中,i=1,2,...,k, w 2 j = &theta; &theta; - 1 - 1 &theta; - 1 &CenterDot; d 2 j d 2 , 式中,j=1,2,...,l, F和 B就是所估计的初始的前景和背景颜色分量;1) According to the segmented area, for any point c in the unknown area, set its color as C, and calculate its initial foreground and background color components F and B; the calculation of said initial foreground and background color components F and B Yes: For any point c in the unknown area, find out the points f' and b' closest to point c on the foreground contour line and background contour line, and the distances between point f' and b' from point c are d 1 and d 2 , given a positive real number θ, where, 1.0<θ≤10.0, with point c as the center, and θd 1 and θd 2 as the radius, make two concentric circles C 1 and C 2 , set them at circle C All points inside 1 and located on the foreground contour line are f 1 , f 2 , ..., f k , and the distances from these points to point c are d 11 , d 12 , ..., d 1k , inside circle C 2 and All points on the background contour line are b 1 , b 2 , ..., b l , and the distances from these points to point c are d 21 , d 22 , ..., d 2l , and f i is calculated, where i= 1, 2, ..., k, weighted average of point colors f &OverBar; = &Sigma; i = 1 k w 1 i f i , b j , where, j=1, 2, ..., l, the weighted average of point colors B &OverBar; = &Sigma; j = 1 l w 2 j b j , in w 1 i = &theta; &theta; - 1 - 1 &theta; - 1 &Center Dot; d 1 i d 1 , In the formula, i=1, 2,..., k, w 2 j = &theta; &theta; - 1 - 1 &theta; - 1 &Center Dot; d 2 j d 2 , In the formula, j=1, 2, ..., 1, F and B are exactly estimated initial foreground and background color components; 2)据估计出的初始前景和背景颜色分量 F和 B,采取颜色调整措施调整为F和B的值,最后估计出c点的alpha值,所说的alpha值估计是:其步骤为:1)根据图像中前景物体和背景物体的颜色亮度差异,决定色差参数ρ的取值,2)根据 F和 B的颜色亮度比值λ与色差参数ρ的关系,调整 F和 B的值为F和B,3)根据调整后的F和B,由公式 &alpha; = ( C - B ) &CenterDot; ( F - B ) | | F - B | | 2 计算出未知区域中的一点c的alpha值α。2) According to the estimated initial foreground and background color components F and B, take color adjustment measures to adjust to the values of F and B, and finally estimate the alpha value of point c. The estimated alpha value is: the steps are: 1 ) Determine the value of the color difference parameter ρ according to the color brightness difference between the foreground object and the background object in the image, 2) adjust the values of F and B to F and B according to the relationship between the color brightness ratio λ of F and B and the color difference parameter ρ , 3) According to the adjusted F and B, by the formula &alpha; = ( C - B ) &CenterDot; ( f - B ) | | f - B | | 2 Calculate the alpha value α of a point c in the unknown area. 2.根据权利要求1所述的一种数字图像处理中以任意图像为背景的快速抠图方法,其特征在于所说的区域分割是:手工在图像的前景边缘画两条轮廓线,一条是前景轮廓线,处于这条轮廓线内部的点都是前景区域的点,另一条轮廓线为背景轮廓线,处于这条轮廓线之外的点都是背景区域的点,位于这两条轮廓线之内的点为未知区域的点,手工画轮廓线时,尽量使未知区域内不包含前景区域或背景区域的点。2. in a kind of digital image processing according to claim 1, take arbitrary image as the fast matting method of background, it is characterized in that said region segmentation is: manually draw two contour lines at the foreground edge of image, one is The foreground contour line, the points inside this contour line are the points of the foreground area, the other contour line is the background contour line, and the points outside this contour line are the points of the background area, located in these two contour lines The points within are the points of the unknown area. When manually drawing the contour line, try to make the unknown area not contain the points of the foreground area or the background area. 3.根据权利要求1所述的一种数字图像处理中以任意图像为背景的快速抠图方法,其特征在于色差参数ρ的取值是:当前景物体的亮度比背景物体大时,ρ的取值范围为1.0<ρ≤2.0;当前景物体的亮度比背景物体小时,ρ的取值范围为ρ>2.0。3. in a kind of digital image processing according to claim 1, take arbitrary image as the background fast matting method, it is characterized in that the value of color difference parameter ρ is: when the brightness of foreground object is bigger than background object, the value of ρ The value range is 1.0<ρ≤2.0; when the brightness of the foreground object is smaller than that of the background object, the value range of ρ is ρ>2.0. 4.根据权利要求1所述的一种数字图像处理中以任意图像为背景的快速抠图方法,其特征在于 F和 B的调整是:设 F=( Fr, Fg, Fb),B=( Br, Bg, Bb),C=(Cr,Cg,Cb),其中Ar,Ag,Ab为颜色A在RGB三个通道上的分量,这里A= F,B,C,计算lF= Fr+ Fg+ Fb,l B = Br+ Bg+ Bb,lC=Cr+Cg+Cb,比值λ=l F /l B ,此时分为三种情况讨论:①如果λ>1/ρ且lC>l F ,或者λ≤1/ρ且lC<l F ,则把 F调整为F=( Fr×lC/l F , Fg×lC/l F , Fb×lC/l F ), B不作调整,也即B= B,②如果λ>1/ρ且lC<l B ,或者λ≤1/ρ且lC>l B ,把 B调整为B=( Br×lC/l B , Bg×lC/l B , Bb×lC/l B ), F不作调整,也即F= F,③在其余的情况下, F和 B均不作调整,也即F= F,B= B。4. in a kind of digital image processing according to claim 1, take arbitrary image as the fast matting method of background, it is characterized in that the adjustment of F and B is: Let F=( F r , F g , F b ), B=( B r , B g , B b ), C=(C r , C g , C b ), where A r , A g , A b are the components of color A on the three channels of RGB, where A= F, B, C, calculate l F = F r + F g + F b , l B = B r + B g + B b , l C = C r + C g + C b , ratio λ = l F /l B , at this time it is divided into three situations for discussion: ①If λ>1/ρ and l C >l F , or λ≤1/ρ and l C <l F , then adjust F to F=( F r ×l C /l F , F g ×l C /l F , F b ×l C /l F ), B is not adjusted, that is, B= B, ②If λ>1/ρ and l C <l B , or λ≤ 1/ρ and l C >l B , adjust B to B=( B r ×l C /l B , B g ×l C /l B , B b ×l C /l B ), F is not adjusted, and That is F=F, ③ in the rest of the cases, F and B are not adjusted, that is F=F, B=B.
CN 03116447 2003-04-14 2003-04-14 Method for fast picking up picture with any image as background in digital image process Expired - Fee Related CN1224242C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 03116447 CN1224242C (en) 2003-04-14 2003-04-14 Method for fast picking up picture with any image as background in digital image process

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 03116447 CN1224242C (en) 2003-04-14 2003-04-14 Method for fast picking up picture with any image as background in digital image process

Publications (2)

Publication Number Publication Date
CN1445984A CN1445984A (en) 2003-10-01
CN1224242C true CN1224242C (en) 2005-10-19

Family

ID=27814871

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 03116447 Expired - Fee Related CN1224242C (en) 2003-04-14 2003-04-14 Method for fast picking up picture with any image as background in digital image process

Country Status (1)

Country Link
CN (1) CN1224242C (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7430321B2 (en) * 2004-09-09 2008-09-30 Siemens Medical Solutions Usa, Inc. System and method for volumetric tumor segmentation using joint space-intensity likelihood ratio test
JP2006293986A (en) * 2005-03-15 2006-10-26 Fuji Photo Film Co Ltd Album generating apparatus, album generation method and program
JP4704253B2 (en) * 2005-04-13 2011-06-15 富士フイルム株式会社 Album creating apparatus, album creating method, and program
CN100414981C (en) * 2005-11-09 2008-08-27 上海奇码数字信息有限公司 screen display control system
CN101188018B (en) * 2007-12-06 2010-08-25 北大方正集团有限公司 An automatic land return method and device in typeset
CN101582168B (en) * 2009-06-16 2011-06-15 武汉大学 Matting sample set construction method based on fuzzy connectedness
CN101588459B (en) * 2009-06-26 2011-01-05 北京交通大学 Video keying processing method
JP5526874B2 (en) * 2010-03-09 2014-06-18 富士ゼロックス株式会社 Image processing apparatus and image processing program
CN103559509B (en) * 2013-11-06 2017-02-08 汇隆基业科技(北京)有限责任公司 Real-time image matting method based on scene information
CN103714539B (en) * 2013-12-21 2016-05-18 浙江传媒学院 Numeral is scratched the interactive region partitioning method based on SVM in picture processing
CN105590307A (en) * 2014-10-22 2016-05-18 华为技术有限公司 Transparency-based matting method and apparatus
CN108446705B (en) * 2017-02-16 2021-03-23 华为技术有限公司 Method and device for image processing
CN110503657A (en) * 2019-08-26 2019-11-26 武汉众果科技有限公司 A method of picture quickly being carried out FIG pull handle
CN111861956A (en) * 2020-06-24 2020-10-30 北京金山云网络技术有限公司 Picture processing method and device, electronic equipment and medium

Also Published As

Publication number Publication date
CN1445984A (en) 2003-10-01

Similar Documents

Publication Publication Date Title
CN1224242C (en) Method for fast picking up picture with any image as background in digital image process
CN102761766B (en) Color Feature Extraction Method
WO2022028383A1 (en) Lane line labeling method, detection model determining method, lane line detection method, and related device
CN113469895B (en) Image highlight removing method based on color partition
CN1260682C (en) Natural image scratching method in digital image treatment based on HVS precessing
CN101783963A (en) Nighttime image enhancing method with highlight inhibition
CN113240685A (en) Image layering superpixel segmentation method and system, electronic device and storage medium
CN110866882B (en) Hierarchical joint bilateral filtering depth map inpainting method based on depth confidence
CN106097313A (en) Image partition method and device
CN117274405A (en) LED light working color detection method based on machine vision
CN107133936B (en) Digital halftoning method
CN102306307A (en) Positioning method of fixed point noise in color microscopic image sequence
CN1622638A (en) Image brightness correcting method of video monitoring system
CN106296599A (en) A kind of method for adaptive image enhancement
CN109523472B (en) Retinex color image enhancement method, computer vision processing system
CN1564198A (en) Natural image digging method based on sensing colour space
CN116862811A (en) Image enhancement method based on texture priori and color clustering
CN108765337A (en) A kind of single width color image defogging processing method based on dark primary priori Yu non local MTV models
CN109035331A (en) A kind of aligning method and apparatus of signal lamp group
CN111784702B (en) A scoring method for image segmentation quality
CN112749624B (en) Complex background image matting method based on deep learning semantic segmentation
CN119295633B (en) A method and system for rendering images through a generative digital model
CN112881253B (en) Method for determining pore area of rock casting body slice picture, face porosity calculation method and application of face porosity calculation method
CN117094903B (en) A brightness correction grayscale method based on color loss
CN103745438A (en) Haze removing method for large-area background light haze-containing image

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20051019