George Ge
asked on
How to recognize image A in image B in c#
Hello programmers. I need a liitle Help in Windows Forms. I want to write a Code that returns true if Bitmap Image A is in Bitmap Image B. For Example : B = Screenshoot and A = little Part of Screenshot(Icon) . Programm return True if B contains A and returns False if it isn't. Have anyone Idea how to do this.
I have found a Code in Internet but havenn't understand how it works :
public class BitmapExtensions
{
public bool Contains(this Bitmap template, Bitmap bmp)
{
const int divisor = 4;
const int epsilon = 10;
ExhaustiveTemplateMatching etm = new ExhaustiveTemplateMatching (0.9f);
TemplateMatch[] tm = etm.ProcessImage(new ResizeNearestNeighbor(temp late.Width / divisor, template.Height / divisor).Apply(template),
new ResizeNearestNeighbor(bmp. Width / divisor, bmp.Height / divisor).Apply(bmp));
if (tm.Length == 1)
{
Rectangle tempRect = tm[0].Rectangle;
if(Math.Abs(bmp.Width / divisor - tempRect.Width) < epsilon && Math.Abs(bmp.Height / divisor - tempRect.Height) < epsilon)
{
return true;
}
}
return false;
}
}
Have any one Idea how to solve my problem.
I have found a Code in Internet but havenn't understand how it works :
public class BitmapExtensions
{
public bool Contains(this Bitmap template, Bitmap bmp)
{
const int divisor = 4;
const int epsilon = 10;
ExhaustiveTemplateMatching
TemplateMatch[] tm = etm.ProcessImage(new ResizeNearestNeighbor(temp
new ResizeNearestNeighbor(bmp.
if (tm.Length == 1)
{
Rectangle tempRect = tm[0].Rectangle;
if(Math.Abs(bmp.Width / divisor - tempRect.Width) < epsilon && Math.Abs(bmp.Height / divisor - tempRect.Height) < epsilon)
{
return true;
}
}
return false;
}
}
Have any one Idea how to solve my problem.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER