C#检查另一个图像中是否存在图像

我不知道从哪里开始,所以一些指导会很好。 我需要做的是,检查一个大图像(比如1280×1024)并检查其中是否存在另一个较小的图像(可能是一个50×50像素的图像)。

我尝试通过比较每个非常慢的像素来做到这一点,我可能需要做100次以上,所以看起来不合适。 我只是想知道是否有更好的方法?

谢谢

我正在研究类似的东西,我想出的快速而肮脏的结果是使用AForge.Net的“ExhaustiveTemplateMatching”实现其图像尺寸的1/4。 完整尺寸的720p图像花了几分钟,但是在1/4大小的情况下,在我微不足道的计算机上大约一秒钟。

public static class BitmapExtensions { ///  /// See if bmp is contained in template with a small margin of error. ///  /// The Bitmap that might contain. /// The Bitmap that might be contained in. /// You guess! public static bool Contains(this Bitmap template, Bitmap bmp) { const Int32 divisor = 4; const Int32 epsilon = 10; ExhaustiveTemplateMatching etm = new ExhaustiveTemplateMatching(0.9f); TemplateMatch[] tm = etm.ProcessImage( new ResizeNearestNeighbor(template.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; } } 

你当然也可以检查tm.length> 0,是的,那里有一些不必要的分歧:P