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
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
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 ++;
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;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.