如何删除背景图像并获得前景图像
有两张图片
alt text http://bbs.shoucangshidai.com/attachments/month_1001/1001211535bd7a644e95187acd.jpg 替代文本http://bbs.shoucangshidai.com/attachments/month_1001/10012115357cfe13c148d3d8da.jpg 一张是背景图像,另一张是具有相同背景、相同尺寸的人的照片,我想要做的是删除第二张图像的背景并仅提取该人的个人资料。常见的方法是从第二张图像中减去第一张图像,但我的问题是人的穿着颜色是否与背景相似。减法的结果很糟糕。我无法获得整个人的个人资料。谁有去除背景的好主意给我一些建议。 先感谢您。
there are two images
alt text http://bbs.shoucangshidai.com/attachments/month_1001/1001211535bd7a644e95187acd.jpg
alt text http://bbs.shoucangshidai.com/attachments/month_1001/10012115357cfe13c148d3d8da.jpg
one is background image another one is a person's photo with the same background ,same size,what i want to do is remove the second image's background and distill the person's profile only. the common method is subtract first image from the second one,but my problem is if the color of person's wear is similar to the background. the result of subtract is awful. i can not get whole people's profile. who have good idea to remove the background give me some advice.
thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您对图像背景有很好的估计,那么从人物图像中减去它是一个很好的第一步。但这只是第一步。之后,您必须对图像进行分割,即必须将图像划分为“背景”和“前景”像素,并具有如下约束:
如果您有数学倾向,则可以使用 Mumford-Shah 函数完美地对这些约束进行建模。 请参阅此处了解更多信息。
但是您可能可以调整其他细分问题的算法。
如果您想要一个快速且简单(但不完美)的版本,您可以尝试以下操作:
您现在有一个轮廓多边形,它接触可见的人物背景边界,并在边界不可见或对比度较低的地方平滑地继续。
查找“Snakes”(例如此处)了解更多信息。
If you have a good estimate of the image background, subtracting it from the image with the person is a good first step. But it is only the first step. After that, you have to segment the image, i.e. you have to partition the image into "background" and "foreground" pixels, with constraints like these:
If you are mathematically inclined, these constraints can be modeled perfectly with the Mumford-Shah functional. See here for more information.
But you can probably adapt other segmentation algorithms to the problem.
If you want a fast and simple (but not perfect) version, you could try this:
You now have an outline polygon that touches the visible person-background border and continues smoothly where the border is not visible or has low contrast.
Look up "Snakes" (e.g. here) for more information.
在减去图像之前对图像进行低通滤波(模糊)。
然后使用该差异信号作为掩模来选择感兴趣的像素。
足够宽的滤波器将忽略太小的(高频)特征,这些特征最终会在您感兴趣的对象内雕刻出“可怕”的区域。它还会减少像素级噪声和未对准(最高频率信息)的突出显示。
此外,如果您有两个以上的帧,引入一些时间滞后也可以让您随着时间的推移形成更稳定的感兴趣区域。
Low-pass filter (blur) the images before you subtract them.
Then use that difference signal as a mask to select the pixels of interest.
A wide-enough filter will ignore the too-small (high-frequency) features that end up carving out "awful" regions inside your object of interest. It'll also reduce the highlighting of pixel-level noise and misalignment (the highest-frequency information).
In addition, if you have more than two frames, introducing some time hysteresis will let you form more stable regions of interest over time too.
我认为常见的一种技术是使用混合模型。获取多个背景帧,并为每个像素为其颜色构建一个混合模型。
当您应用其中包含人物的帧时,根据每个像素的混合模型中的概率密度,您将获得该颜色是前景或背景的一定概率。
在获得 P(像素是前景)和 P(像素是背景)之后,您可以对概率图像进行阈值处理。
另一种可能性是使用概率作为一些更聪明的分割算法的输入。一个例子是 图形切割,我注意到它效果很好。
然而,如果该人穿着在视觉上与背景难以区分的衣服,显然上述方法都不起作用。你要么必须获得另一个传感器(如红外线或紫外线),要么拥有一个非常复杂的“人物模型”,如果它发现它认为是躯干和头部,它可以将腿“添加”到正确的位置。
祝项目顺利!
One technique that I think is common is to use a mixture model. Grab a number of background frames and for each pixel build a mixture model for its color.
When you apply a frame with the person in it you will get some probability that the color is foreground or background, given the probability densities in the mixture model for each pixel.
After you have P(pixel is foreground) and P(pixel is background) you could just threshold the probability images.
Another possibility is to use the probabilities as inputs in some more clever segmentation algorithm. One example is graph cuts which I have noticed works quite well.
However, if the person is wearing clothes that are visually indistguishable from the background obviously none of the methods described above would work. You'd either have to get another sensor (like IR or UV) or have a quite elaborate "person model" which could "add" the legs in the right position if it finds what it thinks is a torso and head.
Good luck with the project!
背景与前景检测是非常主观的。应用场景定义背景或前景。然而,在您详细介绍的应用程序中,我猜您隐含地说该人是前景。
使用上述假设,您寻求的是人员检测算法。一个可能的解决方案是:
瞧……你应该有一个简单的人物检测器。
Background vs Foreground detection is very subjective. The application scenario defines background or foreground. However in the application you detail, I guess you are implicitly saying that the person is the foreground.
Using the above assumption, what you seek is a person detection algorithm. A possible solution is:
voila... you should have a simple person detector.
您可以逐个像素地遍历两个图像,而不是直接进行减法,并且仅“减去”完全相同的像素。但这当然不能解释颜色的微小差异。
Instead of a straight subtraction, you could step through both images, pixel by pixel, and only "subtract" the pixels which are exactly the same. That of course won't account for minor variances in colors, though.
将照片发布到 Craigslist 上,并告诉他们您将支付 5 美元请人拍摄。
保证您会在几分钟内获得点击。
Post the photo on Craigslist and tell them that you'll pay $5 for someone to do it.
Guaranteed you'll get hits in minutes.