这是我想做的:

我定期用网络摄像头拍照。就像时间流逝一样。然而,如果没有什么真正的改变,也就是说,图片看起来几乎相同,我不想存储最新的快照。

我想有某种方法可以量化这种差异,我必须根据经验确定一个阈值。

我追求的是简单而不是完美。 我用的是python。


当前回答

I have been having a lot of luck with jpg images taken with the same camera on a tripod by (1) simplifying greatly (like going from 3000 pixels wide to 100 pixels wide or even fewer) (2) flattening each jpg array into a single vector (3) pairwise correlating sequential images with a simple correlate algorithm to get correlation coefficient (4) squaring correlation coefficient to get r-square (i.e fraction of variability in one image explained by variation in the next) (5) generally in my application if r-square < 0.9, I say the two images are different and something happened in between.

这是强大的和快速的在我的实现(Mathematica 7)

这是值得玩转的部分,你感兴趣的图像,并通过裁剪所有的图像到那个小区域,否则一个远离相机但重要的变化将被错过。

我不知道如何使用Python,但我确信它也有相关性,不是吗?

其他回答

我也遇到了同样的问题,写了一个简单的python模块,使用pillow的ImageChops来比较两个相同大小的图像,创建一个黑白差异图像,并总结直方图值。

你可以直接得到这个分数,也可以得到一个百分比值,与完整的黑白差异进行比较。

它还包含一个简单的is_equal函数,可以在图像传递为相等的情况下(并包括)提供一个模糊阈值。

这种方法不是很详细,但可能对其他正在与相同问题斗争的人有用。

https://pypi.python.org/pypi/imgcompare/

看看Haar小波是如何由isk-daemon实现的。你可以使用它的imgdb c++代码来实时计算图像之间的差异:

disk -daemon是一个开源的数据库服务器,能够将基于内容的(可视的)图像搜索添加到任何与图像相关的网站或软件。 这项技术允许任何与图像相关的网站或软件的用户在小部件上绘制他们想要查找的图像,并让网站回复他们最相似的图像或简单地在每个图像详细页面请求更多相似的照片。

一个简单的解决方案:

将图像编码为jpeg格式,并寻找文件大小的实质性变化。

我曾经用视频缩略图实现过类似的东西,并且取得了很大的成功和可伸缩性。

你见过寻找相似图像的算法问题吗?请查看相关建议。

我建议对你的框架进行小波变换(我已经写了一个使用Haar变换的C扩展);然后,比较两张图片之间最大(比例)小波因子的索引,你应该得到一个数值相似近似。

I have been having a lot of luck with jpg images taken with the same camera on a tripod by (1) simplifying greatly (like going from 3000 pixels wide to 100 pixels wide or even fewer) (2) flattening each jpg array into a single vector (3) pairwise correlating sequential images with a simple correlate algorithm to get correlation coefficient (4) squaring correlation coefficient to get r-square (i.e fraction of variability in one image explained by variation in the next) (5) generally in my application if r-square < 0.9, I say the two images are different and something happened in between.

这是强大的和快速的在我的实现(Mathematica 7)

这是值得玩转的部分,你感兴趣的图像,并通过裁剪所有的图像到那个小区域,否则一个远离相机但重要的变化将被错过。

我不知道如何使用Python,但我确信它也有相关性,不是吗?