opencv比较两个图片的相似性

double CmpPic(char *pic1,char *pic2)
{
 IplImage *Image1=cvLoadImage(pic1, 0);
 IplImage *Image2=cvLoadImage(pic2, 0);
 
 if(Image1==NULL)
 {
  printf("program cannot load the first picture!\n");
  return 0;
 }
 if(Image2==NULL)
 {
  printf("program cannot load the second picture!\n");
  return 0;
 }
 
 //创建直方图
 CvHistogram *Histogram1=cvCreateHist(1,&HistogramBins,CV_HIST_SPARSE,HistogramRange);
 CvHistogram *Histogram2=cvCreateHist(1,&HistogramBins,CV_HIST_SPARSE,HistogramRange);
 //计算直方图
 cvCalcHist(&Image1,Histogram1);
 cvCalcHist(&Image2,Histogram2);
 //归一化直方图
 cvNormalizeHist(Histogram1,1);
 cvNormalizeHist(Histogram2,1);
 return cvCompareHist(Histogram1,Histogram2,CV_COMP_CORREL);
 }

你可能感兴趣的:(opencv比较两个图片的相似性)