haus.cpp
上传用户:wjfckcom
上传日期:2014-06-28
资源大小:1989k
文件大小:1k
- #include "haus.h"
- float Hausdorff(struct rateseq m, struct rateseq n, struct contourrate * seq1,
- struct contourrate * seq2)
- {
- // seq1[m.index];
- // seq2[n.index];
- float t = 0.0;
- float k[21];
- int i,j;
- for(i=m.index-10; i<m.index+10; i++)
- {
- for(j=n.index-10; j<n.index+10; j++)
- {
- t=abs(seq1[i].q-seq2[j].q);
- if(k[i-m.index+10]>t)
- k[i-m.index+10]=t;
- }
- }
-
- //sequence k[21] ,get the maxvalue
- // for(i = 0; i<20; i++)
- for(j=1; j<21; j++)
- {
- if (k[0]<k[j])
- {
- float temp = k[0];
- k[0] = k[j];
- k[j] = temp;
- }
- continue;
- }
-
- return k[0];
- }
- extern IplImage* stack_imgs( IplImage* img1, IplImage* img2 )
- {
- IplImage* stacked = cvCreateImage( cvSize( MAX(img1->width, img2->width),
- img1->height + img2->height ),
- IPL_DEPTH_8U, 3 );
-
- cvZero( stacked );
- cvSetImageROI( stacked, cvRect( 0, 0, img1->width, img1->height ) );
- cvAdd( img1, stacked, stacked, NULL );
- cvSetImageROI( stacked, cvRect(0, img1->height, img2->width, img2->height) );
- cvAdd( img2, stacked, stacked, NULL );
- cvResetImageROI( stacked );
-
- return stacked;
- }