Compare two images to check if they are the same

故事扮演 提交于 2019-12-22 10:47:17

问题


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

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.

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

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

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

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?


回答1:


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 )

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.

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/

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



来源:https://stackoverflow.com/questions/19440001/compare-two-images-to-check-if-they-are-the-same

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!