在阅读了本网站上有关图像比较主题的许多相关帖子后,我想我会尝试在每个图像上实现 PCA,以查看图像是否“相似”,但我不确定如何从我的图像中获取数据 - 是否有一个 VB 函数可以用来将图像转换为字节数组或其他内容以便比较图像?或者比较两个图像的更简单的方法(应该是黑白的,但它们会被扫描,v.小图像)
非常感谢,
贝基
After reading many related posts on this site on the subject of image comparison I'm thinking I'll try implementing a PCA on each image in order to see if an image is 'similar' or not, but I'm not sure how to get the data from my images - is there a VB function that I can use to convert the image into an array of bytes or something in order to compare images? Or a simpler way to compare two images (should be black and white but they'll be scanned, v. small images)
Thanks very much,
Becky
发布评论
评论(5)
另外,这是一篇有用的文章:这个人拍摄了两张图像,比较了它们,然后创建了第三张图像,以图形方式表示两者之间的差异。这似乎是描述相似性的一种很好的视觉方式。
Also, here is a useful article: this guy took two images, compared them, then created a third image that graphically represented the difference between the two. It appears to be a nice visual way to depict similiarity.
使用 roygbiv 的答案来查看它们是否相同非常容易。要了解它们的相似程度相当复杂。如果这些是扫描文档,它们实际上永远不会完全相同。投资第三方选项可能是值得的。我们在扫描过程中使用 Accusoft 和 TiS。
也就是说,有一些潜在的重复 问题。
To see if they're identical or not is quite easy using roygbiv's answer. To see how similar they are is quite complicated. If these are scanned documents they're really never going to be identical. It may be worthwhile to invest in a third party option. We use products in our scanning process from Accusoft and TiS.
That said, there are a couple of potential duplicate questions.
你可以使用一些东西:
You can use something:
所以,这就是我想出的办法。我没有单独比较像素,而是使用了根据文件内容提供的哈希算法。然后它比较返回的散列的各个字节。在我的测试中,它的返回速度是比较 1152 X 720 和 101KB 大的灰度位图图像的各个像素的速度的两倍。
这是代码:(
编辑是因为我第一次发布代码时一切看起来都很奇怪。删除了注释。)
So, this is what I came up with. Rather than compare the pixels individually, I used a hashing algorithm fed from the contents of the file. It then compares the individual bytes of the returned hash. In my tests, it came back twice as fast as comparing the individual pixels for a gray-scale bitmap image 1152 X 720 and 101KB big.
Here's the code:
(editing because the first time I posted the code everything looked strange. removed comments.)
用于检索图像的像素数据;您可以使用 Bitmap.GetPixel 或Bitmap.LockBits,这将为您提供 BitmapData(链接有示例代码) 类作为回报。
For retrieving the pixel data of an image; you can either use Bitmap.GetPixel or Bitmap.LockBits, which will give you a BitmapData (link has example code) class in return.