title: Find (x,y) subpixel coordinates of a maximum using discrete quadratic interpolation
body: <p>I have to find the subpixel <code>(x,y)</code> coordinates of the maximum value given a set of discrete points.<br>Im ny case, I run <code>cv::matchTemplate</code> function that slides a model window along an image and returns a score value for each pixel position.<br>The result is an image with the score for each position and the location <code>(x0, y0)</code> with of the maximum value, like these values around the maximum value found:</p>
  
  <pre><code>      x_1    x0     x1
  y_1 |0.91 | 0.89 | 0.90|
  y0  |0.92 | 0.99 | 0.89|
  y1  |0.95 | 0.95 | 0.90|
  </code></pre>
  
  <p>I would like to use a quadratic interpolation to find where are the subpixel point coordinates of the interpolated maximum value, using just the nearest neighbors.<br>
  In a 1d case, I use this formula (assuming <code>x0</code> is the origin):</p>
  
  <pre><code>interpolated_x = (x_1-x1)/(2.*(x_1-2.*x0+x1));
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>  x_1    x0     x1
  |0.92 | 0.99 | 0.89|
  </code></pre>
  
  <p>you get <code>interpolated_x = -0.08823</code>, that is correctly slightly on the left of x0.</p>
  
  <p>Is there some C++ code for the 2d case?</p>