2

I want to compare an image of a document with a logo type or another picture to see if the logo is in the document.

The application to do this is going to use ASP.NET MVC 3 and C#.

After more searching i finded a solution with a extension of Bitmap that using 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;
    }
}
Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
RickardP
  • 2,558
  • 7
  • 34
  • 42

1 Answers1

0

I think that you want to use template matching functionalities. I would suggest using opencv for that. This is similar to this question

Community
  • 1
  • 1
Eric
  • 19,525
  • 19
  • 84
  • 147