如何使用Node.js比较两个图像

我正在寻找一种方法来比较两个图像,看看他们是多么相似。 使用谷歌search会产生大量的image processing结果(裁剪,重新resize等),但没有什么会做近似的图像比较。 有一个Node.js库,但它是0.0.1版本,依赖于各种第三方系统包,所以不稳定或便携。

沿着这些线路的东西:

var imgComparator = require('some-awesome-image-comparator-module'); // result would be between 1.0 and 0.0, where 1.0 would mean exact match var result = imgComparator.compare('/path/to/image/1.png', '/path/to/image/2.png'); 

有node-opencv模块,你可以使用它来执行像图像比较这样的繁重操作。 好的话题就在这里: 比较图像的相似性的简单而快速的方法

也有图像差异看起来非常有前途,这是由Uber。

 var imageDiff = require('image-diff') imageDiff({ actualImage: 'checkerboard.png', expectedImage: 'white.png' }, function (err, imagesAreSame) { // error will be any errors that occurred // imagesAreSame is a boolean whether the images were the same or not // diffImage will have an image which highlights differences }) 

我find了这个库,可能对你有用

https://github.com/HumbleSoftware/js-imagediff