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;
}