title: matchTemplate with openCV in java
body: <p>i have a code like this:</p>
  
  <pre><code>Mat img = Highgui.imread(inFile);
  Mat templ = Highgui.imread(templateFile);
  int result_cols = img.cols() - templ.cols() + 1;
  int result_rows = img.rows() - templ.rows() + 1;
  Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
  Imgproc.matchTemplate(img, templ, result, Imgproc.TM_CCOEFF);
  /////Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
  for (int i = 0; i &lt; result_rows; i++)
  for (int j = 0; j &lt; result_cols; j++) 
    if(result.get(i, j)[0]&gt;?)
  
       //match!
  </code></pre>
  
  <p>I need to parse the input image to find multiple occurrencies of the template image. I want to have a result like this:</p>
  
  <pre><code>result[0][0]= 15%
  result[0][1]= 17%
  result[x][y]= 47%
  </code></pre>
  
  <p>If i use TM_COEFF all results are [-xxxxxxxx.xxx,+xxxxxxxx.xxx]</p>
  
  <p>If i use TM_SQDIFF all results are xxxxxxxx.xxx</p>
  
  <p>If i use TM_CCORR all results are xxxxxxxx.xxx</p>
  
  <p>How can i detect a match or a mismatch? What is the right condition into the if?
  If i normalized the matrix the application set a value to 1 and i can't detect if the template isn't stored into the image (all mismatch).</p>
  
  <p>Thanks in advance</p>