[code cpp] double CompareHistogram(IplImage* BufSrc, IplImage* BufRef)
{
double dfScore;
int nHistoSize = 256;
float ranges[] = { 0, 256 };
float *hist_range[] = { ranges }; CvHistogram *histSrc = cvCreateHist(1, &nHistoSize, CV_HIST_ARRAY, hist_range);
CvHistogram *histRef = cvCreateHist(1, &nHistoSize, CV_HIST_ARRAY, hist_range);
cvCalcHist(&BufSrc, histSrc, 0, NULL );
cvCalcHist(&BufRef, histRef, 0, NULL ); cvNormalizeHist( histSrc, 100);
cvNormalizeHist( histRef, 100);
// Score = 0.0 ~ 100.0
dfScore = cvCompareHist( histSrc, histRef, CV_COMP_INTERSECT ); return dfScore;
} [/code]
{
double dfScore;
int nHistoSize = 256;
float ranges[] = { 0, 256 };
float *hist_range[] = { ranges }; CvHistogram *histSrc = cvCreateHist(1, &nHistoSize, CV_HIST_ARRAY, hist_range);
CvHistogram *histRef = cvCreateHist(1, &nHistoSize, CV_HIST_ARRAY, hist_range);
cvCalcHist(&BufSrc, histSrc, 0, NULL );
cvCalcHist(&BufRef, histRef, 0, NULL ); cvNormalizeHist( histSrc, 100);
cvNormalizeHist( histRef, 100);
// Score = 0.0 ~ 100.0
dfScore = cvCompareHist( histSrc, histRef, CV_COMP_INTERSECT ); return dfScore;
} [/code]
댓글
댓글 쓰기