比较两个图像进行检查,如果他们是相同的图像、两个

2023-09-03 01:42:08 作者:风萧萧兮易水寒

这是比较两个图像(位图),以检查它们是否相同或有效的方法呢?

Which is the efficient way to compare two images (Bitmaps), to check if they are the same or not?

我一直在努力,记录了我和我读过,我需要重新大小两个图像左右16x16px,但我没有得到预期的结果。

I've tried to document me and I've read that I need to re-size both images to around 16x16px, but I don't get the expected result.

我试图用.Equals比较调整大小的图像:

I've tried to compare the resized images using .Equals:

    If img1.Equals(img2) then 
        msgbox("are equals!")
    End if

我见过的 AForge 图片库,但我无法找到任何方法中比较形象。

I've seen AForge image library but I can't found any method inside to compare Images.

有没有办法使用.NET类或第三方库没有硬codeA像素每个像素的图像比较器做一个有效的图像比较?如果不是,函数的任何一个例子来比较图像?

Is there way to do an efficient Image comparison using .NET classes or 3rd party libs without hardcode a pixel-per-pixel image comparer? If not, any example of a function to compare images?

推荐答案

您需要仔细考虑您的要求,什么平等的手段。如果你正在做一个直接的像素的像素比较,那么你可以找到无数的.NET图像类来帮助这个(我不是一个.NET专家,但尝试此处Image比较的图像之间的相似性的发现率)

You need to think carefully about your requirements and what equal means. If you are doing a direct pixel by pixel comparison, then you can find numerous .net image classes to help with this (I am not a .net expert but try here Image Comparison for find percentage of similarity between images )

当然,实现一个简单的直接图像的区别是相当容易的。你甚至可以允许有区别和其中的细微差别;门槛,这在上面的教程SO回答讨论。顺便说一下这个答案还提到SIFT,这是我没有意识到我已经提过之后。 SIFT是根据你的要求的好工具。

Of course implementing a simple direct image difference is fairly easy. You could even allow for slight differences with difference < threshold, which the tutorial in the above SO answer discusses. Incidentally this answer also mentions SIFT, which I did not realize until after I had mentioned it. SIFT is a good tool depending on your requirements.

在SIFT第三方工具是一个伟大的方式来比较,可以有细微变化的图像,但可能需要进行系统调用,因为我不知道,如果他们提供了一个.NET接口。权威网站SIFT实现: http://www.cs.ubc.ca/~罗威/关键点/

The SIFT 3rd party tool is a great way to compare images that can have slight variations, but you might have to make a system call as I am not sure if they provide a .net interface. The definitive website for SIFT implementation is: http://www.cs.ubc.ca/~lowe/keypoints/

我发现这个在互联网上: HTTP://www.nowozin .NET /塞巴斯蒂安/ TU-柏林-2006 / libsift / 号称是C#实现。

I did find this on the internet: http://www.nowozin.net/sebastian/tu-berlin-2006/libsift/ which claims to be a c# implementation.