2012-02-09 3 views
0

누구나 PGH (Pairwise Geometric Histogram) 유사성 계산을위한 코드를 공유 할 수 있습니까? 나는 이미지 목록에서 가장 유사한 물체를 찾아야한다.OpenCV (Emgu)를 사용하는 PGH

다음 코드를 작성했지만 결과가 의미가 없습니다. 어리석은 실수를 저질렀다는 걸 알았고 나는 갇혀있다.

제안 사항? 이 여기, 사람을 도움이

public double GetBestPGHMatch(Contour<Point> currContour, List<Contour<Point>> 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<Point> 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 > match) match = c; 
     } 

     return match; 
    } 

답변

0

희망은 내가 경기 낮은 값이 클수록 따라서, 나는 데브 브 하타 차르 거리를 사용하고, 그것을 작동하는 방법입니다. 다른 측정 기준도 있지만 B- 거리가 내 필요에 가장 잘 맞았습니다.

public double pghMatchShape(Contour<Point> shape1, Contour<Point> shape2) 
    { 
     DenseHistogram hist1 = new DenseHistogram(
      new int[2] { 8, 8 }, 
      new RangeF[2] { new RangeF(-180, 180), new RangeF(100, 100) }); 
     DenseHistogram hist2 = new DenseHistogram(
      new int[2] { 8, 8 }, 
      new RangeF[2] { new RangeF(-180, 180), new RangeF(100, 100) }); 
     CvInvoke.cvCalcPGH(shape1, hist1.Ptr); 
     CvInvoke.cvCalcPGH(shape2, hist2.Ptr); 
     CvInvoke.cvNormalizeHist(hist1.Ptr, 100.0); 
     CvInvoke.cvNormalizeHist(hist2.Ptr, 100.0); 
     double corr = CvInvoke.cvCompareHist(hist1, hist2, HISTOGRAM_COMP_METHOD.CV_COMP_BHATTACHARYYA); 

     return corr; 
    } 
관련 문제