2

I would like to know if there is a way that I can determine whether or not two images are the same (there are lots of posts on that topic, I know), but it's also possible that one picture is a compressed version of the other image...

This post also asks for a C# library that does image processing and comparing, but I'm not really sure what kind of functions a library would need to provide this specific match.. This post on the other hand is way to abstract. I've read about OpenCV (or this .NET wrapper) but I have no experience with it, and I'm not sure if it will do what I want without applying the abstractions from the that post I didn't understand myself.. I mean, OpenCV is probably capable of doing the required computations, it seems like a very powerful tool, but it seems a bit complex for the seemingly simple requirement.. Or is this actually more complex and is something like OpenCV the way to go? (and if so, how?)

So, how would I go about achieving this?

Community
  • 1
  • 1
Thomas Mulder
  • 740
  • 10
  • 26
  • 1
    Load'em as bitmaps and check each pixel colour? Labour intensive. Likely a very bad suggestion, but a suggestion nonetheless. – Grant Thomas Jun 02 '16 at 13:40
  • Unless you have a special definition if bitmaps being the same you need to compare all pixels of the (uncompressed) bitmaps. Do use LockBits or unsafe for proper speed! – TaW Jun 02 '16 at 14:12
  • If they are photographs (i.e. not line drawings that are mostly one color) then you can probably get away with sampling a few thousand random positions in each image at corresponding locations and comparing them using sum of difference squared. This can easily be made to work for resized images too. – samgak Jun 03 '16 at 01:10

1 Answers1

2

One simple path you could try is AForge .NET library. It is fully .NET implementation so no worries about environment setup, and has following functionality, that might fit your case :

ExhaustiveTemplateMatching Class

"The class implements exhaustive template matching algorithm, which performs complete scan of source image, comparing each pixel with corresponding pixel of template. The class also can be used to get similarity level between two images of the same size, which can be useful to get information about how different/similar are images"

http://www.aforgenet.com/framework/docs/html/17494328-ef0c-dc83-1bc3-907b7b75039f.htm

// create template matching algorithm's instance
// use zero similarity to make sure algorithm will provide anything
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);

// compare two images
TemplateMatch[] matchings = tm.ProcessImage(image1, image2);
// check similarity level
if (matchings[0].Similarity > 0.95f)
{
    // do something with quite similar images
}
Edgars Pivovarenoks
  • 1,526
  • 1
  • 17
  • 31
  • Project got sidetracked a bit, but this will probably be the way to go when I pick it up again in order to avoid throwing myself at complex math. Thanks for your suggestion! – Thomas Mulder Aug 08 '16 at 14:20