히스토그램 유사성에 따라 이미지 순위를 매기려고합니다. 나는 이미지를 가져오고 소스 이미지와 얼마나 비슷한 지에 따라 이미지의 데이터베이스와 히스토그램을 비교해야한다. 이것은 필터처럼 작동해야하며 가장 유사한 이미지를 가진 하위 그룹을 취한 다음 다른 방법과 비교하여보다 정확하고 값 비싼 컴퓨팅 (패턴 일치, SURF 등)을 비교해야합니다.BGR EmguCV를 사용한 히스토그램 비교
이 이미지의 배경에는 일부 이미지에는 파란색이 많이 들어 있고 라이브러리에는 파란색이 많은 이미지가 6 개 있으므로 이미지의 순위를 높이게됩니다. 다른 이미지를 내 코드는 이것이다이 시점에서 노란색 (파란색과 녹색)을 많이 ...
있습니다
Image<Bgr, byte> colorCard = frame.Copy();
DenseHistogram histBlue = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
DenseHistogram histRed = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
DenseHistogram histGreen = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
Image<Gray, byte> imgBlue = colorCard[0];
Image<Gray, byte> imgRed = colorCard[1];
Image<Gray, byte> imgGreen = colorCard[2];
imgBlue._EqualizeHist();
imgRed._EqualizeHist();
imgGreen._EqualizeHist();
//Also tried whithout equalizing histograms
histBlue.Calculate(new Image<Gray, byte>[] { imgBlue }, true, null);
histRed.Calculate(new Image<Gray, byte>[] { imgRed }, true, null);
histGreen.Calculate(new Image<Gray, byte>[] { imgGreen }, true, null);
List<Match> matchList = new List<Match>();
foreach (String filename in image_paths)
{
Image<Bgr, byte> imgToCompare = new Image<Bgr, byte>(filename);
imgToCompare = imgToCompare.PyrDown().PyrUp().PyrDown().PyrUp();
DenseHistogram histBlueToCompare = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
DenseHistogram histRedToCompare = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
DenseHistogram histGreenToCompare = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
Image<Gray, byte> imgBlueToCompare = colorCard[0];
Image<Gray, byte> imgRedToCompare = colorCard[1];
Image<Gray, byte> imgGreenToCompare = colorCard[2];
imgBlueToCompare._EqualizeHist();
imgRedToCompare._EqualizeHist();
imgGreenToCompare._EqualizeHist();
histBlueToCompare.Calculate(new Image<Gray, byte>[] { imgBlueToCompare }, true, null);
histRedToCompare.Calculate(new Image<Gray, byte>[] { imgRedToCompare }, true, null);
histGreenToCompare.Calculate(new Image<Gray, byte>[] { imgGreenToCompare }, true, null);
double cBlue = CvInvoke.cvCompareHist(histBlue, histBlueToCompare, Emgu.CV.CvEnum.HISTOGRAM_COMP_METHOD.CV_COMP_CORREL);
double cRed = CvInvoke.cvCompareHist(histRed, histRedToCompare, Emgu.CV.CvEnum.HISTOGRAM_COMP_METHOD.CV_COMP_CORREL);
double cGreen = CvInvoke.cvCompareHist(histGreen, histGreenToCompare, Emgu.CV.CvEnum.HISTOGRAM_COMP_METHOD.CV_COMP_CORREL);
double matchValue = (cBlue + cGreen + cRed)/3.0;
matchList.Add(new Match(matchValue, Path.GetFileNameWithoutExtension(filename)));
}
matchList = matchList.OrderBy(X => X.MatchValue).ToList<Match>();
foreach (Match m in matchList)
{
Logger.Log(m.Card + ": " + m.MatchValue);
}
나는 각각의 컬러 히스토그램을 비교할 수 있지만,이 비교를 병합하는 방법을 모른다
단일 값을 얻으려면. 마녀 (cBlue + cGreen + cRed)/3.0
나는 좋은 결과를 얻지 못한다.
이 작업을 수행하는 방법은 지구 이동 거리 (EMD)입니다. EmguCV에는 cvCalcEMD2
이라는 함수가 있지만 사용법 (매개 변수의 의미는 무엇인가)을 모르고 사용법의 예를 찾을 수 없습니다.