title: PGH using OpenCV (Emgu)
body: <p>Could anyone share their code for calculating the PGH (Pairwise Geometric Histogram) similarity ? I need to find the most similar object from within a list of images. </p>
  
  <p>I have written up the following code, but the results make no sense. I'd bet I am doing a silly error, and I am stuck.</p>
  
  <p>Any suggestions?</p>
  
  <pre><code> public double GetBestPGHMatch(Contour&lt;Point&gt; currContour, List&lt;Contour&lt;Point&gt;&gt; ContoursList)
      {
          double match = -1.0d;
          DenseHistogram histCurrContour = new DenseHistogram(
                                                         new int[2]
                                                                  {
                                                                      currContour.Total,
                                                                      currContour.Total,
                                                                  },
                                                          new RangeF[2]
                                                                  {
                                                                      new RangeF(0, 100),
                                                                      new RangeF(0, 100)
                                                                  }
                                                     );
  
          CvInvoke.cvCalcPGH(currContour.Ptr, histCurrContour.Ptr);
          foreach (Contour&lt;Point&gt; contour in ContoursList)
          {
              DenseHistogram hist = new DenseHistogram(
                                                new int[2]
                                                                  {
                                                                      currContour.Total,
                                                                      currContour.Total,
                                                                  },
                                                  new RangeF[2]
                                                                  {
                                                                      new RangeF(0, 100),
                                                                      new RangeF(0, 100)
                                                                  }
                                            );
  
              CvInvoke.cvCalcPGH(contour.Ptr, hist.Ptr);
              double c = CvInvoke.cvCompareHist(histCurrContour.Ptr, hist.Ptr, Emgu.CV.CvEnum.HISTOGRAM_COMP_METHOD.CV_COMP_CORREL);
              if (c &gt; match) match = c;
          }
  
          return match;
      }
  </code></pre>