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<BGR,byte> A =NewIMAGE<BGR,byte("738b4710b912c8fc453a8235fe039245d7882178.jpg"); IMAGE<BGR,byte> b =NewIMAGE<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