EMGUCV functions in the image Class (iv) template matching using the Matchtemplate function

Source: Internet
Author: User

The function prototype for Matchtemplate is

method);

There are 6 kinds of detection methods of Templatematchingtype
1, square difference matching Sqdiff
The best match is 0. The worse the match, the greater the matching value.
2. Relevant matching Ccorr
A larger number indicates a high degree of matching and 0 is the worst matching effect.
3 related matches Ccoeff
1 is the perfect match, 1 indicates the worst match, and 0 means there is no correlation (random sequence).
4, the standard square difference matching sqdiffnormed
The minimum value represents the best match
5. Standard related matching ccorrnormed
Maximum value is best match
6. Standard related matching ccoeffnormed
Maximum value is best match

Principle:
Move one pixel at a time through an image block (from left to right, from top to bottom). In each position, a metric calculation is performed to illustrate the similarity between the image block and the specific area of the original image.

Use the following:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingEMGU.CV;usingEmgu.CV.CvEnum;usingEmgu.CV.Structure;usingEmgu.CV.Util;usingEmgu.util;usingEmgu.cv.ui;namespace emgucvhist{ Public Partial classForm1:form { Public Form1() {InitializeComponent (); IMAGE&LT;BGR,byte> A =NewIMAGE&LT;BGR,byte("738b4710b912c8fc453a8235fe039245d7882178.jpg"); IMAGE&LT;BGR,byte> b =NewIMAGE&LT;BGR,byte> ("Qq20150827003943.png"); Image<gray,float> c =NewImage<gray,float> (a.width, A.height); c = a.matchtemplate (b, templatematchingtype.ccorrnormed);Doublemin=0, max=0; Point Maxp =NewPoint (0,0); Point MINP =NewPoint (0,0); Cvinvoke.minmaxloc (c,refMinrefMaxrefMINP,refMAXP); Console.WriteLine (min +" "+ max);//cvinvoke.normalize (c, c);Cvinvoke.rectangle (A,NewRectangle (MAXP,NewSize (B.width, b.height)),NewMcvscalar (0,0,255),3);        Imagebox1.image = A; }    }}

: The middle is the run diagram

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

EMGUCV functions in the image Class (iv) template matching using the Matchtemplate function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.