title: compare 2 histograms with Chi-Square
body: <p>i want to compare 2 Histograms, which have 2 dimensions.
  For this i want to use the <strong>Chi-Square</strong>-Metric.
  My comparator looks like this function:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>double Histogram::compareHistogram(Histogram *hist){
      double result=0;
      double a=0;
      double b=0;
      for (int y=0 ; y &lt; bins_1 ; y++) {
           for (int x=0 ; x &lt; bins_2 ; x++) {
               a=getHistogramValue(x,y)-hist-&gt;getHistogramValue(x,y);
               b=getHistogramValue(x,y)+hist-&gt;getHistogramValue(x,y);
               if(fabs(b)&gt;0.0){
                 result+=a*a/b;
               }
           }
      }
      return result;
  }
  </code></pre>
  
  <p>I've compared the result with the result of OpenCv's cv::<code>compareHist()</code> function and it is different. I don't know why.</p>
  
  <p>Before i compared the histograms, i norm the histograms with the MINMAX-Norm. 
  I compared my normed histogram with the normed histogram  of openCV and they are equal. 
  So I think, the problem is in my compareHist function.
  But where?</p>
  
  <p>Best regards,</p>