c# - 如何检查 Logo /图像是否在图像中?

标签 c# image photo graphical-logo

我想将文档的图像与 Logo 类型或另一张图片进行比较,以查看 Logo 是否在文档中。

执行此操作的应用程序将使用 ASP.NET MVC 3 和 C#。

经过更多搜索后,我找到了一个使用 AForge 扩展位图的解决方案:

public static class BitmapExtensions
{
    /// <summary>
    /// See if bmp is contained in template with a small margin of error.
    /// </summary>
    /// <param name="template">The Bitmap that might contain.</param>
    /// <param name="bmp">The Bitmap that might be contained in.</param>        
    /// <returns>You guess!</returns>
    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;
    }
}

最佳答案

我认为您想使用模板匹配功能。我建议为此使用 opencv。这是 similar to this question

关于c# - 如何检查 Logo /图像是否在图像中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14941205/

相关文章:

c# - 如何在wcf中处理客户端上下文(sharepoint online)?

c# - 通过单击超链接打开文件不起作用

html - 如何使用 HTML 和 CSS 更改图像?

mysql - 试图避免 "Polymorphic Associations"并维护外键参照完整性

java - 如何将 ImageView 列表设置为 RecyclerView

c# - 组合框触发空选择

c# - 未从 WorkItemCollection 获取字段 "Assigned To"和 "Last update date of Workitem"

java - BufferedImage 颜色 channel 蒙版

ios - ios中的六边形网格

unity-game-engine - 我可以使用设备的相机在 Unity 中拍照吗?