0

How could I make it where it will take 2 image files
.jpg or .bmp and compare them
and if they are alike to a point have a if statement of cursor

so if 85% like do this {

beep

}

thank you as always your help is great thank you

3
Contributors
2
Replies
6
Views
7 Years
Discussion Span
Last Post by Ravenheart
1

You could loop through each of the pixels and compare them as below but that would only work based on the same lighting etcetera. You will have to look at some more complex pattern matching algoritms for a more reliable method. It really depends on what you are using the app for.

Bitmap bmp1 = Bitmap.FromFile("\\...");
Bitmap bmp2 = Bitmap.FromFile("\\...");

    //... loop pixels
    sameColour += (bmp1.GetPixel(x, y) == bmp2.GetPixel(x, y)) ? 1 : 0;
    pixelCount ++;
0

I recommend the AForge.NET library.

Here is an example how it works:

bool MatchImages(Bitmap WhatToSearchFor, Bitmap TheImageInWhichToSearchFor)
        {
            bool result = false;

            TemplateMatch[] match = Match(WhatToSearchFor, TheImageInWhichToSearchFor);
            if (match.Length == 0)// no matching images could be found
            {
                return result;
            }
            if (match[0].Similarity > 0.90)// if a match is found check how similar it is to the image we're searching for
            {
                result = true; //its similar enough
            }
            return result;
        }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.