简体   繁体   English

通过用户输入进行背景扣除

[英]Background Substraction with user input

I am looking for an algorithm or, even better, some library that covers background substraction from a single static image (no background model available). 我正在寻找一种算法,或者甚至更好的是,某个库涵盖了从单个静态图像中扣除背景(没有可用的背景模型)。 What whould be possible though is some kind of user input like for example https://clippingmagic.com does it. 不过,可能会出现某种用户输入,例如https://clippingmagic.com Sadly my google fu is bad here as i cant find any papers on that topic with my limited amount of keywords. 遗憾的是,我的Google Fu在这里不好,因为我用有限的关键字找不到关于该主题的任何论文。

That webpage is really impressive. 该网页确实令人印象深刻。 If I were to try and implement something similar I would probably use k-means clustering using the CIELAB colorspace . 如果我要尝试实现类似的东西,则可能会使用CIELAB colorspace进行 k-means聚类 The reason for changing the colorspace is so that colors can be represented by two points rather than 3 as a regular RGB image. 更改颜色空间的原因是,可以用两点而不是3点的颜色来表示常规的RGB图像。 This should speed up clustering. 这将加速群集。 Additionally, the CIELAB color space was build for this purpose, finding "distances" (similarities) between colors and accounts for the way humans perceive color. 此外,CIELAB颜色空间就是为此目的而建立的,它可以发现颜色之间的“距离”(相似性),并解释人类对颜色的感知方式。 Not just looking at the raw binary data the computer has. 不只是查看计算机具有的原始二进制数据。

But a quick overview of kmeans. 但是简要介绍一下kmeans。 For this example we will say k=2 (meaning only two clusters) 在此示例中,我们将说k = 2(仅意味着两个群集)

  1. Initialize each cluster with a mean. 用均值初始化每个聚类。
  2. Go through every pixel in your image and decide which mean it is closer to, cluster 1 or 2? 遍历图像中的每个像素,并确定哪个更接近簇1或2?
  3. Compute the new mean for your clusters after you've processed all the pixels 处理完所有像素后,为群集计算新的均值
  4. using the newly computed means repeat steps 2-4 until convergence (meaning the means don't change very much) 使用新计算的均值重复步骤2-4,直到收敛为止(意味着均值变化不大)

Now that would work well when the foreground image is notably different than the background. 现在,当前景图像与背景明显不同时,这将很好地工作。 Say a red ball in a blue background, but if the colors are similar it would be more problematic. 在蓝色背景下说一个红色的球,但是如果颜色相似,就会出现更多问题。 I would still stick to kmeans but have a larger number of clusters. 我仍然会坚持kmeans,但拥有更多的集群。 So on that web page you can make multiple red or green selections. 因此,在该网页上,您可以选择多个红色或绿色。 I would make each of these strokes a cluster, and intialize my cluster to the mean. 我将这些笔画中的每一个都作为一个簇,并将我的簇初始化为均值。 So say I drew 3 red strokes, and 2 green ones. 假设我画了3个红色笔画和2个绿色笔画。 That means I'd have 5 groups. 这意味着我将有5个小组。 But somehow internally I add an extra attribute as foreground/background. 但是在某种程度上,我在内部添加了一个额外的属性作为前景/背景。 So that each cluster will have a small variance, but in the end, I would only display that attribute, foreground or background. 这样每个聚类会有很小的差异,但是最后,我只会显示该属性,前景或背景。 I hope that made sense. 我希望这是有道理的。

Maybe now you have some search terms to start off with. 也许现在您有了一些搜索词 There may be many other methods but this is the first I thought of, good luck. 可能还有许多其他方法,但这是我想到的第一个,祝您好运。

EDIT 编辑

After playing with the website a bit more I see it uses spatial proximity to cluster. 在玩了更多网站之后,我看到它使用空间接近度来聚类。 So say I had 2 identical red blobs on opposite sides of the image. 可以这么说,我在图像的相对两侧有两个相同的红色斑点。 If I only annotate the left side of the image the blob on the right side might not get detected. 如果仅注释图像的左侧,则可能无法检测到右侧的斑点。 Kmeans wouldn't replicate this behavior since the method I described only uses the color to cluster pixels completely oblivious to their location in the image. Kmeans不会复制此行为,因为我描述的方法仅使用颜色将像素完全聚类,而完全不考虑它们在图像中的位置。

I don't know what tools you have at your disposal but here is a nice matlab example/tutorial on color based kmeans 我不知道您可以使用哪些工具,但这是基于颜色的kmeans的一个不错的matlab示例/教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM