如何删除背景图像和得到的图像 [英] how to remove background image and get fore image

查看:261
本文介绍了如何删除背景图像和得到的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个图片



一个是背景图片另一个是人的照片具有相同的背景,相同的大小,我想做的是删除第二个图像的背景,并提炼个人的个人资料。通常的方法是从第二个图像减去第一个图像,但我的问题是如果人的磨损的颜色类似于背景。减法的结果是可怕的。我不能得到全民的个人资料。谁有好主意去除背景给我一些建议。
提前谢谢。

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.

推荐答案

如果您对图像背景有很好的估计,与人是一个良好的第一步。但这只是第一步。之后,您必须分割图片,即必须将图片分割为背景和前景像素,并使用以下限制:

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:


  1. 在背景区域,与背景图片的平均差异应该较高

  2. 在背景区域, b $ b
  3. 区域应该是平滑的。



b $ b

如果你在数学上倾向于,这些约束可以用Mumford-Shah函数完美地建模。 详情请参阅这里

但你可以改用其他分割算法来解决这个问题。

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:


  • 减去两个图像

  • 找到最大的连续blob具有背景前景差大于某一阈值的像素。这是对前景图像中的人物区域的第一粗略估计,但是分割不满足上述标准3和4.

  • 找到最大斑点的轮廓( EDIT:请注意,您不必从大纲开始,也可以从较大的多边形开始,因为步骤会自动将其缩小到最佳位置。)

  • 现在通过轮廓中的每个点并使轮廓平滑。即对于每个点找到最小化公式的点:c1 * L-c2 * G,其中L是轮廓多边形的长度,如果点在此处移动并且G是点将被移动到的位置处的梯度, c1 / c2是控制过程的常数。将点移动到该位置。这具有在源图像中的低梯度区域中平滑轮廓多边形的效果,同时保持其与源图像(即,人的可见边界)中的高梯度相关。你可以尝试L和G的不同表达式,例如,L可以考虑长度和曲率,G也可以采用背景中的渐变,并减去图像。

  • 您可能必须重新规范轮廓多边形,即确保轮廓上的点有规律地间隔。或者,或确保点之间的距离保持规则在之前的步骤。 (大地测量蛇)

  • 重复最后两个步骤直到收敛

  • subtract the two images
  • find the largest consecutive "blob" of pixels with a background-foreground difference greater than some threshold. This is the first rough estimate for the "person area" in the foreground image, but the segmentation does not meet the criteria 3 and 4 above.
  • Find the outline of the largest blob ( Note that you don't have to start at the outline. You can also start with a larger polygon, as the steps will automatically shrink it to the optimal position.)
  • now go through each point in the outline and smooth the outline. i.e. for each point find the point that minimizes the formula: c1*L - c2*G, where L is the length of the outline polygon if the point were moved here and G is the gradient at the location the point would be moved to, c1/c2 are constants to control the process. Move the point to that position. This has the effect of smoothing the contour polygon in areas of low gradient in the source image, while keeping it tied to high gradients in the source image (i.e. the visible borders of the person). You can try different expressions for L and G, for example, L could take the length and curvature into account, and G could also take the gradient in the background and subtracted images into account.
  • you probably will have to re-normalize the outline polygon, i.e. make sure that the points on the outline are spaced regularly. Either that, or make sure that the distances between the points stay regular in the step before. ("Geodesic Snakes")
  • repeat the last two steps until convergence

一个轮廓多边形,其触摸可见人物 - 背景边界并且在边界不可见或具有低对比度的地方平滑地继续。
查找Snakes(例如此处)了解更多信息。

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.

这篇关于如何删除背景图像和得到的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆