【问题标题】:How to check if logo/image is in a image?如何检查徽标/图像是否在图像中?
【发布时间】:2013-02-03 04:09:13
【问题描述】:

我想将文档的图像与徽标类型或其他图片进行比较,以查看徽标是否在文档中。

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

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

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;
    }
}

【问题讨论】:

标签: c# image photo graphical-logo


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 1970-01-01
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 2019-09-04
    相关资源
    最近更新 更多